I am using the SEMI-AUTOMATIC mode to delay connecting to the cellular network unless something has changed. In so doing, I managed to prevent my Electron from entering the listening mode so I can upload new software. When I reset it and hold down the listening mode button, it flashes white and then goes to sleep. It won’t go into listening mode unless it is triggered to start the cellular connection which makes if difficult to program.
I can get it into DFU mode but not sure how that would help me. How to I get it into listening mode?
Here is some of my code.
void setup() {
Serial.begin(9600);
Serial.printf("%s (%s)\n", PROG_NAME, REVISION);
Time.zone(-7);
// hardware setup
pinMode(G_LED_PIN, OUTPUT); digitalWrite(G_LED_PIN, LOW);
pinMode(R_LED_PIN, OUTPUT); digitalWrite(R_LED_PIN, LOW);
flashLED(RED, true);
pinMode(DS18_DATA, OUTPUT); digitalWrite(DS18_DATA, LOW);
// read historic data
EEPROM.get(lastPubTimeAddr, lastPubTime);
EEPROM.get(lastTempAddr, lastTemp);
EEPROM.get(setTempAddr, setTemp);
// read temperature and publish results
if (readTemp()) {
Serial.printf("Temp: %0.2f\n", temp);
// timestamp
ts = Time.now();
// check if this is a new dataset or already checking data every 4 minutes
if (ts >= (lastPubTime + NEW_DATASET_TIME)) {
initState = 1;
setTemp = MIN_REPORT_TEMP;
}
// check if the temperature is above the minimum and above the current report level
if ((temp >= MIN_REPORT_TEMP) && (temp >= setTemp)) {
risingTemp = 1;
reportNow = true;
} else if ((temp >= MIN_REPORT_TEMP) && (temp < setTemp - SET_TEMP_STEP)) {
risingTemp = 0;
reportNow = true;
}
// set a new set temperature level
if (reportNow) {
setTemp = ((int)(temp/SET_TEMP_STEP) + 1) * SET_TEMP_STEP;
Serial.printf("New setTemp: %d\n", setTemp);
// start cellular and cloud connection
Particle.connect();
if (!(waitFor(Particle.connected, CONNECT_TIME*60))) {
// no connection available
Serial.println("No cellular connection available");
goToSleep();
}
// successful cellular connection
flashLED(RED, false);
ledOn(GREEN);
//Particle.keepAlive(PARTICLE_KEEPALIVE);
Blynk.begin(blynkAuth, BLYNK_IP);
// report data
formatResults();
particlePublishData();
blynkPublishData();
}
saveData();
}
goToSleep();
}
void loop() {
}