Pico and ESP8266

Posted on
Page
of 4
Prev
/ 4
Last Next
  • yeah, connecting the middle pin (3.3V) solves the problem. Than the red LED is on and the blue LED flashes on wifi transmission.

    thanx to@drazzy

  • Glad you got it sorted in the end!

    The middle connector (labeled: VDD) leaves unconnected.

    The Video does tell you do do it, from 3 min 11 sec onwards: https://youtu.be/zqI_g-T0HP0?t=3m11s

    It's a shame I insert the wire offscreen, but maybe I could add some text to the video to explain what's being done.

  • I've got the same problem. "No 'ready' after AT+RST". I got my pico from the kickstarter as well as the ESP8266 module. I can't get it to work. Blue led doesn't even light up.
    I've already checked that all the pins of the shim are connected at the right places. I've flashed both stable firmwares and one cutting-edge build. I've tried connecting the capacitor.
    It just won't work. What can I do?

  • Do you get the red LED lit up on the ESP8266? And when you initially plug the board in, do you not get the blue LED flashing even momentarily?

  • Got mine up and running after updating firmware. Works perfectly. Great video, thanks.

    What would be nice is some example http server code to compliment the client connect code.
    Is there any on the site for the ESP8266? All the original examples are not for this new module and I am having a tough time trying to translate.

    I am attempting to create a network of sensors controlled by a Raspberry Pi server. The Pi connects to the remote Pico's and issues commands to the listening pico's. These commands could be to retrieve values directly from the pins or to set pins to a state or call functions stored on the pico. Got a simple version working via the USB interface, but now I would like to wirelessly connect.

    Any help will be useful.

  • You can take a look at this:

    https://github.com/SpenceKonde/AzzyProje­cts/blob/master/ESPtest.js

    It was me messing around with a generic http server to run on a Pico w/ESP8266. You can uncomment that SD card stuff and it should serve stuff off the SD card, if you connect it as indicated.

    No warranty express or implied.

  • The red LED is lit up all the time, but the blue one has never lit up.
    UPDATE: I gave up and closed the IDE, but I left the espruino connected. After a while, the blue LED started lighting up randomly. Is there something wrong with my code?

  • It sounds like there was no communication between espruino and ESP8266. Did you get any errors after you sent the code? Whjat was printed to console?

    Blue light should start blinking when it runs the require("ESP8266WiFi").connect(...) line - how is it connected to the Espruino? Are you using the shim? Are you sure all the wires are connected well? Have you installed a 1uf (or more) capacitor next to the ESP8266 (there are pads on the shim for a smd one)? The ESP8266 modules seem to need one to function reliably.

  • When I send the sample code I get this error:

    Uncaught No 'ready' after AT+RST
     at line 2 col 18
      if (err) throw err;
                      ^
    in function "a" called from line 1 col 100
    ...a("No 'ready' after AT+RST");else return c}
                                   ^
    in function "d" called from line 1 col 16
    {e=void 0;d&&d()}
                    ^
    in function called from system
    

    I'm using the shim, and I've checked a lot of times that all is connected where it is meant to be. I installed a 10uF cap in the shim.

  • @cool_acid: My ESP boards worked fine with the shim without any cap. Using the example. Except that the web server will get stuck if more than one request comes in at the same time. And of course the web client will get stuck after doing about 300 requests, most of the time. I have some auto-reset code catching that condition. None of that is the problem of the Pico, I am sure. The ESPs are notorious for these kinds of things.

    But more general, in my experience those ESP boards are divas. They are cheap in more than one way. Sometimes they just don't work. Mine won't work with anything else than the Pico. For whatever reason, I don't know. Power? TX lines too long? No idea. Maybe yours just does not work. Do you have a second one to try?

  • @cool_acid, the blue LED lighting up randomly is strange... When it happens, please could you log back in, enter the line wifi.at.debug() on the left-hand side of the IDE, and let me know what gets printed?

    Please could you also check for shorts between pins A2 and A3 on Espruino (on the end of it) - that's about all I can think could be causing the random blue flashing...

  • @Eric to get a server, you just replace the require("http").get(... line with require("http").createServer. There's an example here and a bit more info on the internet page.

    The actual code should look a bit like this though:

    var WIFI_NAME = "wifi_name";
    var WIFI_PASS = "wifi_key";
    
    function pageHandler(req, res) {
        res.writeHead(200);
        res.end("Hello World");
    }
    
    Serial2.setup(9600, { rx: A3, tx : A2 });
    var wifi = require("ESP8266WiFi").connect(Serial2, function(err) {
      if (err) throw err;
      wifi.reset(function(err) {
        if (err) throw err;
        console.log("Connecting to WiFi");
        wifi.connect(WIFI_NAME, WIFI_PASS, function(err) {
          if (err) throw err;
          console.log("Connected");
          // print IP address
          wifi.getIP(console.log);
          // Create a server
          require("http").createServer(pageHandler­).listen(80);
        });
      });
    });
    

    @Stevie, yes the ESP8266 is a little unreliable as a server at the moment (I'm surprised about the 300 requests for a client though - I've left one going for days without problems). I'm hoping I can do something in the driver to make the server more reliable - but it may be that I have to come up with a way to update the firmware on the ESP8266...

  • OK Thanks for the reply.
    I see what you are doing here and it does give me some good pointers.

    I have just found Gordon's example of an interactive webpage

    http://www.espruino.com/Interactive+Web+­UI

    which is exactly the sort of thing I was trying to do. On loading it just worked!

    This is so cool.

    Thanks again.

  • Hello Gordon,

    I can't believe how helpful you have all been. DrAzzy and yourself have been great in responding so fast. Thank you for the trimmed down version it makes it perfectly clear now.

    One small question more I have is "Is it possible to take the wifi.getIP() function and make a request to a server passing the IP address as a part of the query string?"

    For example http://192.168.0.2/get_pico_ip.php?picoi­d=pico001&ip=192.168.0.171

    So in other words, I have have my Pi listening out for requests from Pico's making connections to network. The request is an announcement what the IP address is of the Pico after connection. This get's logged as a dynamic IP and can then be used by the Pi server to remotely connect and make calls, set values etc just like in your interactive web page.

    If not, I would need to set up my router to issue the same IP address for the MAC ID following initial connection, which is OK, but a dynamic approach is better I think.

  • Thanks!

    Well, as you're using PHP on the Pi, you can actually do echo $_SERVER['REMOTE_ADDR'];, which will get the IP address of the computer that accessed the webpage. In some ways that might be easier.

    But to do what you want on the Pico, you can do:

    wifi.getIP(function(err,ip) {
      if (err) return;
      require("http").get("http://192.168.0.2/­get_pico_ip.php?picoid=pico001&ip="+ip, function(res) {
       // ...
      });
    });
    

    Just in case it's helpful, there's also process.env.SERIAL on the Pico, which gives you the (hopefully unique) serial number of the microcontroller. It might mean you can use exactly the same code for multiple Picos.

    edit: just to add that this could be a bit more tricky because I'm not 100% sure you can have an HTTP server and a client at the same time on the ESP8266. You'd need to make sure you only started the server after the HTTP request closed.

  • Thanks Gordon,

    It was actually the fact that you suggested in your guide that you are not able to have a server and client running at the same time that prompted the question.

    So, the php remote address is neat, I should of known that. But to stamp it to a unique ID (like the board SN) a client call would be needed first anyway.

    To make this work, I would call the function above first to establish the connection to the Pi / register with the Pi that the Pico exists and is available for communicating, then start the server and listen for commands. Sounds OK to me.

    Thanks for the tips, I will experiment...

  • @Gordon, I have tested it with 3 different modules, always the same. I stripped down to pretty much the example code, still had that. But I heard the same also from others. It is sufficient to reset the ESP to "heal" the problem, so I am pretty sure it is not Espruino.

    +1 for a way to update the firmware!

  • Hey, guys! Thanks for all the help. I finally managed to make the ESP work. I ordered two modules with my kickstarter backing and I guess the first one that I soldered is damaged or something. When I tried with the other one, it worked like a charm the first time.
    Also, I'm going to do a "shield" for the ESP, because although the shim is really compact, it is really "permanent" and difficult to desolder. Maybe when I'm done, I'll share it. :)

  • Has anyone tried to setInterval() to poll a server every 20 seconds or so and seen the following error after about 4 polls?

    ERROR: Socket error -1 while sending
    Uncaught Error: CIPSTART failed
    at line 1 col 207
    ...d 0,Error("CIPSTART failed");}

  • That looks pretty much like what I was seeing. Only it took ~300 polls for it to happen, most of the time. Sometimes it also happened after a few tries.

    Interesting in that context: I was now able to use the ESP 8266 without the Espruino. Turned out that my old trusted Bub II FTDI board does not work with it. It works with pretty much everything else, but according to someone else a 1 MOhm resistor is keeping the ESP to work with it. I now use a Teensy as a passthrough serial adapter. With that I was able to use the AT commands and also update the firmware.

    I then installed NodeMCU on it and did the same test. Same result :-(. After about 300 requests it got stuck...

  • What happens if you try every 60 seconds instead of 20? I know I was doing that as a test and it worked for days...

    It might help to narrow down the problem.

  • If you ever let the current ESP8266 driver attempt to open more than one request at a time, it will completely fall over. So if a request isn't finished completely before the next one gets fired, things will hit the fan - a brief perusal of the ESP8266WiFi module shows why - no provision has been made for handling more than 1 socket while communicating with the ESP8266.

  • As @DrAzzy says, it could be a result of the connection not getting closed.

    Do you have the up to date firmware? The old one had some issues where connections didn't get closed if you requested a page with only one or two bytes on it.

  • OK, so I tried 60 seconds in the interval and got 19 connections but then got the following error after the final response printout:

    Response:  {
      "headers": {
        "Date": "Fri, 29 May 2015 07:58:17 GMT",
        "Server": "Apache/2.2.14 (Ubuntu)",
        "Last-Modified": "Fri, 15 Nov 2013 15:42:26 GMT",
        "ETag": "\"c01036-d-4eb390b8a8d18\"",
        "Accept-Ranges": "bytes",
        "Content-Length": "13",
        "Vary": "Accept-Encoding",
        "Connection": "close",
        "Content-Type": "text/plain"
       },
      "httpVersion": "1.1",
      "statusCode": "200",
      "statusMessage": "OK"
     }
    >Uncaught Error: Unlink already registered
     at line 2 col 22
    " already registered");g[a]=b}
                          ^
    in function "registerLine" called from line 1 col 159
    ...Line("Unlink");e[b]=void 0});else throw e[b]=void 0,Error("C...
                                   ^
    in function "d" called from line 1 col 26
    {e=void 0;var b;d&&(b=d(a))?(e=g,d=b):clearTimeout(c);­void 0...
                              ^
    in function "e" called from line 1 col 291
    ...f&&(g[f](d),n=!0);n||e&&e(d)}b=b.subs­tr(a+1);"\n"==b[0]&&(b=...
                                   ^
    in function called from system
    ERROR: Socket error -1 while sending
    Uncaught Error: CIPSTART failed
     at line 1 col 207
    ...d 0,Error("CIPSTART failed");}
                                   ^
    in function "d" called from line 1 col 16
    {e=void 0;d&&d()}
                    ^
    in function called from system
    ......
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Pico and ESP8266

Posted by Avatar for gnz @gnz

Actions