I’m trying to follow along with the various threads about the Argon and sleep, but don’t seem to have code that does it just yet. This was easier in Sleep 1.0 on the Photon, but I need the Argon as I’m going to replace it with LTE eventually, and want to use the same PCBA I’m designing.
Anyway, why doesn’t this code wake the Argon up correctly? I see D7 turn on, and the RGB just breathes blue like it’s listening, not connecting. D7 never turns off, nor does it ever connect to the cloud. The first boot works fine, it connects to MQTT and sends my temp probe data to my server just fine. The goal is to do this every 15 minutes (it’s 1 minute for testing right now) on a battery and solar setup from Sparkfun. That part works, but I can’t get it to wake up and reconnect.
void goToSleep()
{
client.disconnect();
Particle.disconnect();
waitUntil(Particle.disconnected);
WiFi.off();
System.sleep(sleepconfig);
}
bool wakeup()
{
WiFi.on();
**EDIT**
**wrong**
WiFi.connecting();
**right**
WiFi.connect();
waitUntil(WiFi.ready);
if (!Particle.connected())
Particle.connect();
return connectMQTT();
}
void setup()
{
Log.info("App getting started");
pinMode(D7, OUTPUT);
sleepconfig.mode(SystemSleepMode::STOP).duration(1min);
if (!connectMQTT()) {
goToSleep();
Log.error("Could not connect to the MQTT sources");
}
else {
Log.info("Connected to services");
}
Log.error("Firmware Version: %d", APP_ID);
}
void loop()
{
SleepResult result = System.sleepResult();
if (result.wokenUpByRtc()) {
digitalWrite(D7, HIGH);
wakeup();
digitalWrite(D7, LOW);
}
for (int i = 0; i < MAX_RETRIES; i++) {
if (readEnvironment())
break;
}
goToSleep();
}
EDIT
Testing to see if my autocomplete bug of WiFi.connecting instead of connect is at fault.
Yes, that was it.