LoRa DeepSleep + Sensor example

While the reference https://github.com/RAKWireless/WisBlock/blob/master/examples/communications/LoRa/LoRaWAN/Low_Power_Example.md
explains the deep sleep functions, and the example code works well with OTAA and thethingsnetwork, I am having some issues getting the BME680,
I think the semaphores and looptask is a bit tricky.

Is there any example for deepsleep with a sensor I could use as inspiration? (how to handle the setup and loop)

For the BME680 and BSEC library to work and calculate IAQ values, the sensor has to be running all the time and feeding values into the closed source BSEC libraries.
Therefor the deep-sleep example cannot be applied.

That’s not actually true.

The BSEC library will tell the hosting code how long to wait until calling it again. The processor can then be made to sleep until that point in time.

I do recall that the rate choices for BSEC seemed to be “very fast” or “very slow” without any pacing that felt useful to me. And sticking a big binary blob in an embedded firmware was a non-starter anyway… their insistence on making it closed and secret basically made it unusable.

But it does not actually prevent suspending the processor.

1 Like

Indeed, 300s for quoted average current ~0.1mA or every 3s for two combos of readings, one of which is ~0.1mA, or full speed of 1s for all those Sci-Fi movie moments when the volatile gasses are pouring out in to the room.

The wrinkle Bosch don’t highlight so well is that if you do go to sleep, the Arduino library implementation relies on millis() being up to date, so you either add a value on when you wake up in time for the next reading or you, on AVR, use SLEEP_MODE_IDLE which is a bit academic as it wakes every millisecond and uses almost the same amount of power. If you lose RAM per ESP32, you have to save some data structures, sleep and upon awake, restore data & rejig the timer.

1 Like

I guess I can skip the IAQ and fancy stuff of the BME680, eventually use an SHT. Is there any Wisblock code example with deepsleep, LoRa and a sensor.

The DeepSleep example can be easily extended to read a sensor.
Put your sensor initialization into setup().
And then in loop find

and replace the comment with your code to read the data.

Of course you have to change SendLoRaFrame as well to send the sensor data instead of ‘Hello’.

1 Like