Espruino on ESP8266 ESP-09 - 1 powerful cm2

Posted on
  • I had some fun with my with my ESP-09 that had a break for a while... a break of couple years... I got it finally talking a bit more... Attached are the pics of my setup...

    To begin with, I just wired the pins for normal run via 10k resistors - GPIO0, GPIO02, RST to H, GIO15 to L - and a direct connection of CH_DP to 3.3V. The 'fat' capacitor - 2200uF - close to the 8266 makes sure that there is enough juice for spikes... As said, this was the beginning... to get things done though, I ended up with wiring more pins to PICO - like in the shim - and override the resistors.

    No matter what I did, ESP8266 ESP-09 as a pure Wifi module driven via serial from Espruino just did not want to cooperate. I ended up to put Espruino on the ESP-09 and now we are talking. The third picture shows the final setup: Espruino IDE on OS X connected via USB-to-Serial to ESP8266 ESP-09. For how I got there, keep reading.

    See also sister conversation WebServer and Chirp Sensor (moisture, temperature, light) on ESP8266 ESP-09.


    3 Attachments

    • ESP-09_wriring.png
    • ESP-09setup.jpg
    • Espruino_on_ESP8266_Esp09.jpg.jpg
  • *** NOTE *** Baudrate: Use 74880 where ever 76800 is used! (2020-11-16)

    To get something going, I started out on the https://www.espruino.com/ESP8266 page. The regular test code that connects to the module and then to my local wireless LAN threw only something like ...no ready after reset in my face. Reading up hinted Espruino module or baud rate. Module change did not help. So I used the code to discover the baud rate... this though did not help either...

    Since it did not talk back at all in this baud rate discovery code - I got empty string back for all of the listed baud rates, I wondered if really nothing comes back or the discovery code is just not up to task. Several actions I took:

    • I packed the discovery code into an onInit() called 1 second after upload completion.
    • I connected theESP8266 TX and connected it to a free pin on pico and added a watch on it:

      function gLED(e) { digitalWrite(LED2,e.state); }
      setWatch(gLED,B8,{repeat:true, edge:"both", debounce:0});
      
    • I added a reset - A01 on RST:

      digitalWrite(A10,0); // reset
      digitalWrite(A10,1);
      
    • I delayed the sending of the AT+GMR\r\n call by 100[ms] after the reset

    Now got something going... right after the reset to the point where I got input buffer overrun.

    In other words the module was not dead... the baud rate discover had the reset short coming... sending code with different baud rate without reset did not produce anything but empty string. With the reset I god information, but still all gibberish... When I initially worked on the module a couple years ago, I had used an oscilloscope and figured empirically by just looking at the signals that there was a baud rate of something 76400... searching around, I notice that others encountered 76800. Therefore I added this baud rate as well to the list of others.

    This is the final discovery code:

    // ESP8266_discoverBaudRate.js
    // (c)20181026 allObjects
    var serial = Serial2;
    var pins = { rx: A3, tx : A2 };
    function test(baud) {
      serial.removeAllListeners();
      var l="";
      serial.on('data', function(d) {l+=d;});
      serial.setup(baud, pins);
      digitalWrite(A10,0); // reset
      digitalWrite(A10,1);
      setTimeout(function(){
        serial.write("AT+GMR\r\n");
        setTimeout(function(){
          console.log(baud,":"
                      ,JSON.stringify(l));
          },800);
      },100);
    }
    
    function gLED(e) {digitalWrite(LED2,e.state); }
    setWatch(gLED,B8,{repeat:true,edge:"both­",debounce:0});
    
    digitalWrite(B9,1);  // enable on Pico Shim V2
    digitalWrite(A10,1); // 
    
    function onInit() {
      setTimeout(function() { test(  9600); }, 2000);
      setTimeout(function() { test(115200); }, 4000);
      setTimeout(function() { test( 57600); }, 6000);
      setTimeout(function() { test( 76800); }, 8000);
      setTimeout(function() { console.log("Done!"); }, 10000);
    }
    
    setTimeout(onInit,1000);
    

    Now I got something legible back... proper mode - 3 - but other than that, not very nice: very old version of firmware... something like ...ets Jan 8 2013, rst cause:2, boot mode:(3,7)...

    I tried now - with 'proper' baud rate different versions of the ESP8266 module with no success... all failed with something like ...no ready after reset....

    To get more information, I updated python from 2.7.5 to 2.7.15 and got the esptool in python installed from https://github.com/espressif/esptool - I would need it anyway for updating - and I did some reading using PICO as the mediator - or - USB to Serial. This is the modified 'bridge' code i used:

    // ESP09BridgeOnPico.js
    // (c)20181026 allObjects
    // PICO plays the role of USB-SERIAL to talk to ESP8266
    var serial = Serial2;
    function onInit() {
      var r = (typeof toBootLoader == "undefined")
            ? true
            : ! toBootLoader;
      console.log((r)?"run":"boot");
      digitalWrite(B9,1);  // CH_PD: H
      digitalWrite(A1,r);  // GPIO0: L - load / H|float - run
      digitalWrite(A10,0); // pulse reset RST
      digitalWrite(A10,1);
      // -------------------------
      serial.setup(76800, { rx: A3, tx : A2 });
      serial.on('data', function(d) { USB.write(d); });
      USB.on('data', function(d) { serial.write(d); });
      Serial1.setConsole();
    }
    
    var toBootLoader = true;
    
    setTimeout(onInit,1000);
    

    In bootloader mode, esptool could read the chip_id and flash_id. The chip_id showed ES8266 as expected, but the memory showed 8Mbit - 1MB.

    $   python2 ../esptool/esptool.py --port /dev/cu.usbmodem1421 chip_id
    esptool.py v2.6-beta1
    Serial port /dev/cu.usbmodem1421
    Connecting...
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Features: WiFi
    MAC: 18:fe:34:9c:15:3b
    Uploading stub...
    Running stub...
    Stub running...
    Chip ID: 0x009c153b
    Hard resetting via RTS pin...
    $
    

    and

    $ python2 esptool.py -p /dev/cu.usbmodem1421 flash_id
    esptool.py v2.6-beta1
    Serial port /dev/cu.usbmodem1421
    Connecting...
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Features: WiFi
    MAC: 18:fe:34:9c:15:3b
    Uploading stub...
    Running stub...
    Stub running...
    Manufacturer: ef
    Device: 4014
    Detected flash size: 1MB
    Hard resetting via RTS pin...
    

    It took though always two attempts after a power connect. The first choked in the esptool on the double listing of the USB to Serial device /dev/cu.usbmodem1421 in OSX (only bottom of the stack trace shown):

      ...
      ...
      File "/usr/local/lib/python2.7/site-packages/­serial/serialposix.py", line 501, in read
        'device reports readiness to read but returned no data '
    

    I usually connect to the second one... so I tried the first one, and it got worse: python claimed that the device would be busy and cannot be opened and read from...

    ...
    ...
      File "/usr/local/lib/python2.7/site-packages/­serial/serialposix.py", line 268, in open
        raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
    serial.serialutil.SerialException: [Errno 16] could not open port /dev/cu.usbmodem1421: [Errno 16] Resource busy: '/dev/cu.usbmodem1421'
    

    Now I was looking for updating the ESP8266 ESP-09 module... and found the 0.50 - declared old by espressif, but tested by @Gordon... - https://bbs.espressif.com/viewtopic.php?­f=46&t=1123

    python2 ../esptool/esptool.py --port /dev/cu.usbmodem1421 \
    >   write_flash --flash_freq 40m --flash_mode qio --flash_size 8m \
    >   0x0000 "boot_v1.4(b1).bin" 0x1000 512+512/user1.1024.new.2.bin \
    >   0xfc000 esp_init_data_default.bin 0x7e000 blank.bin 0xfe000 blank.bin
    ------ (second attempt):
    WARNING: Flash size arguments in megabits like '8m' are deprecated.
    Please use the equivalent size '1MB'.
    Megabit arguments may be removed in a future release.
    esptool.py v2.6-beta1
    Serial port /dev/cu.usbmodem1421
    Connecting...
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Features: WiFi
    MAC: 18:fe:34:9c:15:3b
    Uploading stub...
    Running stub...
    Stub running...
    Configuring flash size...
    Flash params set to 0x0020
    Compressed 2752 bytes to 2006...
    Wrote 2752 bytes (2006 compressed) at 0x00000000 in 0.3 seconds (effective 81.2 kbit/s)...
    Hash of data verified.
    Compressed 278676 bytes to 202043...
    Wrote 278676 bytes (202043 compressed) at 0x00001000 in 26.7 seconds (effective 83.4 kbit/s)...
    Hash of data verified.
    Compressed 128 bytes to 76...
    Wrote 128 bytes (76 compressed) at 0x000fc000 in 0.0 seconds (effective 57.1 kbit/s)...
    Hash of data verified.
    Compressed 4096 bytes to 26...
    Wrote 4096 bytes (26 compressed) at 0x0007e000 in 0.0 seconds (effective 3014.5 kbit/s)...
    Hash of data verified.
    Compressed 4096 bytes to 26...
    Wrote 4096 bytes (26 compressed) at 0x000fe000 in 0.0 seconds (effective 2984.9 kbit/s)...
    Hash of data verified.
    
    Leaving...
    Hard resetting via RTS pin...
    

    After successful flashing, I was still not successful to connect to the device... same error: ....no ready after RST...

    My last shot was now something a first for me: put Espruino on a non-Espruino board... something I was always discouraging people to do, because ESP8266 is just not the right setup... Taking the combined binary and ignoring the extra 512KB in the ESP-09 vs the ESP-01, I successfully could flash the ESP-09 - of course - as Murphy wants to be part of the game - only the second attempt was successful:

    python2 ../esptool/esptool.py --port /dev/cu.usbmodem1421   write_flash --flash_freq 40m --flash_mode qio --flash_size 8m  0x0000 espruino_2v00_esp8266_combined_512.bin
    WARNING: Flash size arguments in megabits like '8m' are deprecated.
    Please use the equivalent size '1MB'.
    Megabit arguments may be removed in a future release.
    esptool.py v2.6-beta1
    Serial port /dev/cu.usbmodem1421
    Connecting...
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Features: WiFi
    MAC: 18:fe:34:9c:15:3b
    Uploading stub...
    Running stub...
    Stub running...
    Configuring flash size...
    Flash params set to 0x0020
    Compressed 524288 bytes to 324783...
    Wrote 524288 bytes (324783 compressed) at 0x00000000 in 43.0 seconds (effective 97.6 kbit/s)...
    Hash of data verified.
    
    Leaving...
    Hard resetting via RTS pin...
    

    Too lazy to dig up a USB-Serial cable, I switched my Espruino Bridge on PICO to run mode and loaded the bridge - w/ 76800 talking to ESP-09: Great... for the begin... bad gibberish at the end:

             |_| espruino.com
     2v00 (c) 2018 G.Williams
    >
    run
    -> Serial1
     ets Jan  8 2013,rst cause:2, boot mode:(3,6)
    load 0x40100000, len 2408, room 16
    tail 8
    chksum 0xe5
    load 0x3ffe8000, len 776, room 0
    tail 8
    chksum 0x84
    load 0x3ffe8310, len 632, room 0
    tail 8
    chksum 0xd8
    csum 0xd8
    2nd boot version : 1.6
      SPI Speed      : 40MHz
      SPI Mode       : QIO
      SPI Flash Size & Map: 8Mbit(512KB+512KB)
    jump to run user1 @ 1000
    rf cal sector: 251
    freq trace enable 0
    rf[112]å>/9!~'¡¡¡¡¡¡¡¡ÈPrç~è~'~è'nn~è~'È­Pr'©P@.¡r(PPP¡P@n î~çrç~.¡r'Pn~îr'nn~n (¡¡¡¡nP$pzùë~å!µÇ,¡Z¡±¡¶gñjÉêNXaÖpzùhÉèÁ­ªAåÙív@c×P·p
    ¡µpÁn§Nx|é¨zµÄv«·zZrAéÉ-×PÄt©ñ(~Ém (çp{$pzùë~åñ(§N(|$x©Pâ`±{¹©©Äv,v)é,±T±%a­ ï 
    

    A via 9600 baud to 115200 got my bridge working and I can see Espruino on ESP-09:

             |_| espruino.com
     2v00 (c) 2018 G.Williams
    >
    run
    -> Serial1
    sllscânlìp|ìp|bpp~ònlooccpìbl`rlpòoàlcoâãob|~ònïll`onl`nrsl`pònàràbnâânìpòooîl`nnl`osîlpóoàsìboã|p|ónîl`ool`nrsl`rïàl`slnp~ònãroonlblìllìllllrlìlllol~`ìllpsnìlbbllàbllpbbrìl`oloccllîn|lcll`slâìpnì|rbcll`cðslnàoâl`ãsllþ
     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v00 (c) 2018 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 1MB:512/512, manuf 0xef chip 0x4014
    >process.env
    ={
      VERSION: "2v00",
      GIT_COMMIT: "ff35517",
      BOARD: "ESP8266_BOARD",
      FLASH: 0, RAM: 81920,
      SERIAL: "18fe349c-153b",
      CONSOLE: "Serial1",
      MODULES: "Flash,Storage,hea" ... "r,crypto,neopixel",
      EXPTR: 1073643636 }
    >process.memory()
    ={ free: 1668, usage: 32, total: 1700, history: 4,
      gc: 0, gctime: 1.365 }
    > 
    

    There is still some gibberish... until Espruino in ESP-09 switches to 115200, and logo and everything shows nice... Going back to my baud rate discovery shows that some stuff comes in at 76800 and then Espruino switches baud rate to 115200.

    Next step is really getting this USB-Serial cable out... to test the Wifi part... of course, I could manually load the modules through the console... but that's not fun.

    I still hope to be able to get back and just drop ESP on ESP-09 rather than Espruino. May be I should have listened to the comment on the espressif page with the AT 0.50.0.0 download - see screenshot.


    1 Attachment

    • ESP_8266_AT_0.50.0.0.notToUseAnymore.png
  • ...long story short - after digging up the versatile USB-to-Serial: Hurray, it just woks: Espruino 2v00 on the mini ESP8266 ESP-09 - 10x10mm (~3/8..0.393..7/16").

    See also sister conversation WebServer and Chirp Sensor (moisture, temperature, light) on ESP-09.

    // EspruinoOnESP09Test.js
    // after flashing w/ Espruino 2v00 via pico
    
    var wifiCreds = require("wifiCreds");
    
    var wifi = require("Wifi");
    
    function onInit() {
      console.log("Connecting to wifi...");
      wifi.connect(wifiCreds.ssid
          , {password:wifiCreds.pw}, function(err) {
        if (err) {
          console.log('error during connect:',err);
          wifi.disconnect();
        } else {
          console.log('Connected to wifi.');
          wifi.stopAP();
          //wifi.save();
        }
      });
    }
    
    setTimeout(onInit,1000);
    

    And console output:

    `
    >
     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v00 (c) 2018 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 1MB:512/512, manuf 0xef chip 0x4014
    >
    Connecting to wifi...
    Connected to wifi.
    >process.env
    ={
      VERSION: "2v00",
      GIT_COMMIT: "ff35517",
      BOARD: "ESP8266_BOARD",
      FLASH: 0, RAM: 81920,
      SERIAL: "18fe349c-153b",
      CONSOLE: "Serial1",
      MODULES: "Flash,Storage,hea" ... "r,crypto,neopixel",
      EXPTR: 1073643636 }
    >process.memory()
    ={ free: 1633, usage: 67, total: 1700, history: 52,
      gc: 0, gctime: 1.397 }
    >
    `
    

    1 Attachment

    • Espruino_on_ESP8266_Esp09.jpg
  • Wow, nice - and it looks like the aerial works ok?

  • Aerial - whip antenna - works nice... it is 1/4 wave length (31mm). The -45 degrees ground plane though is missing, so I do not know the impedance... (The original, intended use of the ESP-09 was within an H0 model train engine of metal - an ideal ground plane.) - On the breadboard as pictured, the big fat electrolyte capacitor may help with the radiation with its aluminum case. My wifi access point is actually pretty far away: I sit at one end of the house on second floor and the access point is at the other end of the house on first floor.

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

Espruino on ESP8266 ESP-09 - 1 powerful cm2

Posted by Avatar for allObjects @allObjects

Actions