How to upload JavaScript modules/files to ESP

Posted on
  • I am using NodeMCU with ESPruino, I could blink few LEDs successfully, but really facing tough time with ESPruino, without much document on JS on NodeMCUs.

    I don't know how to upload files like DHT11.js to NodeMCU, can you please give some pointers and tutorials on ESPruino with NodeMCU? I tries google a lot, able to upload the firmware, blink LEd, looking forward to use file uploads. I tries uploading files on Lua Firmware, it was working, also tried with Smart.js, I could make file upload possible with their GUI tool.

    Please help me with useful resources on ESPruino and JavaScript on NodeMCU.

  • Once you've flashed Espruino, you don't need to put anything in as a file.

    Connect to the board using the Espruino Web IDE (see note below), and put your code in the right-hand side of the window. You can require() the modules by name (if they're on the official Espruino site) or you can enter a URL to point to a version hosted somewhere else, or you can set up the sandbox option to load modules from your computer instead of fetching them from the web. In any event, when you click the send to Espruino button, the IDE will grab the appropriate modules and send them to the Espruino (using Modules.addCached() ), minify your code (configurable in settings) and send that to the Espruino as well.

    If you click the left hand side and press the up arrow after uploading, you can see the commands it sent.

    (connecting with IDE) this can be done over serial - though you have to change the serial speed - or over telnet. See for info on how to set this up; I usually log in over serial after flashing using a non-Espruino terminal, set it up to use my wifi, and then connect only via telnet.

  • @DrAzzy,

    Thanks for tips. I launched Web IDE (Chrome), could connect to the device over serial port. Also send Code was succeeded after few failed attempts ("got errors like prompt not found").

    I was not able to type in the terminal on the left side, also I could not see my console.log statement outputs over serial port.

    Instead I connected to 'Flash'n'Chips' from smart.js, I could write statements like

    setInterval(function(){console.log("Hell­o");}, 1000) could print "Hello" for every second, I could see over terminal.

    Can I type code in command prompt/console shown left side of the IDE? To me, typing is not working on command prompt, also console.log on the device is not printed.

    ü !!¡1ÿ¿ö¿T¦ÒÒÿÿáÂô3ïèVÆD½0ERROR: Prompt not detected - upload failed. Trying to recover...
    ERROR: Prompt not detected - upload failed. Trying to recover...
    ü"(BÂT¾Ð¾×c31çõþÿ!å¶ç!Ö+BæERROR: Prompt not detected - upload failed. Trying to recover...
    ERROR: Prompt not detected - upload failed. Trying to recover...

    Another newbie question, to connect over ssh, how do I know the IP address of the ESP module running Espruino?

  • You probably have the wrong baud rate? you need 115200.

  • @Gordon, You are right, I had bad baudrate, Thanks a lot saving me.

    Little more information.

    1. How do I store static files like images into ESP, serve them via HTTP?
    2. How do I store JSON file which can be opened and parsed by JavaScript code.

    I am trying to store angular.js within ESPruino, run simple REST service along with static index.html file, angular.js files on ESPruino, to run a simple web server with REST background.

    I learned that all the required modules are automatically uploaded to ESPruino after minimizing it, but not sure how to store and serve files externally.

  • After going through samples, I found that ESPRuino needs SD card to store the files. I remember either with smart.js or NodeMCU Lua firmware, I was able to have file, that can be listed, including init.lua without SD card.

    Any pointer to store files without SD card would be great, I have no experience in hardware to connect SD card.

  • You can use, or as is done in pretty much all the examples you can use to convert files into strings that you include in your code.

    But it's worth browsing the forum as there are a few other posts where people have stored files and things in flash in other ways.

    Also, it is just Espruino, not ESPruino - the ESP8266 came after Espruino, so it's just coincidence :)

  • What better to call an ESP8266 running Espruino, but ESPruino?

  • ESPruino8266?

  • new trademark to grab / register: ESPruino8266™ / ESPruino8266®... ;-|

  • Well the new kid on the block will be the esp32 - the dual core version of the esp8266 with more ram and Bluetooth and wifi... So:

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

How to upload JavaScript modules/files to ESP

Posted by Avatar for user64299 @user64299