setup: i have a working project i added IOT capabillety by switching nano to nano IOT ( and some parts 3v3 etc.
the project works fine until i get out of reach of the wifi . the project includes a Display so i can use it without IOT but it completly gets stuck if i "simulate" a not working connection by changing SSID or PASS
is there a exemple on how to use
ArduinoCloud.begin <- in void setup()
wiithout blocking void loop() completly? what does ArduinoCloud.begin return?
Probably, you have to have a time out in setup so if, after a certain time elapses when no connection has been established, a flag, say called offline, is set and the connection attempt is abandoned. In the loop(), you will somehow use this flag to prevent any periodic attempts to re-establish a connection.
and would probably be a good place to set global variables which you can test in the loop() to see if it is safe to start attempting to make a connection to the "cloud".
it does not reach the cloud.update function if the network does not get connected it never goes into main loop.
and would probably be a good place to set global variables which you can test in the loop() to see if it is safe to start attempting to make a connection to the "cloud".
yes exactly i dont need network but i need the code to run always
but i can not use Iot connection handler and stuff, if i dont set them up in void Setup()
with ArduinoCloud.begin();
Or so i think, does someone know a good source for dokumentation? the arduinoIOT stuff seem to be not that much documented (not that good as i am used to for Arduino)
You can check the status of the connection with conman.check() as you have done so in the loop, but testing the return code. Maybe you can do it early in setup() and, if it shows a failure, don't use any of the commands which depend on a connection. It returns a value indicating the status of the connection:
if ( conMan.check() == NetworkConnectionState::INIT ) { Serial.println("INIT");}
if ( conMan.check() == NetworkConnectionState::CONNECTING ) { Serial.println("CONNECTING");}
if ( conMan.check() == NetworkConnectionState::CONNECTED ) { Serial.println("CONNECTED");}
also some serial prints at the start and end of loop it gets clearer, the loop is actualy running!
just for every conMan.check() the loop gets delayed for a few seconds and that every loop so it behaves stuck (and all my deboundcing serial and display stuff is not working but it actually loops
-- void setup()
##setup internet and stuff
-- void loop()
##if conected reset timer
#else timer interrupt to 10min or so than recheck
#run normal code every loop
-- void setup()
##setup internet and stuff
-- void loop()
##if conected reset timer
#else timer interrupt to 10min or so than recheck
#run normal code every loop
Something like that could work to limit the blocking activity if the loop does get entered but conman.check() blocks too long when it runs and also runs too often.
If you discover early on (by some method) that there is no connection, you could also completely disable the call to conman.check() in the loop. That would mean, however, that if there was no connection at the start, it would not attempt to automatically restore the connection within that session even if one became available.
There may also be methods for setting timeouts so, for example, conman.check() did not block for so long.
right. for the moment i have to dig myself throu the timer interrupt theme...
and i could also live with the interruption every 10minutes, ( so only checking if it is connected ans storing that in a vairable. ) also: i figured if it does connect conman.check runs in less then 5ms it only delays in case of no connection