LowPower_Handler(); function on the CubeCell board

I am transmitting from one CubeCell board to another in the point-to-point mode, and I would like to put the transmitting CubeCell into lowpower state periodically for say one hour.

I re-used the code from the PingPong example. Everything works fine. One board is only transmitting another is only receiving. Only the transmitting board works from the battery, so I need lowpower mode only on it. There is the BME680 sensor on it, which works fine, by the way.

I read the LowPower_WakeUPByTimer example. However I am unable so far implement its approach on this transmitting CubeCell.

Is there a possibility to read more about the LowPower_Handler(); function. I search via Google but I cannot find more information except this example.

I will try tomorrow to exchange BME680 on BME280. I read meanwhile at a forum that the BME680 requires more than 10 mAh. Probably, this is why I think I am not in a lowpower mode.

the BME680 is very power hungry cause of his sensor design.
It heats up a plate to measure the VOC.
The BME280 is requiring much less power.

But the MCU does not know about it.
Have you connected the sensor to VEXT?
if yes only turn VEXT on about 5-10 seconds before taking a measurement.
After that run VEXT off.

I understood how the Vext works. After pinMode(Vext, OUTPUT); digitalWrite(Vext, HIGH); we get 3.4 Volts on the pin #6 in the middle of the board. After digitalWrite(Vext, LOW); it is back to 0 V.

The BME280 works fine from the Vext pin. It seems there is enough current for this sensor on this pin.

Now I am trying to use the Vext together with the BME280 and the LowPower_Handler();

BME280 makes measurements once, but then it does not wake up for some reason. And I cannot find a soluton for this. I want that after the wakeup the sensor makes the new measurements.

Here is my code:

#include “BME280.h”
#include <Wire.h>
#include “Arduino.h”

#define timetosleep 15000
#define timetowake 20000
static TimerEvent_t sleep;
static TimerEvent_t wakeup;
uint8_t lowpower = 1;

unsigned long time_now = 0;

BME280 bme280;

void OnSleep()
{
Serial.printf(“into lowpower mode, %d ms later wake up.\r\n”, timetowake);
lowpower = 1;
//timetosleep ms later wake up;
TimerSetValue( &wakeup, timetowake );
TimerStart( &wakeup );
}

void OnWakeup()
{
Serial.printf(“wake up, %d ms later into lowpower mode.\r\n”, timetosleep);
lowpower = 0;
//timetosleep ms later into lowpower mode;
TimerSetValue( &sleep, timetosleep );
TimerStart( &sleep );
}

void setup()
{
Serial.begin(115200);
BoardInitMcu();
Radio.Sleep( );
pinMode(Vext, OUTPUT);
digitalWrite(Vext, HIGH);

if (!bme280.init()) {
Serial.println(“Device error!”);
}

time_now = millis();
while (millis() < time_now + 500) {
}

TimerInit( &sleep, OnSleep );
TimerInit( &wakeup, OnWakeup );

OnWakeup();

}

void loop()
{

if (lowpower) {

digitalWrite(Vext, LOW);

time_now = millis();
while (millis() < time_now + 1000) {
}

//note that LowPower_Handler() run six times the mcu into lowpower mode;
LowPower_Handler();

time_now = millis();
while (millis() < time_now + 1000) {
}

} else {

digitalWrite(Vext, HIGH);

time_now = millis();
while (millis() < time_now + 2000) {
}

float pressure;

//get and print temperatures
Serial.print("Temp: ");
Serial.print(bme280.getTemperature());
Serial.println("C");//The unit for  Celsius because original arduino don't support speical symbols

//get and print atmospheric pressure data
Serial.print("Pressure: ");
Serial.print(pressure = bme280.getPressure());
Serial.println("Pa");

//get and print altitude data
Serial.print("Altitude: ");
Serial.print(bme280.calcAltitude(pressure));
Serial.println("m");

//get and print humidity data
Serial.print("Humidity: ");
Serial.print(bme280.getHumidity());
Serial.println("%");

time_now = millis();
while (millis() < time_now + 2000) {
}

}
}

Can you check the voltage on the pin after wake up? I was getting 1.8v after wake up, which I thought was just me but you are describing the behavior I saw.

(I didn’t fix it as I realized I needed the sensor on all the time and moved away from vext)

Yes, I measured it. It is 1.6 V.

I have a feeling that I do not get it right yet how the LowPower_Handler(); works.

No I think this is a bug as it still turns on after wakeup. I’ve raised a github issue to track this.