[SOLVED] Unable to execute code on an ESP8266

Posted on
  • I'm new to using Espruino and i am trying out ThingsSDK sample project to run Espruino on a NodeMCU ESP8266.

    I have flashed Espruino -1v91 via Flasher.js.app on my Mac and the flash works perfectly on the port /dev/cu.SLAB_USBtoUART and suceeds

    But when doing 'node run dev', i encounter the error 'unable to connect'. I've tried both the supported baud rates and still it has the same issue.

    user$ npm run dev

    sample1@0.0.0 dev /Users/user/someFolder/IOT/Espruino/sample1
    node ./scripts/upload development && npm run repl

    Treeshaking code... Sending code to device - /dev/cu.SLAB_USBtoUART @

    9600 baud... espruino: Espruino Command-line Tool 0.0.23

    espruino: Connecting to '/dev/cu.SLAB_USBtoUART' espruino: Port
    "/dev/cu.SLAB_USBtoUART" not found espruino: Unable to connect!
    Exited with status 0

    sample1@0.0.0 repl /Users/user/someFolder/IOT/Espruino/sample1
    node ./scripts/repl

    Connecting REPL... espruino: Espruino Command-line Tool 0.0.23

    espruino: Connecting to '/dev/cu.SLAB_USBtoUART' espruino: Port
    "/dev/cu.SLAB_USBtoUART" not found espruino: Unable to connect!

    I've tried to connect Espruino Web IDE and it shows connected but whenever i send a javascript line to evaluate it sends it but there's no response back displayed. No visual indication if something executed or not.

    Has anyone else faced this issue? Any help is appreciated. I just have a Mac machine to experiment on.

  • I'm on the same path. Trying to figure out to get nodemcu esp8266 running Espruino. I've had no luck. Something I wasn't aware of when I bought mine was that there are many versions of the esp8266.

    Can you give us some more details of exactly which board you have?

    Here's what I purchased:
    HiLetgo New Version ESP8266 NodeMCU LUA CP2102 ESP-12E
    *The one I bought has "Amica" written underneath

    In particular, the '12E' part is a different model than many other users on this forum seem to have had success with. Secondly, all of the tutorials I've ran through mentioned needing to set the baud rate to 115200 (my board literally has 'set baud rate to 9600' stamp on the underside), but I believe we're still supposed to set baud rate to 115200 (someone please correct me if this is in error). I've also tried the ThingsSDK tutorial to no avail.

    My experience:
    Flashing the device seems to work flawlessly, getting it to display anything but unintelligible character strings with screen --port /dev/tty.SLAB_USBtoUART --baud 115200 has not be successful. Espruino Web IDE allows me to connect when baud rate is set to 115200 however, the console is unresponsive (no text or commands are respected when trying to type into the terminal window). When I open the Web IDE settings menu and click console, the log shown there says that it connect and got a prompt, but also says that it ... just got "" response from it. This suggests that the boot_v1.6.bin file does not load correctly. I mentioned in an earlier post 9 months ago @MaBe said we should switch out boot_v1.6.bin for boot_v1.5.bin. I've yet to find a copy of it in the archived files though :(

    Let me know if you figure it out!

  • I've got 2 Node MCU ESP8266's and I believe both of them are a 12E too. I dont have a link to share as i bought them off from a local store.

    But on one, i have the Amica branded one (the other one was a GPIO chart behind, no brand). which mentions "Use 9600 baud rate"

    I was able to program these two devices in Arduino IDE and work with various sensors too.

    About Espruino Web IDE, i have the same behavior as you described above. Not responding.

    i'll look for the older boot_v1.5.bin. Perhaps these should be a part of the Older Espruino releases v1.87 ?

  • I have a new development.. I've kept trying the same steps but for some reason it started working. I will try to re-create the steps and post back with another update. So what i recall to have done was

    1. Follow this article and downloaded this espruino_1v94.154_esp8266_4mb.tgz file.
    2. Tried to get an older boot1.4(b1).bin from a ESP8266 firmware - but this did not work and had the same issue.
    3. Went back to use the boot_v1.6.bin which was there in the original espruino package and used esptool.py to flash the ESP8266. I modified this slightly to mention --flash_size as 4MB instead of 32m (this comes as a warning, so i've modified that).
    4. Flash the ESP8266
      > esptool.py --port /dev/cu.SLAB_USBtoUART --baud 115200 erase_flash

    Important step here is to disconnect and re-connect the ESP8266 from the USB.

    1. Burn the downloaded image

    esptool.py --port /dev/cu.SLAB_USBtoUART --baud 115200 write_flash
    --flash_freq 80m --flash_mode qio --flash_size 4MB 0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin 0x3FC000
    esp_init_data_default.bin 0x3FE000 blank.bin

    1. Opened up Espruino IDE and connected to 1 of the 2 USBtoUART options that it always displays. And ran the sample code.

      var wifi = require("Wifi");
      wifi.connect("my-ssid", {password: "my-password"}, 
      function(err){if(err)console.log(err);else console.log("connected!");})
      

    and it started working. I am still testing out other APIs.. Another sample that i was able to do was

    This blinks the onboard LED ON and OFF every 500ms.

    var isOn = false;
    var interval = 500;
    function main() {
        setInterval(function () {
            isOn = !isOn;
            digitalWrite(D2, isOn);
        }, interval);
    }
    main();
    
  • @stevo Updated with another post below. Hope that gets your work going too!

  • Update 1 - I still haven't been able to run this through the ThingsSDK CLI. It still says "Cannot connect" to the same port. Even though i have disconnected that from the Espruino Web IDE

  • Awesome, can't wait to try this out!
    Thanks for the update.

  • Uhg, no difference for me. Same errors as before. No clue where to go from here. Thanks for your help anyhow @swaroop

  • Ah ha the answer for me was changing from 'qio' to 'dio'.
    No more errors woot!

  • Woot!.. that is good news.

    It was documented on the ESPTool page

    Most boards use qio mode. Some ESP8266 modules, including the ESP-12E
    modules on some (not all) NodeMCU boards, are dual I/O and the
    firmware will only boot when flashed with --flash_mode dio. Most ESP32
    modules are also dual I/O.

  • Yeah you're right. I was in a hurry or perhaps just frustrated and didn't read it carefully. :D

  • Great, thanks. I thought it was a hardware defect (mine has alse the text reversed). Just switched to dio, now it works perfectly.

  • I'm trying to keep updated nodemcu esp8266 12e documentation - in regards to flashing and other issues specific to that board.

    Any chance you have a screenshot, error log, or steps to reproduce the 'text reversed' issue you encountered? Those would be useful to add to the document/conversation for others who might be searching for 'reversed text' and whatever errors may be showing up.

  • The reversed text is the text printed on the chip, here's a photo comparing to normal text :


    1 Attachment

    • aliexpress2.jpg
  • @Polypod suspect your circuit isn't reversed just the metal case is rotated 180 degrees

  • @Polypod Also the first one has a proper F antenna, which -- unless I am mistaken -- results in better radio performance.

    https://en.wikipedia.org/wiki/Inverted-F_antenna

  • One on the right is an ESP12E, one on the left is an ESP12F.

    The ESP12F has a better antenna as noted above.

    Does using DIO instead of QIO mode (on boards wired for the former only) mean that we can use GPIO 9 and 10 from within Espruino?

  • Not tried it out yet, I've been meaning to do a test run off all the pins to get a solid mapping set. Anyone else?

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

[SOLVED] Unable to execute code on an ESP8266

Posted by Avatar for swaroop @swaroop

Actions