• I just debugged a problem with ESP8266 v0.95(b1) firmware and the latest Espurino build in file network_esp8266.c:
    1) Sending the command AT+CWJAP="",""
    now longer seems to work, so this code now always fails:

      libs/network/esp8266/network_esp8266.c:  JsVar *cmd = jsvNewFromString("AT+CWJAP=\"\",\"\"\r\n­");
    

    I changed this command to AT+CWQAP for now to test

    2) Sending any AT commands with \r\n fails - use \r only when sending to the esp8266

    3) Looks like the esp8266_connect() timeout of 500ms is way way to fast especially when connecting to an AP (should be over 5 seconds, ie 10000)
    Adding -dESP8266_DEBUG to the defines section of the Makefile helps watch the progress of the failures

    Code I used to test: (note I have an STM32F4 (407) Discovery board)

    Serial4.setup(9600, { rx: A1, tx : A0 });
    console.log("Connecting to ESP8266");
    var wifi = require("ESP8266").connect(Serial4, function() {
     console.log("Connecting to WiFi");
      wifi.connect("your_ssid_here","your_pass­word", function() {
        console.log("Connected");
        require("http").get("http://192.168.1.1"­, function(res) {
          console.log("Response: ",res);
          res.on('data', function(d) {
            console.log("--->"+d);
          });
        });
      });
    });
    

    Debug Log so far all timeouts updated to 10000 in libs/network/esp8266/network_esp8266.c

    >Serial4.setup(9600, { rx: A1, tx : A0 });
    =undefined
    >console.log("Connecting to ESP8266");
    Connecting to ESP8266
    =undefined
    >var wifi = require("ESP8266").connect(Serial4, function() {
    :  console.log("Connecting to WiFi");
    :  wifi.connect("your_ssid_here","your_pass­word_here", function() {
    :    console.log("Connected");
    :    require("http").get("http://192.168.200.­1", function(res) {
    :      console.log("Response: ",res);
    :      res.on('data', function(d) {
    :        console.log("--->"+d);
    :      });
    :    });
    :  });
    :});
    >>> "AT+CWQAP\r"
    ={  }
    ESP8266> "AT+CWQAP"
    ESP8266> ""
    ESP8266> "OK"
    >>> "AT+CWMODE=1\r"
    ESP8266> "AT+CWMODE=1"
    ESP8266> ""
    ESP8266> "OK"
    >>> "AT+RST\r"
    ESP8266> "AT+RST"
    ESP8266> ""
    ESP8266> "OK"
    ESP8266> "D�I\x11�H\x112�\x00�a�k#��'��\"\b\x11\x­00���"
    ESP8266> ""
    ESP8266> "Vendor:http://www.ai-thinker.com"
    ESP8266> ""
    ESP8266> "SDK Version:0.9.5(b1)"
    ESP8266> "Compiled @:Dec 25 2014, 21:50:58"
    ESP8266> "ready"
    >>> "AT+CIPMUX=1\r"
    ESP8266> "AT+CIPMUX=1"
    ESP8266> ""
    ESP8266> "OK"
    Connecting to WiFi
    >>> "AT+CWJAP=\"your_ssid_here\",\"your_pass­word_here\"\r"
    ESP8266> "AT+CWJAP=\"your_ssid_here\",\"your_pass­word_here\""
    ESP8266> ""
    ESP8266> "OK"
    >>>> "AT+CIFSR\r"
    ESP8266> "AT+CIFSR"
    ESP8266> "+CIFSR:STAIP,\"192.168.200.232\""
    ESP8266> "+CIFSR:STAMAC,\"18:fe:34:9e:2d:29\""
    ESP8266> ""
    ESP8266> "OK"
    Uncaught Error: WiFi network connection failed
    

    You can see the connection works - but the return status is wrong

  • Thanks - that's interesting... When connecting to an AP on earlier versions it returns almost instantly and it's hard to tell when it's connected (hence the polling for IP address). They obviously fixed that in later ones.

    I'll have to check if just sending /r works on earlier versions too. If so it might be able to check what firmware it has and do the relevant things depending on it.

    Is 0.95 actually an official firmware? I wonder if it's something specific to ai-thinker.com ?

    EspressIF have pulled it from being Open Source now so I'm not 100% sure what's going on. I know Adafruit seem to ship with 0.94, and I just ordered a bunch of ESP8266 modules for the KickStarter and that's what they ship with too.

  • Yes 0.9.5 (b1) is the latest offical firmware
    I am getting closer to working code aftre making a few more changes and fixing a broken test. I am now stuck with a new bug that AT+CIPSEND=NN,XX drops all \r characters over the network (this is really only a ESP8266 0.9.5 (b1) code bug) causing the sent size to mismatch and timeout waiting for more characters.
    See: http://www.esp8266.com/viewtopic.php?f=1­3&t=1610

    Once I work this out everything should start working and I can post diffs to network_esp8266.c - just in cases others don't want to wait for an offical fix by the Author.

    This is what I am now getting after the CWJAP command "OK" response - see first post
    (the last SEND OK is actually from the IPCLOSE command not the send)

    ESP8266> ""
    ESP8266> "OK"
    >>>> "AT+CIFSR\r"
    ESP8266> "AT+CIFSR"
    ESP8266> "+CIFSR:STAIP,\"192.168.200.232\""
    ESP8266> "+CIFSR:STAMAC,\"18:fe:34:9e:2d:29\""
    ESP8266> ""
    ESP8266> "OK"
    Connected
    >>> "AT+CIPSTART=0,\"TCP\",\"192.168.200.1\"­,80\r"
    ESP8266> "AT+CIPSTART=0,\"TCP\",\"192.168.200.1\"­,80"
    ESP8266> "0,CONNECT"
    ESP8266> ""
    ESP8266> "OK"
    >>> "AT+CIPSEND=0,64\r"
    ESP8266> "AT+CIPSEND=0,64"
    ESP8266> ">"
    ERROR: Socket error -1 while sending
    >>> "AT+CIPCLOSE=0\r"
    Uncaught Error: Send failed
    ESP8266> " GET / HTTP/1.0User-Agent: Espruino 1v74Connection: close
    ESP8266> ""
    ESP8266> "SEND OK"
    
  • AT+CIPSEND=NN,XX drops all \r characters over the network

    Wow, that's a huge bug! They must have tested that surely as it makes HTTP requests pretty much impossible.

    Do you think your changes are going to be compatible with 0.94? The reason I ask is I'll be sending out 0.94 ESP8266s with the Pico KickStarter, and I want to be sure that they'll still work without a firmware update!

    I'm not sure how you're developing, but did you know that you can run Espruino under Linux and can use the Serial ports? It makes it much faster to compile run and debug on the host machine :)

    Also I don't know what you think but I'm considering modifying the ESP8266 support so that there's C code that handles sending commands and listening for return values, but the actual interaction with the ESP8266 is done in JavaScript (which is more sensible for all the 'do this then that then that' stuff). Main reason is that I've had a few requests for GSM/GPRS (and SMS) support, and while other modules use similar commands, they're not identical.

  • HI Gordon,
    I can check for you to see what 0.94 does.
    Thanks for the tip about using the Linux/Espruino - that may help however at the moment I find that recompile to new firmare takes under 30 seconds at the moment.
    I have been switching between controlling the device directly via USB ftdi232 converter and via the Espruino and with the espurino code for testing. (I made a lttitle test board that has a ESP8266 socket, reset and ESP8266 flash mode enable jumpter and a ftdi232 device - that makes rapid switching easy during debugging. I have also been using JS serial read/write code on the Espurino to talk with the device without using the connection methods. I will have way more time tomorrow night and this weekend - I really hope to get it all working. I will be sure to try a few different versions of the ESP8266 firmware and report my results.

  • Hello,

    I have firmware 0.924 as recommended in the documentation and I have a similar problem. The callback function of the connect function of the driver is never getting called. I checked the response of the ESP8266 by using Serial4.on('data', ...) and I got the AT+CWJAP error as well.

    AT+CWJAP="",""
    
    ERROR
    

    I am using Espruino 1.75.

    Best,

    Tobias

  • Yes, I'm finding problems too - the boards I got for the KickStarter rewards are 0018000902-AI03, and they appear to be different yet again.

    @user6134 if you don't mind, please could you contribute your changes?

    Right this second I'm actually making a JavaScript ESP8266 library which should make it easier to account for all these quirks.

  • ...sounds like: testing Espruino Pico is one thing... having to test (all) the ESP8266 was not part of the plan... held-up by 3rd party firmware flaw that can be sw-'compensated' should not become a held-up, at least it is not a held-up for me...

    Libraries and mixed greens salad - sorry, meant to say mixed versions - recalls / echoes @boneskull 's thread...

  • Yes, so sadly Espruino ships with ESP8266 support as it is right now. Hopefully by the time they're received a software update will fix it though.

  • For anyone interested: https://github.com/espruino/EspruinoDocs­/blob/master/devices/ESP8266.js

    This should be a lot easier to hack around with. I haven't pushed the version of Espruino this needs yet, but in terms of network connection/etc it'd work on Espruino as it is now - it's just the link from the HTTP server back to JS that's missing.

    Again, a port of this to GSM should be trivial, and I'll be trying to do that soon.

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

FYI - ESP8266 0.95 firmware requires minor changes to driver under Espurino 1v74

Posted by Avatar for magore @magore

Actions