I’ve got some code that’s attempting to check a moisture sensor, post the resuts to ThingSpeak, and go into SLEEP_MODE_DEEP for 60 seconds. That works great initially, but after several hours, the Photon just stops responding/posting.
Here’s my code - pretty simple.
#include "ThingSpeak/ThingSpeak.h"
TCPClient client;
int sensorPin = A0; // set the input pin for the moisture sensor
void setup() {
ThingSpeak.begin(client);
}
void loop() {
int sensorValue = 0;
Serial.println("Reading sensor value...");
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
Serial.println("Attempting to publish a reading...");
ThingSpeak.setField(1,sensorValue);
ThingSpeak.writeFields(MYCHANNEL, "APIKEY");
//delay(30000);
//go into deep sleep for 60 seconds
System.sleep(SLEEP_MODE_DEEP, 60);
}
I’ve searched the forum, but I couldn’t find anything that wasn’t pertaining to an old firmware. I’m building with firmware 0.5.2.
Can anyone point me in the right direction as far as troubleshooting? Unfortunately, the device is remote, so troubleshooting is pretty brutal (raises hand for deferred OTA updates, please! ). Any help would be very much appreciated.