Lorabee RN2483 sleep problem

Hello,

I’m using a sodaq autonomo with lorabee module RN2483.
I’m trying to put all the system in deep sleep mode for lower power consumption.
For the autonomo, im using RTCZERO library in order to interrupt the autonomo every x minutes.
For lora RN2483, i tried using loraSerial.write(“sys sleep …”) command but it isnt working wherever i place it in the code ( setup() or loop() )
While the autonomo is sleeping, it consumes around 3 mA ( with or without sys sleep command)
I also tried to disable all lorabee pins including the BEE_VCC, the current decreased to 0.05 mA but changing this pin from low to high doesnt permit data transmission even if I reinitialize the network setup.
I tried many codes already posted on the forum, none works well for my case and the power consumption isnt getting lower than 3 or 2 mA.

PS: i updated the firmware to version 1.0.3
Any help ?

Have you tried using the sleep() and wakeUp() commands from the library?

One thing to note, make sure you don’t make two calls in a row to sleep(). I believe the activity on the UART from the second call to sleep() results in waking the board up once again.

When the LoRa module is idle it uses about 3ma, in sleep mode that should drop to about 10uAs.

Could you possibly give me an example code on how we call these functions ? ( which order and where to place them ?)

You will need to call the wake function at least once each cycle before using the LoRa module:

LoRaBee.wakeUp()

Similarly, you must call the sleep function before putting the Autonomo into sleep mode:

LoRaBee.sleep()

i’m actually trying this code, and the sleep function doesn’t seem to be working. (current 11.34 mA even the autonomo won’t enter the sleep mode when i put LoRaBee.sleep() before rtc.standbyMode())

#include <Sodaq_RN2483.h>
#include <Sodaq_wdt.h>
#include <StringLiterals.h>
#include <Switchable_Device.h>
#include <Utils.h>

#include <RTCZero.h>
#define loraSerial Serial1
#define beePin BEE_VCC

#define debugSerial SerialUSB

RTCZero rtc;
uint8_t seconds = 0;
uint8_t minutes = 00;
uint8_t hours = 00;
volatile bool rtc_flag = false;
void setup()
{
debugSerial.begin(57600);

loraSerial.begin(LoRaBee.getDefaultBaudRate());

digitalWrite(beePin, HIGH);

LoRaBee.sleep();
rtc.begin(true);
rtc.setTime(hours, minutes, seconds);
rtc.setAlarmTime(00,1,00);
rtc.enableAlarm(rtc.MATCH_MMSS);
minutes+=1;

rtc.attachInterrupt(alarmMatch);

}
void loop()
{

if(rtc_flag)
{
LoRaBee.wakeUp();
rtc.disableAlarm();
rtc_flag = false;
digitalWrite(13, HIGH);

delay(5000);

minutes+=1;
rtc.setAlarmTime(00,minutes,00);
rtc.enableAlarm(rtc.MATCH_MMSS);
digitalWrite(13, LOW);
LoRaBee.sleep();

}

rtc.standbyMode(); // Sleep until next alarm match

}
void alarmMatch()
{
rtc_flag = true;
}

@GabrielNotman can you please post a working code that puts both the Autonomo and LoraBee into sleep mode. Please it’s urgent!

Here you go:

A couple of things, you need to initialise the LoRaBee module and the call to the sleep function must be given a little bit of time to take effect. In this example, I call the flush method which ensures all data has been transmitted. Adding a small delay will also have the same effect.

I’m reading in the region of 16uAs for the below sketch.

Note, a copy of the library dependencies are included in the repository.

Gabriel if already using RTCZero lib why not using rtc.standbyMode();?

It is a personal preference. The power management of the SAMD processor has nothing to do with the RTC module. As such, I don’t think the standbyMode() method has any business being part of the RTCZero library.

The actual code to enter standby mode is just a single call to Wait For Interrupt __WFI(). I really don’t see the point in adding a method to call this, in an unrelated library.

Hi gabriel,
Thank u for ur help but unfortunately your code didn’t work well for me. Maybe you’re using a different library or working on the sodaq one instead of the sodaq autonomo.
Here’s a sketch that worked (power consumption ~ 80 uA):

