• Hi,

    I am still trying to have my Pico+ESP8266 act as simple HTTP server. It has been working last week (inconvenient of having this only as a hobby project :/ ) but now I keep getting this error.

    I used http://www.espruino.com/Interactive+Web+­UI to kick start my code. It still is pretty close to it. The first request I make works, but the second always triggers this error:

    Here, as seen in the Web IDE's console:

    GET /
    GET /
    ERROR: Socket error -1 while sending
    Uncaught Error: > not registered at line 2 col 64 ...Error(key+" not
    registered");
    ^
    in function "unregister" called from line 7 col 26
    at.unregister('>');
    ^
    in function "callback" called from line 4 col 40
    if (callback && (n=callback(d))) {
    ^
    in function "lineCallback" called from line 29 col 27
    lineCallback(l);
    ^
    in function called from system

    Code:

    var wifi;
    
    function connectWifi(){
      
      Serial2.setup(9600, { rx: A3, tx : A2 });
      
      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);
          });
        });
      });
      
    }
    
    
    function pageHandler(req, res) {
      console.log(req.method,req.url);
      if (req.method=="POST") {
          res.writeHead(200);
          res.end('POSTHOME');
      } else if (req.method=="GET") {
        if (req.url=="/") {
          res.writeHead(200);
          res.end('GEThome');
        } else {
          res.writeHead(404);
          res.end("404: Not found");
        }
      } else if (req.method=="OPTIONS") {
        if (req.url=="/") {
          res.writeHead(404);
          res.end();
        }
      }
    }
    
    connectWifi();
    

    I spent several hours looking for the origin of the error, as well as its cause with no luck. Does someone recognise it?

  • Check the version of the firmware on your ESP8266

  • 0018000902-AI03

    I'm ordering a USB-TTL converter and will upgrade. Thanks. I read the ESP page too fast:

    If you don't have the 0018000902-AI03 firmware version, make sure you
    change the baud rate and Module Name in the code examples below.

    So I concluded that it was all right for me.

    But now I see in the table is written for 0018000902-AI03:

    This was the version sent on boards that came with the Espruino Pico
    KickStarter. It's quite old now, and is known have quite a few bugs.

    Thank you @DrAzzy

  • I was having this issue too, I solved it by changing to firmware version 0.25.0.0. You can download the new firmware from the ESP page. Don't forget to change the javascript module to "ESP8266WiFi_0v25".

  • Thanks. The USB TTL should arrive soon.
    Gordon wrote it is "quite difficult". Does he mean complex or risky (big chance of frying something)?

  • I'm not sure. I didn't have any trouble with the software (on Linux), it just flashed when I used the esptool command. Hardware-wise was fiddly, you need to connect up 6 of the pins on the ESP8266, and I needed a voltage regulator to supply the 3.3v because the USB-TTL couldn't supply enough current for the ESP8266. It's still not too hard if you've got all the parts and you know where everything goes. Might be hard to hook up if you've got the shim soldered on.

  • It is soldered with the shim. Everything is going to be ok :)
    But maybe I should order a backup Espruino and ESP, just in case...

  • Does he mean complex or risky (big chance of frying something)?

    Not really, just that it'll probably require some soldering to connect the wires if using the shim. However it can be done without too much trouble...

    In fact with one of the new builds of Espruino from Git and some minor tweaks, you can update the ESP8266 using just the Pico board - see @Ingmar_Guillaume's post a few after that too - you need to tweak the firmware updater to get it reliable.

  • Great! I'll try this solution first then.

  • Hi, I'm getting very similar errors on my pico with the ESPs and I've tried absolutely everything I can think of to fix it.

    I've tried an old ESP-07 (the one with the extra GPIOs broken out and ADC), old ESP-01 (as in the documentation) and a brand new ESP-07. All with both ESP firmwares as suggested in this thread. I have tried pico firmware v79 and a bleeding edge v80 from git this morning (there have since been a few more commits, a very good sign. Nice one!).

    I can connect to WIFI and do AT+ commands and the sample code slimmed down a bit works reliably for 'page' ≈ 1Kb, but I get the same not registered error as MrPeu if it's much bigger.

    I'll add that I'm using Serial1 and pin B6/7 and not 2 and A2/3 as in the tutorial. Why bother with 0.05" pitch when you don't have to? I've tried the same setup with serial2 A2/3 once, just in case but couldn't be arsed with the fiddling once it didn't work.

    I unfortunately realised at around midnight that I don't need to be faffing around with >1Kb responses anyway and that all of this was a big distraction.

    I suppose if this crops up for someone else you could use 307 redirects to a proper webserver that is a bit more suited to do the heavy lifting? Or maybe just ditch the ESP for now and go with another wifi option. It's a mysterious beast for many people outside of China. Or outside esspressif for that matter.

  • Why bother with 0.05" pitch when you don't have to?

    It's just because that's what the shim uses to avoid using up pins that are a bit easier to use for other things. There's absolutely no problem using other pins, but B6/B7 are used by default for the console when USB is disconnected, so when you're not connected to a PC with USB you'll need to make sure you move the console back away from B6/B7 non startup with USB.setConsole().

    Pages above 1k should work fine - I'm a bit busy but I'll take a look at the not registered issue and see if I can figure out what's up. Otherwise upgrading the firmware on the ESP8266 seems to work really well now.

  • Hi - sorry for the time it's taken to look at this.

    Basically it was an problem with both drivers for both versions of the ESP8266 firmware, and was actually timing-related (so could have happened with smaller responses too). I've now fixed it, so the next time you send code to Espruino you should get the new version, which will work with long responses.

  • Thanks for that Gordon. I must say, this is the best execution of a kickstarter (pico) I've seen. From the communication during production to actually delivering on what was promised and then some. Documentation is ample, interesting and accurate. Development has actually continued post release so it's not just sales and another kickstarter. Then with support, you took my pretty vague "It's still broke" and turned it into a fix in a couple of weeks. After all this, you've got a fan right here.

  • Thanks!

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

[solved] Pico as http server: "Uncaught Error: > not registered"

Posted by Avatar for Mr.Peu @Mr.Peu

Actions