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.

You had connect a sensor, right? That’s because the current from the GPIO is inverted to Vext, which generates a certain voltage.
Please set the sensor’s relevant GPIO to ANALOG while sleep mode.
for example:
pinMode(GPIO0, ANALOG);

Yes, the sensor BME 280 is connected to the CubeCell board. I use 4 pins of the sensor: GND, VCC, SCL, and SDA.

There are two VEXT pins on the CubeCell board as per this diagram: https://github.com/HelTecAutomation/ASR650x-Arduino/blob/master/PinoutDiagram/HTCC-AB01.pdf

One of the VEXT pins has the number 16 and the GPIO6 on the diagram, and another has no number on this diagram, just the text VEXT.

There is the pin #30 with the GPIO0 on the left side of the diagram. I do not use this pin. Do you mean that I may try to use this pin as a VEXT too with this code:
pinMode(GPIO0, ANALOG);

Did you ever resolve this issue? I am having the same basic problem trying to use a BME280 sensor in conjunction with the lowPowerHandler. Do you have a sketch that works?

It’s OK. The voltages were actually OK when I managed to measure them, and I ultimately got things working by removing the turnOnRGB/turnOffRGB calls I had in my script. Why that was a problem is a question for another time/post… This problem did though seem only to pop up after I upgraded my board software (RGB_ON disappeared in 0.0.5 in favour of turnOnRGB/turnOffRGB), so maybe there’s a conflict there somewhere.