Espruino Wifi error

Posted on
  • Hi,

    When I enter on my Espruino WiFi

    var wifi = require("EspruinoWiFi");

    I get the error,

    ERROR: SD card must be setup with E.connectSDCard first
    WARNING: Module "EspruinoWiFi" not found

    The firmware is 1v91. Any help appreciated on whether this is a hardware or software issue.


  • It is not clear where you enter this. It is expected to be in the editor / right hand pane of the Web IDE and then uploaded.

    When you are connected to the Web / internet and do the upload to the Espruino board, your code is first parsed for modules required with require("..."). The modules are pulled from folder, for example -
    in this case - either as EspruinoWiFi.js or EspruinoWiFi.min.js, uploaded to the Espruino board and stored in the Modules cache on Espruino board. After that, your code is uploaded. When it comes to execution of your code, require(...) will find the requested modules in the Modules cache and load/use them. If it cannot find them in the Modules cache, it tries to find a mounted SD card and looks for it there. If no card is mounted, the error message you see is what you get.

  • Oh I got you. I was directly using screen on my mac assuming the firmware has that js module. :)
    Thank you so much !

  • I'm having the same problem. If I type this into the console in the IDE:

    var wifi = require("EspruinoWiFi");

    I get the same response:

    ERROR: SD Card must be setup with E.connectSDCard first
    WARNING: Module "EspruinoWiFi not found

    My mac is connected to the internet, but is seems like the IDE is looking to the SD card rather than looking to

    Suggestions? I'm new to Espruino as of yesterday, so I'm certain I've missed something.

    Oh, bother. Without changing anything, it's working now.

  • I'm having the same problem. If I type this into the console in the IDE:

    You need to enter this on the right hand side of the ide, so that the module can be loaded onto the board.

    If you enter it on the left side, you will get that message.

    edited by Gordon - I think you got the sides switched over :)

  • Hi there,

    So, if you have a require statement, you have to write the statement (or your code) on the right side of IDE and upload. This process downloads any dependency from the internet and uploads them correctly to the device. You will get a module not found error if you write a require statement in the REPL.
    A typical program would then have an onInit() function and a save() statement at the end of file for persistence.
    The modules are downloaded from­/tree/master/devices
    A typical program would look like this-

    var wifi;
    var werr;
    let WIFI_NAME = 'something';
    let WIFI_OPTIONS = { password: 'something' };
    let w_conn = 0;
    function onInit() {
      connWiFi().then(succ => {
        w_conn = 1;
        console.log('connected !');
        digitalPulse(LED2, 1, 100);
      }, err => {
        werr = err;
        console.log('some error in wifi connection');
    function connWiFi() {
      let prom = new Promise((res, rej) => {
        wifi = require('EspruinoWiFi');
        wifi.connect(WIFI_NAME, WIFI_OPTIONS, err => {
          if(err) rej(err);
          else res(1);
      return prom;
  • @Wilberforce... may be left and right got a bit mixed up... did it...

    Things entered on the left side are JavaScript expressions / statements that are immediately executed. Therefore, if you enter something like var mod = require("moduleName");, Espruino tries to executed that, which means: get the module from the Espruino (memory)'s Modules cache. Since it is not there, Espruino tries to look for it on a mounted SD card. If the card is not mounted, 'mount error' is printed and subsequently the 'module not found error'.

    If you really want to use the left side to load a module into the cache, you have to do it differently - as documented - in Modules.addCached("moduleName","moduleSo­urceCode"); (id and moduleName are the interchangeable).

    If you track what the IDE does when uploading code with a require("moduleName");, it does exactly above: The IDE grabs the file from­min.js as text and executes Modules.addCached("moduleName","moduleSo­urceCodeAsReadFromTheFile.min.js");.

    This though has limitations, because it does not handle nested require(...): if a module source code that you push into the cache in the left side of the IDE, you also have to that recursively for all the included require(...).

    If entered in the right side - editor side - and uploaded using the upload button - all this is taken care of.

    Now there may be the situation that modules are in deed on an SD card and the SD card is mounted on the Espruino board. If you then want to take advantage of that while still uploading code from the Editor side, you would stick the moduleName as string into a variable and then use the variable in the require expression:

    var moduleNameVar = "moduleName";
    var mod = require(moduleNameVar);

    Doing it this way, the upload process does not find a literally required module (finding the exact character sequence require("...") and therefore not jump into action a retrieve the module from the Web / or local project/modules/ sandbox folder and upload it to the Modules cache.

    When it then comes to execution, the module is not found in the Modules cache but it would hen find it on the mounted SD card (if the card is mounted...).

    (PS: there is now also an option that modules are stored as functions in Espruino cache... I do though not know how it could be done using the left side... may be the reference doc is not updated yet...).

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Espruino Wifi error

Posted by Avatar for user76916 @user76916