-
• #2
Put a 1uf+ ceramic cap onto those two pads on the shim, it seems to need a cap on the supply to work reliably (ie, the manufacturers of the board were too fucking cheap to add a 3 cent capacitor to make it work reliably).
-
• #3
That's a strange one - do you get the same error each time? The error
Uncaught CWMODE failed: AT+CWMODE=1
is actually because the WiFi dongle has just echoed back the exact same command that got sent to it - which it shouldn't do becausewifi.reset
sends a command that tells it not to do that.It feels unlikely, but could you just get a multimeter and check that A2 and A3 aren't shorted out?
-
• #4
The error is consistent. Some commands work, some don't. I checked A2-A3 for short. Everything is OK.
I ordered the caps DrAzzy recommended. I'll put them in this afternoon and report back.
While at it, I noticed that the firmware/SDK is still at 0.9.2.4. And I also noted I shouldn't update the ESP8266 firmware. However, the newer firmware/SDK is already at V1.1.0 . Will there be a way to update the firmware when it's fix soldered to the Pico? And if, when will this happen? The new SDK solves so many issues since the 0.9.2.4 version. (And also allows for OTA updates)
-
• #5
That's odd - can you try running
wifi.at.debug()
afterrequire("ESP8266WiFi").connect(
... it'll turn on debugging output so we can see what is being sent/received?It's a shame about the outdated firmware - I was told by the suppliers that the auto-update works, but after testing it turns out it just bricks the module in that version of the firmware :(
I am planning on coming up with a way of updating it - I'm in the process of fixing some USB issues, and I think once that is done it should be possible turn the Espruino into a simple USB-TTL pass-through with a few lines of code, which would in turn mean you can use the existing firmware update tools to update the ESP8266.
Even now it would be possible to write an updater in JavaScript that would run in the Web IDE, pushing data. It's just that me (or someone else) will have to do it.
-
• #6
This is the debug output with the debug command immediately following the connect command (so within the delay for setTimeout).
Cap is going in now, check back later.
reset(); =undefined _____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v79 Copyright 2015 G.Williams >echo(0); =undefined Waiting for ESP8266 to flush its serial buffer ] "AT" <--- "AT" ] "AT+C" <--- "+C" ] "AT+CW" <--- "W" ] "AT+CWMO" <--- "MO" ] "AT+CWMODE" <--- "DE" ] "AT+CWMODE=" <--- "=" ] "AT+CWMODE=1\r" <--- "1\r" ] "AT+CWMODE=1\r\r\n" <--- "\r\n" Uncaught CWMODE failed: AT+CWMODE=1 at line 2 col 22 if (err) throw err; ^ in function "b" called from line 2 col 2 e):d.cmd("AT+CWJAP="+JSON.stringify(a)+","+JSON.stringify(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.substr(a+1);"\n"==b[0]&&(b=... ^ in function called from system ] "\x04" <--- "\x04" ] "\x04a" <--- "a" ] "\x04a3©" <--- "3©" ] "\x04a3© ÿ" <--- " ÿ" ] "\x04a3© ÿ!" <--- "!" ] "\x04a3© ÿ!Â" <--- "Â" ] "\x04a3© ÿ!Âý" <--- "ý" ] "\x04a3© ÿ!Âý\x19" <--- "\x19" ] "\x04a3© ÿ!Âý\x19B" <--- "B" ] "\x04a3© ÿ!Âý\x19B#\x12" <--- "#\x12" ] "\x04a3© ÿ!Âý\x19B#\x12#¡" <--- "#¡" ] "\x04a3© ÿ!Âý\x19B#\x12#¡ò" <--- "ò" ] "\x04a3© ÿ!Âý\x19B#\x12#¡òÐ" <--- "Ð" ] "\x04a3© ÿ!Âý\x19B#\x12#¡òÐQ1" <--- "Q1" ] "\x04a3© ÿ!Âý\x19B#\x12#¡òÐQ1\\ÿ" <--- "\\ÿ" ] "\x04a3© ÿ!Âý\x19B#\x12#¡òÐQ1\\ÿ×" <--- "×" ] "\x04a3© ÿ!Âý\x19B#\x12#¡òÐQ1\\ÿ×Lû" <--- "Lû" ] "\x04a3© ÿ!Âý\x19B#\x12#¡òÐQ1\\ÿ×Lû\r" <--- "\r" ] "\n[" <--- "\n[" ] "[Ve" <--- "Ve" ] "[Vend" <--- "nd" ] "[Vendo" <--- "o" ] "[Vendor:" <--- "r:" ] "[Vendor:ww" <--- "ww" ] "[Vendor:www" <--- "w" ] "[Vendor:http://www.a" <--- ".a" ] "[Vendor:http://www.ai-" <--- "i-" ] "[Vendor:http://www.ai-th" <--- "th" ] "[Vendor:http://www.ai-thin" <--- "in" ] "[Vendor:http://www.ai-think" <--- "k" ] "[Vendor:http://www.ai-thinker" <--- "er" ] "[Vendor:http://www.ai-thinker.c" <--- ".c" ] "[Vendor:http://www.ai-thinker.com" <--- "om" ] "[Vendor:http://www.ai-thinker.com V" <--- " V" ] "[Vendor:http://www.ai-thinker.com Ver" <--- "er" ] "[Vendor:http://www.ai-thinker.com Versi" <--- "si" ] "[Vendor:http://www.ai-thinker.com Version" <--- "on" ] "[Vendor:http://www.ai-thinker.com Version:0." <--- ":0." ] "[Vendor:http://www.ai-thinker.com Version:0.9." <--- "9." ] "[Vendor:http://www.ai-thinker.com Version:0.9.2." <--- "2." ] "[Vendor:http://www.ai-thinker.com Version:0.9.2.4]" <--- "4]" ] "[Vendor:http://www.ai-thinker.com Version:0.9.2.4]\r\n" <--- "\r\n" ] "\r\nrea" <--- "\r\nrea" ] "ready" <--- "dy" ] "ready\r\n" <--- "\r\n" >Uncaught CWMODE failed: undefined at line 2 col 22 if (err) throw err; ^ in function "b" called from line 2 col 2 e):d.cmd("AT+CWJAP="+JSON.stringify(a)+","+JSON.stringify(c)... ^ in function "d" called from line 1 col 16 {e=void 0;d&&d()} ^ in function called from system ] "\f" <--- "\f" ] "\fa" <--- "a" ] "\fa1§" <--- "1§" ] "\fa1§ ÿ" <--- " ÿ" ] "\fa1§ ÿ#" <--- "#" ] "\fa1§ ÿ#Ê" <--- "Ê" ] "\fa1§ ÿ#Êü" <--- "ü" ] "\fa1§ ÿ#Êü)" <--- ")" ] "\fa1§ ÿ#Êü)\x02" <--- "\x02" ] "\fa1§ ÿ#Êü)\x02£\x12" <--- "£\x12" ] "\fa1§ ÿ#Êü)\x02£\x12£¡" <--- "£¡" ] "\fa1§ ÿ#Êü)\x02£\x12£¡ò" <--- "ò" ] "\fa1§ ÿ#Êü)\x02£\x12£¡òk" <--- "k" ] "\fa1§ ÿ#Êü)\x02£\x12£¡òk¢k" <--- "¢k" ] "\fa1§ ÿ#Êü)\x02£\x12£¡òk¢ke" <--- "e" ] "\fa1§ ÿ#Êü)\x02£\x12£¡òk¢keü" <--- "ü" ] "\fa1§ ÿ#Êü)\x02£\x12£¡òk¢keüWë" <--- "Wë" ] "\fa1§ ÿ#Êü)\x02£\x12£¡òk¢keüWëû" <--- "û" ] "\fa1§ ÿ#Êü)\x02£\x12£¡òk¢keüWëû\r" <--- "\r" ] "\n[" <--- "\n[" ] "[Ve" <--- "Ve" ] "[Vend" <--- "nd" ] "[Vendo" <--- "o" ] "[Vendor:" <--- "r:" ] "[Vendor:ww" <--- "ww" ] "[Vendor:http://www." <--- "w." ] "[Vendor:http://www.a" <--- "a" ] "[Vendor:http://www.ai-" <--- "i-" ] "[Vendor:http://www.ai-th" <--- "th" ] "[Vendor:http://www.ai-thin" <--- "in" ] "[Vendor:http://www.ai-think" <--- "k" ] "[Vendor:http://www.ai-thinker." <--- "er." ] "[Vendor:http://www.ai-thinker.c" <--- "c" ] "[Vendor:http://www.ai-thinker.com" <--- "om" ] "[Vendor:http://www.ai-thinker.com V" <--- " V" ] "[Vendor:http://www.ai-thinker.com Ver" <--- "er" ] "[Vendor:http://www.ai-thinker.com Versi" <--- "si" ] "[Vendor:http://www.ai-thinker.com Version" <--- "on" ] "[Vendor:http://www.ai-thinker.com Version:0" <--- ":0" ] "[Vendor:http://www.ai-thinker.com Version:0.9.2" <--- ".9.2" ] "[Vendor:http://www.ai-thinker.com Version:0.9.2.4" <--- ".4" ] "[Vendor:http://www.ai-thinker.com Version:0.9.2.4]\r" <--- "]\r" ] "\n\r\n" <--- "\n\r\n" ] "re" <--- "re" ] "read" <--- "ad" ] "ready\r" <--- "y\r" ] "\n" <--- "\n"
-
• #7
The 1 uF capacitor did indeed correct the problem. It now says "Connected".
Oops, cheered a bit too soon. It says "Connected" on the example I gave, but the webui still produces the same error.
-
• #8
Even the example I gave now goes into error again. I'll solder another shim with another module and see what that gives. Maybe the module is just malfunctioning.
-
• #9
Ok, something is odd here, are you sure it's the code you posted earlier:
var delay=5000; 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("Waiting for ESP8266 to flush its serial buffer"); setTimeout(function(){ //your code to be executed after 1 seconds wifi.connect("solarsystem","tmpjoimc", function(err) { if (err) throw err; console.log("Connected"); // Now you can do something, like an HTTP request }); //wifi.connect }, delay); //setTimeOut }); //wifi.reset }); //require
Because Espruino seems to be trying to reset and connect twice in a row from the log you posted...
-
• #10
"but the webui still produces the same error"
Which error?
-
• #11
Gordon,
yes, same code.DrAzzy,
these errors, which in effect are the same errors as above, but without the debug output.
The getAPs.js example works, anything that tries to set up a connection does not.Uncaught CWMODE failed: AT+CWMODE=1 at line 2 col 42 if (err) throw err; ^ in function "b" called from line 2 col 2 e):d.cmd("AT+CWJAP="+JSON.stringify(a)+","+JSON.stringify(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.substr(a+1);"\n"==b[0]&&(b=... ^ in function called from system Uncaught CWMODE failed: undefined at line 2 col 42 if (err) throw err; ^ in function "b" called from line 2 col 2 e):d.cmd("AT+CWJAP="+JSON.stringify(a)+","+JSON.stringify(c)... ^ in function "d" called from line 1 col 16 {e=void 0;d&&d()} ^ in function called from system
-
• #12
There's definitely something wrong here - It looks like the code is somehow being executed twice - I don't see how you can be getting the same
Uncaught CWMODE failed
twice in a row unless somehowwifi.connect
is getting called twice.So you're sure that you're putting that exact code into the right hand side of the Web IDE (nothing else), clicking the send button once, and getting that exact output?
-
• #13
Indeed.
I reduced a bit the code, did a full restart of everything and uploaded the code at the bottom of this post under the dashed line. The output is just below that.You can see that it is actually the serial garbage (which is a known problem in 0.9.2.4), that is the cause of the (initial) error. That's why I originally added the setTimeout. Anyway, I took that setTimeout away for now.
After uploading and executing that code (which failed), I entered the following in the command window
wifi.connect("solarsystem","tmpjoimc", print);
That resulted in:
=undefined CWMODE failed: AT+CWMODE=1
To display the full error, I entered this:
wifi.connect("solarsystem","tmpjoimc", function(err) {if (err) throw err;});
which then resulted in:
=undefined >Uncaught CWMODE failed: AT+CWMODE=1 at line 1 col 17 {if (err) throw err;} ^ in function "b" called from line 2 col 2 e):d.cmd("AT+CWJAP="+JSON.stringify(a)+","+JSON.stringify(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.substr(a+1);"\n"==b[0]&&(b=... ^ in function called from system Uncaught CWMODE failed: undefined at line 1 col 17 {if (err) throw err;} ^ in function "b" called from line 2 col 2 e):d.cmd("AT+CWJAP="+JSON.stringify(a)+","+JSON.stringify(c)... ^ in function "d" called from line 1 col 16 {e=void 0;d&&d()} ^ in function called from system
which in turn is again the same error as in all previous tests.
I'll put together another pico/esp8266 to see what that gives.
====================================================
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; //your code to be executed after 1 seconds wifi.connect("solarsystem","tmpjoimc", print); }); //wifi.reset }); //require
>reset(); =undefined _____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v79 Copyright 2015 G.Williams >echo(0); =undefined WiFi connect failed: áF¨ÿ#Êýi££¡òëâkeü×Lû >
-
• #14
Ok, thanks for checking all that!
So the ESP8266 module is one of the ones that came with the KickStarter, not a different one?
From the garbage, and third from last post, it looks like the ESP8266 could be resetting itself after
CWMODE=1
is called. It could be a power supply issue, but generally with the shim they seem to work ok.Unless it's something crazy like a dodgy USB port/cable that doesn't supply enough power?
If you could put another together Pico that'd be great, hopefully it'll work. If it turns out to be the ESP8266 I'll send you another (although granted unsoldering the old one will be a pain.
-
• #15
I also verified that. yes, it's one that came with the Pico. The other ones have been updated. This one is still at the original firmware level..
The USB is a powered USB 3.0 hub. But I also inserted the pico in the PC directly. It doesn't matter. (I also added a 1uF cap as suggested by DrAzzy.)
-
• #16
Before you give up, try a bigger cap. Another guy said 1 worked so I used that number, but the working esp's I have all have at least a few uf on them. I don't claim that this is definitely the problem, but it's easy to try, and if it is, it's something people are going to keep dealing with
-
• #17
Just made another one. Exactly the same problem. Get APs works, but connecting fails with the CWmode error.
I'll add another cap in parallel. (I need a better magnifying glass, these little buggers are SMALL, for me anyway)
-
• #18
Added another 1uF. Didn't change anything. Same error. I can try to add another uF, but then that's it. With these small things, it's nearly impossible to do this right.
-
• #19
Added another 1 uF. That makes 3uF. Still same error. Get APs works, connect doesn't.
-
• #20
Hum. Wonder what's wrong...
-
• #21
I'm kinda lost here. Let me give some examples with output:
Serial2.setup(9600, { rx: A3, tx : A2 }); var wifi = require("ESP8266WiFi").connect(Serial2, function(err) {if (err) throw err;wifi.getVersion(print);});
produces
echo(0); =undefined null 0018000902-AI03
Now,
Serial2.setup(9600, { rx: A3, tx : A2 }); var wifi = require("ESP8266WiFi").connect(Serial2, function(err) {if (err) throw err;wifi.getAPs(print);});
produces
echo(0); =undefined null [ { "ssid": "Andromeda", "enc": "wpa_wpa2_psk", "signal": -67, "mac": "dc:53:7c:14:a0:21" }, { "ssid": "bbox2-8108", "enc": "wpa_wpa2_psk", "signal": -94, "mac": "5c:33:8e:64:e2:2c" }, { "ssid": "TELENETHOMESPOT", "enc": "open", "signal": -66, "mac": "02:53:7c:14:a0:22" }, { "ssid": "TelenetWiFree", "enc": "open", "signal": -66, "mac": "06:53:7c:14:a0:24" }, { "ssid": "solarsystem", "enc": "wpa_wpa2_psk", "signal": -20, "mac": "00:18:84:88:ec:00" }, { "ssid": "DIRECT-nBPrinter ", "enc": "wpa2_psk", "signal": -44, "mac": "02:15:99:d7:9b:49" }, { "ssid": "FON_galaxy", "enc": "open", "signal": -26, "mac": "00:18:84:88:ec:01" } ]
OK, so that works. Now, inserting connect
Serial2.setup(9600, { rx: A3, tx : A2 }); var wifi = require("ESP8266WiFi").connect(Serial2, function(err) {if (err) throw err;wifi.connect("solarsystem","tmpjoimc",print);});
That gives me BS (due to the serial garbage on initialisation)
as follows:echo(0); =undefined WiFi connect failed: "áÙÓHòé!Í!ÿåÑ+ùÂë
So, I re-introduce the SetTimeout
Serial2.setup(9600, { rx: A3, tx : A2 }); var wifi = require("ESP8266WiFi").connect(Serial2, function(err) {if (err) throw err;}); setTimeout(function(){wifi.connect("solarsystem","tmpjoimc", function(err) {if (err) throw err;});}, 10000);
and then I get
echo(0); =undefined >Uncaught CWMODE failed: AT+CWMODE=1 at line 1 col 17 {if (err) throw err;} ^ in function "b" called from line 2 col 2 e):d.cmd("AT+CWJAP="+JSON.stringify(a)+","+JSON.stringify(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.substr(a+1);"\n"==b[0]&&(b=... ^ in function called from system Uncaught CWMODE failed: undefined at line 1 col 17 {if (err) throw err;} ^ in function "b" called from line 2 col 2 e):d.cmd("AT+CWJAP="+JSON.stringify(a)+","+JSON.stringify(c)... ^ in function "d" called from line 1 col 16 {e=void 0;d&&d()} ^ in function called from system
In effect, as I said, connecting (or trying to in any way) produces the error, both on this and on the other module. With or without caps on Vcc-GND.
-
• #22
Thanks - I'm pretty sure:
WiFi connect failed: "áÙÓHòé!Í!ÿåÑ+ùÂë
Is actually because the board has reset while trying to connect, so I'd be pretty sure this was a power issue (especially as it's affecting both boards). I've never seen it so bad though - maybe it's having to use more power to transmit to your WiFi network than it is to the network I've tried.
Come to think of it, have you tried connecting to a different network? Maybe put your phone into mobile hotspot mode and try that?
Do you have an oscilloscope that you could look at the 3.3v line with so you can see if it's fluctuating.
1 or 2 uF might not cut it. Any chance you have a 47uF or 100uF capacitor kicking around, just to make sure? You can solder through-hole parts into the 2 (of 3) holes nearest where the capacitor goes (one nearest the ESP8266 is GND).
-
• #23
I have had the same issue with all other esp8266 boards (espruino related or not). It's in the firmware. The newer firmware clears the serial buffer before releasing it ready. (I think starting from the V0.9.5 versions. That's actually why I was enquiring about updating the firmware)
-
• #24
Can someone instruct me on using the wifi.at command?
I tried a wifi.at("AT+GMR"), but that produces an error.
What function should I call using this?
Uncaught Error: Expecting a function to call, got Object
at line 1 col 6
wifi.at("AT+GMR"); -
• #25
If it is a firmware problem, it seems to work for other people - me included - so I'm not sure why it's different in your case.
Did you try a different wifi ap?
Try:
wifi.at.cmd("AT+GMR\r\n",1000,print)
I hope someone here can help me out on this.
I'm a total newbie on Javascript, but an experienced programmer in several other languages.
I got the Espruino Pico with the free ESP8266 modules. I succesfully soldered the shim and the module. The module responds on certain commands, but produces an error on others (actually, the software does).
Originally, I thought it was the spurious characters that flow out of the ESP8266 when reset, so I put in a delay (through setTimeout()), but apparently that is not the problem.
The firmware version of the ESP8266 corresponds to the requirements.
I put the code and output of two small programs below. One gets the accesspoints (and that one works), the other one tries to connect, and doesn't work.
Can someone help me out here?
================================
This code works, producing the list of available APs
But the code below produces an error