LoRaBEE On SODAQ Mbili Sleep mode

Hi,

I would like to use the SODAQ Mbili board and use the LoRaBEE RN2483 to transmit data.

I want to put the device into deep sleep mode to save energy and I put the device into sleep mode. The current consumption is 3.7mA, however when I unplug the LoRaBEE head, the current consumption can drop to 0.7mA, which means the LoRaBEE still consumes energy.

I disable the pin 23/D23 which I think it is the switch of the power supply of the BEE however it does not work.

void setup() {
// initialize digital pin
pinMode(23, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(23, HIGH); // (HIGH is the voltage level)
delay(5000); // wait for a second
digitalWrite(23, LOW);
delay(5000);
}

Here is how I test the device, when it is in the high state the current consumption is 30mA and in low state it can be 9mA and if I unplug the BEE the current can drop to 6mA. So can I further reduce the 3mA current consumption by using software switch?

Many thanks.

Hi @Yansong,

The best practice is to send the sleep command to the RN module.
sys sleep <length>

In our library we use the maximum sleep time and wake it by a break command.

Best regards,
Jan

Hi Jan

Thanks a lot for your constructive suggestions.

I tried to put the LoRa head into sleep mode, and it was successful.

However when I put both the SODAQ MbIli and the LoRaBee into sleep at the same time. It seems that the board can not sleep any more. Here is the code for me to put the board into sleep.
#include <Wire.h>
#include <avr/sleep.h>
#include <avr/wdt.h>

//SODAQ Mbili libraries
#include <RTCTimer.h>
#include <Sodaq_DS3231.h>
#include <Sodaq_PcInt.h>

//The delay between the sensor readings
#define READ_DELAY 1

#include “Sodaq_RN2483.h”

#define loraSerial Serial1
#define debugSerial SerialUSB

#define DEBUG_BAUD 57600

//RTC Timer
RTCTimer timer;

//RTC Interrupt pin
#define RTC_PIN A7
#define RTC_INT_PERIOD EveryMinute
#define loraSerial Serial1

#include “Sodaq_RN2483.h”
const uint8_t devAddr[4] =
{
0x26, 0x01, 0x17, 0xC3
};

// USE YOUR OWN KEYS!
const uint8_t appSKey[16] =
{ 0x03, 0xB3, 0x96, 0x6E, 0xEF, 0x7F, 0x85, 0x5F, 0x1F, 0xDB, 0x6A, 0x32, 0xF0, 0x4E, 0x69, 0x6C };

// USE YOUR OWN KEYS!
const uint8_t nwkSKey[16] =
{ 0x48, 0x71, 0xA7, 0x68, 0xA0, 0xE1, 0x92, 0x37, 0x0E, 0xD9, 0xBC, 0x2B, 0xDA, 0xF1, 0x14, 0xB9 };

const uint8_t testPayload[] =
{
0x30, 0x31, 0xFF, 0xDE, 0xAD
};
void setup()
{
//Initialise the serial connection
Serial.begin(9600);
loraSerial.begin(LoRaBee.getDefaultBaudRate());

//LoRaBee.initABP(loraSerial, devAddr, appSKey, nwkSKey, true);

//Setup timer events
setupTimer();

//Setup sleep mode
setupSleep();

//Make first call
Serial.println(“Power On”);
showTime(getNow());
}

void loop()
{
//Update the timer
timer.update();

//Sleep
systemSleep();
}

void showTime(uint32_t ts)
{
//Retrieve and display the current date/time
String dateTime = getDateTime();
Serial.println(dateTime);
}

void setupTimer()
{
//Instruct the RTCTimer how to get the current time reading
timer.setNowCallback(getNow);

//Schedule the reading every second
timer.every(READ_DELAY, showTime);
}

void wakeISR()
{
//Leave this blank
}

void setupSleep()
{
pinMode(RTC_PIN, INPUT_PULLUP);
PcInt::attachInterrupt(RTC_PIN, wakeISR);

//Setup the RTC in interrupt mode
rtc.begin();
rtc.enableInterrupts(RTC_INT_PERIOD);

//Set the sleep mode
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
}

void systemSleep()
{
//This method handles any sensor specific sleep setup
sensorsSleep();
//LoRaBee.initABP(loraSerial, devAddr, appSKey, nwkSKey, true);

//Wait until the serial ports have finished transmitting
Serial.flush();
Serial1.flush();

//The next timed interrupt will not be sent until this is cleared
rtc.clearINTStatus();

//Disable ADC
ADCSRA &= ~_BV(ADEN);

//Sleep time
noInterrupts();
sleep_enable();
interrupts();
sleep_cpu();
sleep_disable();

//Enbale ADC
ADCSRA |= _BV(ADEN);

//This method handles any sensor specific wake setup
sensorsWake();
}

void sensorsSleep()
{
//Serial.println(“inits”);
//LoRaBee.initABP(loraSerial, devAddr, appSKey, nwkSKey, true);
Serial.println(“sleep”);
showTime(getNow());
//LoRaBee.sleep();
}

void sensorsWake()
{
Serial.println(“initw”);
//LoRaBee.initABP(loraSerial, devAddr, appSKey, nwkSKey, true);
Serial.println(“wake”);
//LoRaBee.wakeUp();
delay(5000);
pinMode(5, OUTPUT);
digitalWrite(5, LOW);
loraSerial.flush();

}

String getDateTime()
{
String dateTimeStr;

//Create a DateTime object from the current time
DateTime dt(rtc.makeDateTime(rtc.now().getEpoch()));

//Convert it to a String
dt.addToString(dateTimeStr);

return dateTimeStr;
}

uint32_t getNow()
{
return rtc.now().getEpoch();
}

Many thanks.