Deep Sleep waking after only 3 seconds when should sleep for longer

Hi All,

Am I missing something silly?

I am trying to get the photon to Deep Sleep for 1 hour but it keeps waking after only a few seconds.

The code works fine with a fresh photon (with nothing wired to the board). However, when I connect my moisture sensor to the board the photon wakes after only a few seconds. Sensor is connected to GND VIN and A0 (DFRobot Capacitative Moisture Sensor). Photon powered via USB battery pack. I have also tried tying WKP Pin to ground using 3.7k resistor, but that didn’t help either?

Pulling my hair out here :slight_smile:

Code is:

#define SENSOR_PIN  A0

int led2 = D7;
int SensorLevel = 0;

void setup() {

  pinMode(led2, OUTPUT);
  pinMode(SENSOR_PIN, INPUT);
}

void loop() {
//**********************  Check moisture level and send to IFTTT *************
SensorLevel = analogRead(SENSOR_PIN);
//SensorLevel = 3000; //For testing
//SensorLevel = random(0,5000); //For testing

if (SensorLevel > 2750) {
    Particle.publish("WaterMeNow", String(SensorLevel), PRIVATE);

//LEDs flash for testing only
    digitalWrite(led2, HIGH);
    delay(200);
    digitalWrite(led2, LOW);
    delay(200);
    digitalWrite(led2, HIGH);
    delay(200);
    digitalWrite(led2, LOW);
    delay(200);
    digitalWrite(led2, HIGH);
    delay(200);
    digitalWrite(led2, LOW);
}
    
else {
    Particle.publish("NotThirsty", String(SensorLevel), PRIVATE);
  
//LEDs flash for testing only
    digitalWrite(led2, HIGH);
    delay(200);
    digitalWrite(led2, LOW);
    delay(200);
    digitalWrite(led2, HIGH);
    delay(200);
    digitalWrite(led2, LOW);
    
}

//****************************************************************************


  // Wait 0.5 minutes. For testing purposes to ensure I can reflash photon if necessary
delay(30000);

delay(1000);
System.sleep(SLEEP_MODE_DEEP, 60); //set to 60 seconds for test purposes only. Will change to 60min for real case

}

Cheers, and thanks in advance,
Steve

Could it be that your battery pack does something to the supply when the current draw from the Photon disapears?
A dip in USB supply voltage can also wake the device from deep sleep.

1 Like

@ScruffR Thank you! I tried the computer USB as a power source and it is working fine now.

Much appreciated,
Steve

1 Like