#include <Sodaq_RN2483.h>
#include <Sodaq_RN2483_internal.h>
#include <Sodaq_wdt.h>
#include <Utils.h>

/*
Sleep RTC Alarm for Arduino Zero

Demonstrates the use an alarm to wake up an Arduino zero from Standby mode

This example code is in the public domain

http://arduino.cc/en/Tutorial/SleepRTCAlarm

created by Arturo Guadalupi
17 Nov 2015
modified
01 Mar 2016

NOTE:
If you use this sketch with a MKR1000 you will see no output on the serial monitor.
This happens because the USB clock is stopped so it the USB connection is stopped too.
To see again the USB port you have to double tap on the reset button!
*/

#include <RTCZero.h>
#define loraSerial Serial1
#define beePin BEE_VCC

#define debugSerial SerialUSB

#define sleepTime 120000

/* Create an rtc object */
RTCZero rtc;

/* Change these values to set the current initial time */
uint8_t seconds = 0;
uint8_t minutes = 00;
uint8_t hours = 00;
volatile bool rtc_flag = false;

/* Change these values to set the current initial date */
/const byte day = 17;
const byte month = 11;
const byte year = 15;
/

void setup()
{

String str;
debugSerial.begin(57600);
//delay(20000);
//debugSerial.println(“Starting”);
loraSerial.begin(LoRaBee.getDefaultBaudRate());

digitalWrite(beePin, HIGH);

pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);

/bool a;
a=LoRaBee.sendCommand("sys sleep ", "20000 ");
debugSerial.println(a);
/

rtc.begin();

rtc.setTime(hours, minutes, seconds);
// rtc.setDate(day, month, year);

rtc.setAlarmTime(00, 1, 00);
rtc.enableAlarm(rtc.MATCH_MMSS);
minutes+=1;
rtc.attachInterrupt(alarmMatch);
// delay(10000);
// loraSerial.write(“sys sleep 60000”);
// delay(10000);
// LoRaBee.sleep();

// loraSerial.println(“sys sleep 80000”);
delay(10000);

loraSerial.print("sys sleep ");
loraSerial.println(sleepTime);
delay(100);
// trace(“Sleeping…”);
//str = loraSerial.readStringUntil(’\n’);
//trace(str);
rtc.standbyMode();
}

void loop()
{

if(rtc_flag)
{

wakeup();
rtc.disableAlarm();
rtc_flag = false;
digitalWrite(LED_BUILTIN, HIGH);

debugSerial.println(“autonomo woke up”);
delay(5000);

minutes+=1;
rtc.setAlarmTime(00,minutes,00);
rtc.enableAlarm(rtc.MATCH_MMSS);

digitalWrite(LED_BUILTIN, LOW);
loraSerial.print("sys sleep ");
loraSerial.println(sleepTime);
delay(100);

}

rtc.standbyMode(); // Sleep until next alarm match

}

void alarmMatch()
{
rtc_flag = true;
}

void wakeup(){
Serial1.end();
pinMode(PIN_SERIAL1_TX, OUTPUT);
digitalWrite(PIN_SERIAL1_TX, LOW);
delay(5);
digitalWrite(PIN_SERIAL1_TX, HIGH);
Serial1.begin(57600);
Serial1.write(0x55);
}

I am stuck at 2.68 mA in deep sleep :frowning:

Dear Eddy,

Please share a bit more information so we can help you.

Kind regards,
Jan

Jan,

I used the sodaq sleep sample and then i get this result.
So am not going to micro Amps.

We turn off the gps, ouput pins, motion chip, serial, usb.

Problems is that sys sleep xxxx turns off the chip direct without giving a response, so a simple delay 150 is used after sending sleep command.

regards

Eddy

Any news on this, in lora advertisements they speak running for years. I only achieve days.

Am not getting any lower then 2,6 mA.

regards

Eddy

This is likely caused by something interfering with the RN2483 from properly entering sleep mode.

It can be something like making repeated calls to enter sleep mode as the UART activity might wake up the LoRa module. I would recommend looking at how the library handles the sleep and wake functions.

We looked at this and only one call is made to sleep and no further action is taken on the uart.