-
• #2
I also took some time to try and debug using the following code I saw on another thread:
This is the code you said to try:
var WIFI_BOOT = A13; var WIFI_CHPD = A14; digitalWrite(WIFI_CHPD, 0); // turn off wifi var pins = { rx: A3, tx : A2 }; Serial2.on('data', function(d) { console.log("wifi:",JSON.stringify(d)); }); Serial2.setup(115200, { rx: A3, tx : A2 }); setTimeout(function() { digitalWrite(WIFI_BOOT, 1); // out of boot mode digitalWrite(WIFI_CHPD, 1); // turn on wifi }, 500);
And this is the output
>E.getAnalogVRef() =3.30846754005 > ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v19 (c) 2021 G.Williams > wifi: "r" wifi: "l\u0000l\u009C\u009E\u008E" wifi: "\u0002\u008Cb\u0003\u00E3n\f" wifi: "\f\f\u008C\u001C\u0080l" wifi: "\u00EC\u001Cp\u008C|\u008E\u0082" wifi: "\u009E\u0000\u00ECp\u0002\u0093r\u0093" wifi: "bl\fc\u008C" wifi: "p~\u00F2n\u009F\u0000l" wifi: "on\u009C\u0012b\fb" wifi: "\u001Cp\u008Clb\u000El" wifi: "slp\u00F2o" wifi: "\u00E0\u0082\u009C\u0000\f\f\u0082" wifi: "\u008E\u0080l\f\f\f\f" wifi: "\f\fb\fn" wifi: "\u00E3\u00E3nl\u00EC\u001C" wifi: "\u00E2\u008C\u008Ep\f\u008C|~" wifi: "\u00F2o\u00EE\u0002l\u008C\u008E" wifi: "\u0000l`\u0002" wifi: "\u0090" wifi: "\u0013\u0012on\f" wifi: "\u008Fsl\u000F\u0002o" wifi: "s\u008E\u0093\u009F\u00EF\u0003\f" wifi: "\f\u0002ll`\u0002" wifi: "p\u00F2o\u00E0\u0082\u009C\u0000\f" wifi: "\fr\u008C\u009C\u001C\u0093" wifi: "\u009C\u00E0\f\f\f\fb" wifi: "\fn\u00E3\u00E3n\u00EC" wifi: "\u008F\u009F\u008C\u008Fp\f\u008C|" wifi: "~\u00F3n\u00EF\u0003\f\u008E\u0000" wifi: "l`\u0002" wifi: "\u0090\u0012\u0013n" wifi: "o\f\u008Erl" wifi: "\u000E\u0002nr\u008E\u0092\u009E" wifi: "r\u0002\f\f\u0093\u009C\u00E0" wifi: "l`\u0003p\u00F2n\u00E0\u0083" wifi: "\u0002\f\fs\u008C" wifi: "\u009C\u001C\u0092\u009C\u00E0\u00EC\u001C\u0080" wifi: "\f\fc\fo\u00E2\u00E2o" wifi: "l\u008E\u0090\f\f" wifi: "b\u008C|\u007F\u00F2o\u00EE" wifi: "\u0002\f\u008F\u0000l`\u0003" wifi: "\u0090\u0012\u0013n" wifi: "o\fl`\u0002" wifi: "\u000E\u0002nr\u008F\u0092\u009Es" wifi: "\u0002\f\fs\u0002l" wifi: "`\u0002\u000Er\u0093\u009F" wifi: "s\u0002\f\fr\u0002" wifi: "l`\u0002rl\u008C" wifi: "\u008Co\u009C\u0000\u008Cp\u007F" wifi: "\u00F2n\u009E\u0000\u008C\u009E\u0012c" wifi: "r\u0013non" wifi: "\u008C\u001E\u0000l\u008Cb\u008E" wifi: "`\u008Cp\u0082lc\u000E" wifi: "l\u0000\f\u00ECl\u0080\u0093\u008C" wifi: "\u0003\u00ECl\u0080\u0092\u009C\u0012\u0082" wifi: "\u009C\u0000\f\f\f\f\f" wifi: "\u008C\u001E\u0000\f\u008E\u0080l" wifi: "ll\u007Frl\u0000\f" wifi: "\u00ECl\u0080\u0093\u008C\u0003l" wifi: "ln\u009C\u0012\u0002\f" wifi: "\f\f\f\f\f\u008C" wifi: "\u001E\u0000\f\u0090b\u00F2l" wifi: "\u000El\u0000\f\u00ECl\u0080\u0093" wifi: "\u008C\u0003\u008C\u0090p\u0012s" wifi: "\u0002n\u00EClbb" wifi: "\u0092\u009C\u0000\u008C\u008C\u0000ll" wifi: "\u00E0\u0002c\f\fll" wifi: "pc\u0082\u009E`l\u008E" wifi: "\u0082\u008C\u00ECb\frbr" wifi: "\u0082\u008C\u001Cnc\u0012c" wifi: "\u000Ell\u0092\u009Er\u0002" wifi: "\u0002\f\u009E~\u0003\u008C|" wifi: "\u0092\u00E2ol\u009E\u008E\u0092" wifi: "\u009C\u008C\u0012\f\f\u0002" wifi: "l\f\f\fl`" wifi: "\u0002rl" wifi: "r" wifi: "l\u008F\u0013\u0090o" wifi: "\u0002\u00CC\u00FF" wifi: "\r" wifi: "\nAi-Thi" wifi: "nker Tec" wifi: "hnology" wifi: " Co.,Lt" wifi: "d.\r\n" wifi: "\r" wifi: "\nready\r" wifi: "\n" wifi: "W" wifi: "IFI CON" wifi: "NECTED\r" wifi: "\n" wifi: "W" wifi: "IFI GOT" wifi: " IP\r\n"
-
• #3
I'm surprised that you do low-level communication to the ESP-##/ EX8266 module sitting on the Espruino-Wifi... Your code reminds me of using Pico with an ESP-01. As far as I recall, this is all hidden behind Espruino-Wifi firmware... No need to deal w/ GPIO pins and the like.
Take a look at this conversation EspruinoWiFi module builtin? and, for example, at this code example: EspruinoWiFi module builtin? - where Espruino-Wifi connects to the local Wifi and exposes a WebServer / interactive WebPage to control the train; and here is another example... not showing me in the best light, but it shows how to connect Espruino-Wifi and check the ip address your access point w/ DHCP give the connection Espruino/Wifi - getIP() returns undefined but callback receives null,ip.
Updating the onboard ESP-## is though a different story... but there is documentation about it... https://www.espruino.com/WiFi
(@Gordon, ooops, read
The Espruino WiFi board is now discontinued. We will be releasing a new WiFi + Bluetooth board in 2022
... I guess COVID-19 and related supply chain challenges ask for a special interpretation of the number 2022... :\ ) -
• #4
Thank you for the reply, the low-level code above was taken from another post that Gordon commented on, he wanted to see what the wifi module reported back, so just to save time I decided to do the same.
The code I am actually running is as follows:
const WIFI_NAME = "<REDACTED>"; const WIFI_OPTIONS = { password : "<REDACTED>" }; const wifi = require("Wifi"); let mqtt; const server = "172.24.0.2"; // the ip of your MQTT broker const options = { // ALL OPTIONAL - the defaults are below client_id: "random", // the client ID sent to MQTT - it's a good idea to define your own static one based on `getSerial()` keep_alive: 60, // keep alive time in seconds port: 1883, // port number clean_session: true, username: "username", // default is undefined password: "password", // default is undefined protocol_name: "MQTT", // or MQIsdp, etc.. protocol_level: 4, // protocol level }; let id = null; let temp = 0; let running = false; let speed = 50; let rgb = {r: 128, g: 128, b: 128}; const leds = 12; let isActive = false; const onInit = () => { lightsOff(); lightsOn(rgb, 300); wifi.on('disconnected', connect); connect(); }; const connect = () => { console.log("wifi connecting..."); wifi.connect(WIFI_NAME, WIFI_OPTIONS, (err) => { if (err) { console.log("wifi error", err); return; } console.log("wifi connected"); connectMQTT(); }); }; const connectMQTT = () => { console.log("connecting to mqtt"); mqtt = require("MQTT").create(server, options); mqtt.on("connected", () => { console.log("mqtt connected"); lightsOff(); lightsOn({r: 0, g: 128, b: 0}, speed); mqtt.subscribe("espruino/rgb"); mqtt.subscribe("espruino/speed"); // mqtt.subscribe("outdoor-motion-sensor"); }); mqtt.on("publish", (pub) => { switch (pub.topic) { case "espruino/rgb": rgb = JSON.parse(pub.message); lightsOff(); lightsOn(rgb, speed); break; case "espruino/speed": speed = pub.message; lightsOff(); lightsOn(rgb, speed); break; case "outdoor-motion-sensor": const activity = JSON.parse(pub.message).activity; if(isActive === activity){ return; }else{ isActive = activity; } const color = isActive ? {r: 255, g: 0, b: 0} : {r: 0, g: 255, b: 0}; speed = isActive ? 200 : 1000; lightsOff(); lightsOn(color, speed); break; } }); mqtt.on("error", (err) => console.log("error", err)); mqtt.connect(); }; const lightsOn = (color, speed) => { if (running) return; let rgb = new Uint8ClampedArray(leds * 3); let pos = 0; const getPattern = () => { pos = (pos + 1) % leds; rgb[pos * 3 + 0] = color.g; rgb[pos * 3 + 1] = color.r; rgb[pos * 3 + 2] = color.b; for (var i = 0; i < leds * 3; i++) rgb[i] *= 8 / leds; return rgb; }; id = setInterval(() => { A15.set(); require("neopixel").write(B15, getPattern()); A15.reset(); }, speed); running = true; }; const lightsOff = () => { clearInterval(id); let rgb = new Uint8ClampedArray(leds * 3); const getReset = () => { for (let i = 0; i < rgb.length; ) { rgb[i++] = 0; rgb[i++] = 0; rgb[i++] = 0; } return rgb; }; A15.set(); require("neopixel").write(B15, getReset()); A15.reset(); running = false; }; const getRndColor = () => { let color = { r: Math.round(Math.random() * 255 + 25), g: Math.round(Math.random() * 255 + 25), b: Math.round(Math.random() * 255 + 25), }; return color; };
The error message is returned here:
if (err) { console.log("wifi error", err); return; }
```
-
• #5
Odd about the firmware update error, but the 0.40 ESP8266 firmware should still be basically fine.
Thanks for running the debug code above - you can see
WIFI GOT IP
in the log, which shows that the module itself is working and has connected to the network, so I wonder what's going on...Please could you try upgrading to a cutting edge build? I seem to recall that 2v19 had an issue with the minified ESP8266 code which might be causing problems - I was going to push a 2v20 release but didn't want to do it before Christmas in case it broke something.
-
• #6
dug up my Espruino-Wifi... 2v01... a while updated it to 2v19 and and checked ESP8266 firmware:
var t = ` Ai-Thinker Technology Co.,Ltd. ready AT+GMR AT version:0.40.0.0(Aug 8 2015 14:45:58) SDK version:1.3.0 Ai-Thinker Technology Co.,Ltd. Build:1.3.0.2 Sep 11 2015 11:48:04 OK `;
Using just the Wifi connection part from your code w/ time added in loggin :
// EspruinoWifiCheck.js // 2024-01-08_ao // after update to 2v19 from 2v00, w/ ESP8266 v4.0 const WIFI_NAME = "<REDACTED>"; const WIFI_OPTIONS = { password : "<REDACTED>" }; const wifi = require("Wifi"); const t = (n) => { var t = getTime(); t=""+t; return t.substr(t.indexOf(".")-(n||2)); }; var wc = "wifi connect"; const connect = () => { console.log(t(),wc+"ing..."); wifi.connect(WIFI_NAME, WIFI_OPTIONS, (err) => { if (err) { console.log(t(),wc+" error", err); return; } console.log(t(),wc+"ed"); wc = "wifi re-connect"; }); }; const onInit = () => { wifi.on('disconnected', connect); connect(); }; setTimeout(onInit,999);
And to my dismay, I get nothing different than:
> ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v19 (c) 2021 G.Williams > 83.02755451202 wifi connecting... 93.05551528930 wifi connect error No 'ready' after AT+RST >
You obvious dug further... My Wifi had still this Retro Horse Derby Game Board with Neopixels showing Reaction Game Status code on it, which was not (yet) using Wifi (the intent was to store game results via Wifi in some (google) doc / db in the cloud), but I know Wifi at worked before (obviously like your's too...).
I'll restore older Espruino version and try again...
-
• #7
'good' news: 2v01 connects...
> ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v01 (c) 2018 G.Williams > 79.02789402008 wifi connecting... 91.23308467864 wifi connected >
Now is the time to find where it went of the rails... ;-)
-
• #8
used the binary approach and figured that 2.15, 2.17, 2.18 work. So I doubted my earlier confirmation that 2v19 failed. But: it kept failing... So now back to 2v18... (and some chat w/ @Gordon).
I noticed that connection could be made within the range of 8..12 seconds, but failing was always within 10..11 seconds:
2v19 (c) 2021 G.Williams > 42.02763271331 wifi connecting... 52.05555248260 wifi connect error No 'ready' after AT+RST >
2v19 (c) 2021 G.Williams > 69.02761077880 wifi connecting... 79.05558586120 wifi connect error No 'ready' after AT+RST >
> ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v18 (c) 2021 G.Williams > 00.02708053588 wifi connecting... 08.74545001983 wifi connected >
2v18 (c) 2021 G.Williams > 15.02713966369 wifi connecting... 23.73204612731 wifi connected >
2v18 (c) 2021 G.Williams > 17.02713966369 wifi connecting... 29.74073886871 wifi connected >
Disconnecting from power and reconnecting power, Espruino-Wifi, upload-run test code usually made it 12 seconds... but also got 8 seconds versions...
-
• #9
Did you try a cutting edge build? I'm pretty convinced it is fixed in those
-
• #10
The cutting edge build
espruino_2v19.123_wifi.bin
from https://www.espruino.com/binaries/travis/master/espruino_2v19.123_wifi.bin does it [EDITED: BUT WATCH: this is fluid... go to the Espruino Download page,Find a Binary
section,select the board
, and pick theCutting Edge build
link - at the bottom of the build(/release) list].> ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v19.123 (c) 2023 G.Williams > 88.02419090270 wifi connecting... 00.74121856689 wifi connected >
...and it will be in 2v20 when that is released.
-
• #11
Hey that's great to hear you were able to reproduce this issue and also have a fix. How would I flash the device with this firmware, hopefully it can be done with the web ide?
@allObjects The link above to the espruino_2v19.123_wifi binary is 404 for me :(
I checked in github but can't see it in any of your repos.
-
• #12
Try
https://www.espruino.com/binaries/travis/d594469bcd5cdf1c28de321325565f8a8875184a/espruino_2v19.123_wifi.bin
The last link was the latest firmware and I'd since made another change, so the number had changed from 122 to 123. This one should stay the same.
You can just paste it into the IDE and you'll be fine
-
• #13
Sorry for the confusion... updated the original post and repeat it here again for who ever will come across same need...
Getting cutting edge build: Go to the Espruino Download page,
Find a Binary
section,select the board
, and pick theCutting Edge build
link - at the bottom of the build(/release) list.Btw, list of ALL cutting edge Espruino builds is at espruino.com/binaries/travis/master/
2 Attachments
-
• #14
Hi @allObjects and @Gordon thank you for your time with this, I got the notification for updating to 2v20 in the Espruino web ide this morning, and now the Wifi module is connecting as expected again!
I am trying to use my Esprunio Wifi, I just updated it to v2.19 firmware successfully and I am trying to connect to my wifi router, something I've done over 100 times in the past. Unfortunately i'm getting an error.
I saw that its possible now to update the Wifi firmware also, it does query the module and gets the current version but trying to update the firmware fails for some reason.
Not having much luck coming back to play with my devices both my Pico and the Esp Wifi giving me problems, hope someone can help me.
3 Attachments