Maybe the difference is whether you’re using the Web IDE or local compiling, but I’ve been using the following successfully compiling locally on “latest”:
#include "application.h"
//SYSTEM_MODE(MANUAL);//!!!!!!!!!!!!!!!!!!!!!!!!!!!
SYSTEM_MODE(SEMI_AUTOMATIC);
char publishString[63];
const uint32_t SOFTDELAY500ms = 500UL;
const uint32_t SOFTDELAY1s = 1000UL;
const uint32_t SOFTDELAY2s = 2000UL;
const uint32_t SOFTDELAY3s = 3000UL;
uint32_t lastTime;
bool receivedflag;
void myHandler(const char *event, const char *data){
receivedflag = TRUE;
}//myhandler
void setup() {
// WiFi.antennaSelect(EXTERNAL);
pinMode(D7,OUTPUT);
Time.zone(-7);
Spark.subscribe("MotionTimeReceived", myHandler, MY_DEVICES);
lastTime = millis();
while(millis() - lastTime < SOFTDELAY1s) { // not sure why this is needed
Spark.process();
}
receivedflag = FALSE;
}//setup
void loop(){
delay(1000);
WiFi.off(); //isn't sleep on photon supposed to do this automatically?
System.sleep(D3, RISING); //Sleep indefinitely till D3 HIGH
// System.sleep(SLEEP_MODE_DEEP,0);
Spark.connect();
lastTime = millis();
while(!Spark.connected()) { // not sure why this is needed
Spark.process();
delay(50);
}//while(millis() - lastTime < SOFTDELAY1s)
delay(500);
sprintf(publishString,"%04d/%02d/%02d %02d:%02d:%02d",Time.year(),Time.month(),
Time.day(),Time.hour(),Time.minute(),Time.second());
if (Spark.connected()) {
delay(100);//may? cause redflash?
Spark.publish("MotionTime",publishString,60,PRIVATE);
lastTime = millis();
while((!receivedflag) && (millis() - lastTime < SOFTDELAY3s)) { // allows processing of receipt msg?
Spark.process();
if (receivedflag == TRUE) { //confirm receipt msg
delay(500);
digitalWrite(D7, HIGH);
delay(500);
Spark.process();
digitalWrite(D7, LOW);
delay(500);
}//if (receivedflag == TRUE)
}//while((!receivedflag) && (millis() - lastTime < SOFTDELAY3s))
receivedflag = FALSE;
}//if (Spark.connected())
}//loop
I’m using a 4k7 pulldown resistor.
Hope this helps