Wake ARM but leave modem in sleep mode

Hi there.

I’m busy building a weather station using the Electron. Part of the weather station is a Davis anemometer.

Basically I’m using the anemometer to trigger an interrupt for each revolution. In the interrupt I increment a counter to keep track of the completed revolutions. After 5 seconds I use the counter to calculate the average wind speed. This average is then stored in a buffer. This process is repeated for 5 minutes. Then the average of the buffer is calculated to determine the 5 minute average wind speed. The maximum value in the buffer is taken as the gust. The data is then published to InfluxDB.

The above mentioned was implemented successfully.
The problem comes in with the power saving aspect. The idea is to put the Electron to sleep using the following:

System.sleep(wakeUpPin, edgeTriggerMode, seconds, SLEEP_NETWORK_STANDBY);

Each time the anemometer completes a revolution the ARM wakes up, increments a counter, and goes back to sleep. The problem is that the modem also wakes up when the ARM wakes up and wastes a lot of power. I only need the modem to wake up once every 5 minutes.

Any suggestions on how I can achieve this?

I know that I can turn the modem off completely, but I’m trying to avoid this to save the time it takes to connect to the network.

Thanks in advance

What SYSTEM_MODE() are you using and do you have SYSTEM_THREAD(ENABLED)?

I’m using the default settings:

I’m pretty sure you’ll find what you want to do impossible. At rain gauge intervals, it’s workable. At anemometer intervals, it’s just not possible to wake up the MCU that often. You’d also miss a bunch of clicks during the wake-to-sleep or sleep-to-wake intervals.

There’s no mode that will allow you keep the modem in standby mode but not wake it on wake. I can see why you’d need it in this scenario, but it’s not supported.

I think you’re going to need an external counter to handle the anemometer.

1 Like

I’m not sure I’m following.
It takes a few milliseconds for the MCU to wake up, increment a counter and go back to sleep. I wrote a few lines of code to test it and it works.
According to the Davis datasheet: 1600 rev/hr = 1 mph which is more or less 26 revolutions per minute.
For an MCU running at 30 MHz this is extremely slow.

I thought about using an external counter but this means I can’t update that part of the code OTA and it makes the circuit more complex.

If its possible to put the modem into standby mode using a software command, it should be possible to keep it in standby when resuming from sleep. I’m assuming a command is sent to the modem when the MCU wakes up to get it to exit standby mode. If this is the case I should be able to wake up the MCU and prevent it from sending that command.

Using your datasheet info, if you have wind gusts up to 30 MPH, you’re looking at 48000 triggers / hour = 800 / minute = 13.3 / second. At that speed, you’re only allowing about 75 ms to wake-up, process and go back to sleep. With a gust of 60 MPH, you’re only allowing 37.5 ms.

Rickkas7’s suggestion of an external counter would be the best way. The counter consumes as low as 40 uA and would allow the Electron to spend longer periods of time asleep. With an 8-bit counter, you could sleep for up to 256 pulses (which is probably the full 5 seconds). You would wake, read the counts, reset the counter and sleep again. You would never miss a pulse. If you use a 4-bit counter, you could wake every 5 seconds, or, wake whenever the counter overflows.

You could use an 8-bit counter like this:

If you don’t have 8 pins available on your uC, you could use a shift register to reduce the pin usage down to 2 or 3:

That sounds like a really good idea! That would mean the MCU could sleep for the full 5 seconds.

That only leaves one more issue. I would still like to use the modem standby (not switch it off). The problem is that the modem returns to normal mode when the MCU comes out of sleep to read the external counter. The modem takes more or less four seconds to go to standby. Therefore if the MCU wakes up every 5 seconds, the modem would basically be on the whole time.

You might want to take some real-world measurements and figure out what works best. Is it better to use network standby while mostly sleeping for 5 minutes? Or would it take less power to go into full-sleep and then wake the modem once every 5 minutes? If using the latter, you would probably need to change to SYSTEM_MODE(MANUAL).

The risk with waking from a full modem sleep is the data consumption for a handshake and the length of time it takes to do the full cellular re-connection (which I understand can take up to a minute or two.) But the power consumption on NETWORK_STANDBY could still be worse I suppose.

According to this awesome tutorial by @rickkas7, Choosing an Electron sleep mode :

"it takes 334 seconds (about 5 1/2 minutes) of SLEEP_MODE_SOFTPOWEROFF to offset the energy used to reconnect to cellular.

Of course if you need to wake up quickly, you may want to use SLEEP_NETWORK_STANDBY for even longer sleep periods, just to save the 24 to 60 seconds to reconnect to cellular.

The only situation where you’d likely use stop mode sleep (pin + time) without using SLEEP_NETWORK_STANDBY is if you need to wake up to take a measurement frequently, but only upload those measurements infrequently (more than every 15 minutes or so)."

Which brings me to the conclusion that SLEEP_NETWORK_STANDBY would be better suited for my application (if I can figure out how to implement it :smiley:)

1 Like