Hi
Doing my first project with a nano 33iot.
The wi fi connection is very flakey and I would like to check in “loop “ as to whether the wi fi signal has been lost and in that case to reconnect it , rather than the one shot in setup .
I have no idea how to do this , can anyone give me a few pointers or code snippet?
You can do it manually in your loop() function with a snippet like this:
void loop() {
if (WiFi.status() != WL_CONNECTED) {
WiFi.begin(SECRET_SSID, SECRET_PASS);
}
...
}
but there's a more robust approach using the Arduino_ConnectionHandler library which does this better:
#include <Arduino_ConnectionHandler.h>
WiFiConnectionHandler conn(SECRET_SSID, SECRET_PASS);
void setup() {
...
}
void loop() {
conn.check();
...
}
1 Like
Thx I’ll give it a go
( have to say this and using the Arduino cloud stuff is very frustrating, getting a connection seems random !!)
Yep , that first bit of code suggested sorted it .
Thx
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.