System.sleep with SLEEP_MODE_DEEP sleeps a max of 60s [RESOLVED]

I have a Photon build with firmware 0.4.7. I have a very strange behaviour where the device sleeps a maximum of 60s using the SLEEP_MODE_DEEP, despite setting a higher value, e.g. System.sleep(SLEEP_MODE_DEEP,230).
Value less than 60 works OK, i.e. a value of 20 makes the device deep sleep for 20 seconds.

I’m building a device where I’d like to

  1. Measure snow depth using ultrasonic sensor and a reference value stored in EEPROM (for persistence during deep sleep)
  2. Publish the current value
  3. Sleep for at least an hour (though example below is 90s)
  4. Repeat

It all seems to work fine except for step 3
Here’s my setup and loop:

const int pingPin = 1;
const int speakerPin = D0;

char resultstr[64];

//EEPROM vars and addresses
    int ref_to_ground = 0;
    int addr_ref_to_ground = 1;  

STARTUP(WiFi.selectAntenna(ANT_EXTERNAL)); // selects the u.FL antenna

void setup() {
    int i;

//Beep a short beep
//Wait 2 seconds for hand to be put close to sensors to change mode
//Check if distance is < 10cm for 5s (500ms x10 checks)
    for(i=0;i<10;i++) {
        if (measurement() > 10) {
//Mode read not found

    if (i == 10) {
//Set new calibration value
        ref_to_ground = measurement();                      //Measure and then store
        EEPROM.put(addr_ref_to_ground, ref_to_ground);      //Store new value 
        beep(900,1,400);                                    //200ms,2 times,50ms pause
//Read stored reference value

void loop() {
    int cm = 0;
    cm = ref_to_ground - measurement();                     //Perform the measurement
    System.sleep(SLEEP_MODE_DEEP, 90);

Anyone with any ideas of why the sleep is limited to 60s and not the 90s in the example above?

I don’t know what your problem is , but I’m on 0.4.7 with no problem with a deepsleep or just a wifi off sleep.
I need it awake every 5 minutes so I know that deepsleep 290 works.

With such a problem it’s advisable to first narrow down the actual cause than jumping to conclusions.
This said, I did this

void setup() 
  pinMode(D7, OUTPUT);

int count;
void loop() 
  digitalWrite(D7, !digitalRead(D7));
  if (count++ > 10)
      System.sleep(SLEEP_MODE_DEEP, 120);

and on my devices this behaves just as expected, so there might be a different reason.
By adding one possible cause after the other - going from most likely (e.g. Particle.publish() just before sleep) down to most unlikely (e.g. int cm = 0;)
And since we can’t see the implementation of measurement() and beep()it’s also difficult to test your original code too.

But with these dummy implementations, your code still behaves as expected

int measurement()
    return 10;

void beep(int a, int b, int c)

Thanks for replying. You’re absolutely right about the need for narrowing down the problem.
So I tested to remove most of the code, including the publish (Which has a default TTL of 60s so I thought maybe something going on there, but the same problem was seen.
So now I have only this code, no periferals attached:

void setup() {


void loop() {

System.sleep(SLEEP_MODE_DEEP, 128);


And the device does not seem to recover from the deep sleep at all, i.e. no onboard led is lit up periodically (should be at least 3000ms anyway).
I’ll try to find a 2:nd Photon to try it on.

It might be your device then, since mine work just as expected.
Maybe try to explicitly update the firmware to 0.4.7 (again).
If you got the most current CLI installed, try particle update.

I`ve tried it again with your basic code , it works as it should 2 minutes asleep , connects to the wifi and cloud and back to sleep again.

OK, here’s an update. Somewhat embarrassing but might help others…:
Solution: Powering the device from a computer connected USB worked fine!

I thought I was clever using a power bank to power the Photon (I need it to be battery powered). But I realise now that the power bank probably has an internal timer of 60s, after which the power bank cuts the power if not enough current is drawn, which is not the case during a deep sleep.
Which in turn resets the Photon, which in turn activates the photon again. And there’s the loop of 60s…
I’ll now get a lipo battery back and a step-up converter instead!

Thanks for your replies and tests! Love this forum.


Yes , I tried using a powerpack at first and got a similar results, but my pack just switched it off and I had to press a button to get it working again.

Can you tell me which power pack are you referring too? I have the spark fun shield… Is that the same as you are referring?

just a cheap phone charger type powerpack not disigned for the core / photon.
Now I how the sparkfun powershield and that is working well, just finished my testing with a 6ah battery .
I wanted a 5 minute wake up , so I sent data to my server , switched the wifi off for 4 minutes and put it in a 5 minute delay loop.
3 and half days and I would still have a fully working photon to count pulses etc.
Next some sort of solar charging ,but here in the UK , there is not a lot of sun to collect now.