• @DamianMontero,

    your code id correctly structured:

    1. connect is for connecting Espruino serially with the ESP8266
    2. connect is for the wifi connection of the ESP8266 with WLAN

    Code is taken from a different board and example.

    Serial2.setup(115200, { rx: A3, tx: A2 });
    var wifi = require("ESP8266WiFi_0v25").connect(Seri­al2, function(err){
      if (err) throw err;
      console.log("Connecting to WiFi");
      wifi.connect("SSID", "PASS", function(err){
        if (err) throw err;
        require("http").get("http://www.pur3.co.­uk/hello.txt", function(res){
          console.log("Response: ", res);
          res.on('data', function(d){ console.log("--->"+d); });

    Try using wifi.at.debug(); to get more details out of the communication between Espruino and ESP8266.

    I hope the your .getPrice() thing close the http request everytime you make the access and tries not to start over all again.

    What I personally do not like is that wifi stuff is not in an onInit(). If you put it in one, declare the variables outside of onInt() and used inonInit().

    Then upload the code. Nothing will happen yet... intentionally. Then you save "save()" in the console: this will save the code in the flash (assuming you have 'no save on upload configured in your IDE), and when done, it invokes onInit(). This way you make sure that nothing runtime is saved that is not run thru and initialized when power-cycle it.

    I had no issues... the code structure is solid with the error handling... What you could think of is to do retries on error with a setTimeout() (and clearing stuff up that may be pending). I think the connect to ESP8266 is repeatable, for the connect to Wifi I would first issue a real/complete disconnect and catch eventual errors...


Avatar for allObjects @allObjects started