Lora Radio, Arduino Pro Mini, Low power lib- Help needed

Hey Everyone,

I have a head scratcher here and don't know where to look anymore, hoping someone can help find my problem.

Hardware
Arduino Pro mini 8mhz 3v3- Regulator removed
SX1262 Lora radio module

Code overview
Wake up every 3 minutes (ish) take a analog reading and send it. to make the system power efficient I used Lowpower Lib as its worked well in the past.

First I tried with Blink LED and thats works fine, the sleep current is around 4uA which is expected. Then I inergrated the RadioLib library and setup the SX1262 radio with a photofet ( digital 5) to turn the power on and off to the module in sleep periods. When the radio wakes again the radio coms gets restarted and setup before transmission, this works as expected.

But what im struggling with is the following.
When the device boots it goes into sleep immediately and i see the 4uA so I know the issue is not some static current on the hardware, after the first wakeup period. the device wakes and transmits as expected. but then the sleep current only goes back down to 500uA and not 4uA. this cycle continues for 4 or 5 transmissions, sometimes misses a message here and there and then the device either gets stuck in 5 or 6mA state or goes down to 500uA and never transmits again.

I have tried different bootloaders and currently have standard 3v3 8mhz bootloader same behavior's. Really confusing as this seems straight forward. I asked Jan form Radio Lib he does not see anything wrong his side and LowPower guys also does not see anything wrong, just recommended some delays. but this has little impact from what I can see. What am i doing wrong ?

#include <LowPower.h>
#include <RadioLib.h>

unsigned long Counter =0;
unsigned long runcount=0;
int VbatOK;

void setup() 
{
 //Serial.begin(9600);
  pinMode(5,OUTPUT);
  pinMode(6,INPUT);
  pinMode(A0,INPUT);
  digitalWrite(5,LOW);
  analogReference(INTERNAL);
  digitalWrite(10,LOW);
  digitalWrite(11,LOW);
  digitalWrite(12,LOW);
  digitalWrite(13,LOW);
}

void loop() 
{  
  
  delay(100);
   if(Counter > 20)
   {
     //delay(100);
     pinMode(5,OUTPUT);
     pinMode(6,INPUT);
     pinMode(A0,INPUT);
     delay(100);
     VbatOK = digitalRead(6);
     if( VbatOK == HIGH)
     {
     digitalWrite(5,HIGH);
     delay(200);
     SX1262 radio = new Module(10, 2, 3, 9);
     delay(200);
     radio.begin(907.5, 500.0, 7, 5, 0x31, 10, 8);
     delay(100);
     float SuperCap = ((analogRead(A0))*4.39); // Resistor Ratio 680K/220K
     String myData = String(SuperCap)+ " mV " + String(runcount)+ " Cycles";
     radio.transmit(myData);
     delay(350);
     digitalWrite(5,LOW);
     SPI.end();
     delay(100);
     }
     Counter = 0;
     runcount++;
   }
   Counter++;
   LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}

That won't work. You cannot connect a powered device to an unpowered device via I/O pins. You can actually damage both devices doing that.

Focus on sleep modes instead.

The radio is not powered via GPIO.. the photoset is turned on and off from GPIO.

Your objection is irrelevant. Do not connect I/O pins on an MCU to I/O pins on an unpowered module.

I dont even know how to respond to that.. offcourse you can, but thats beside the point when the device is in this sleep state physically removing the connections between the module and mcu has no effect so seems like there is a sub system or peripherals not turning off

Good luck with your project.

1 Like

Start at the beginning.

Did you try a basic code that was just for the LoRa module, no other components connected, that would wake up, send a packet (and it was received) and go back to sleep ?

When no sleep library is implemented then that works as expected. but with the sleep library i get this issue. regardless if the power to the Radio gets turned off. ill try it again to confirm. been battling this for 2 weeks now.

Not sure what you are saying there.

Go back further, with the LoRa module removed, not conected, does the sleep library give you a repeatable low sleep current ?

Correct yes, Order of test events

  1. MCU plus blink example works
  2. MCU plus blink plus Low power works and get desired power consumption
  3. MCU Plus Lora Module works
  4. MCU Plus Lora Module plus low power does not work as expected. ( Lora radio does not get powered down)

Im retesting test 3 now to see again if its reliable for set duration. so disabled all low power attempts. just want to confirm again it was working to that point

Yes, So Sleep code disabled, and lora module left powered its repeatable and reliable.

15:24:18.140 -> success!
15:24:18.140 -> [SX1262] Data:		3239.82 mV 11 Cycles
15:24:18.140 -> [SX1262] RSSI:		-60.00 dBm
15:24:18.140 -> [SX1262] SNR:		12.00 dB
15:24:39.258 -> success!
15:24:39.258 -> [SX1262] Data:		3239.82 mV 12 Cycles
15:24:39.258 -> [SX1262] RSSI:		-60.00 dBm
15:24:39.304 -> [SX1262] SNR:		12.00 dB
15:25:00.433 -> success!
15:25:00.433 -> [SX1262] Data:		3239.82 mV 13 Cycles
15:25:00.433 -> [SX1262] RSSI:		-60.00 dBm
15:25:00.433 -> [SX1262] SNR:		10.75 dB
15:25:21.544 -> success!
15:25:21.544 -> [SX1262] Data:		3239.82 mV 14 Cycles
15:25:21.544 -> [SX1262] RSSI:		-60.00 dBm
15:25:21.544 -> [SX1262] SNR:		12.50 dB
15:25:42.660 -> success!
15:25:42.660 -> [SX1262] Data:		3239.82 mV 15 Cycles
15:25:42.660 -> [SX1262] RSSI:		-60.00 dBm
15:25:42.660 -> [SX1262] SNR:		12.25 dB

No Cycles are being missed. and the constant current is about 9mA

Just enabled sleep function again bare bones code here

`#include <LowPower.h>
#include <RadioLib.h>

unsigned long Counter =0;
unsigned long runcount=0;
int VbatOK;
SX1262 radio = new Module(10, 2, 3, 9);
void setup() 
{
 //Serial.begin(9600);
 radio.begin(907.5, 250.0, 7, 5, 0x31, 10, 8);
  pinMode(5,OUTPUT);
  pinMode(6,INPUT);
  pinMode(A0,INPUT);
  analogReference(INTERNAL);
}

void loop() 
{  
  delay(100);
   if(Counter > 15)
   {
     VbatOK = digitalRead(6);
     if( VbatOK == HIGH)
     {
     float SuperCap = ((analogRead(A0))*4.39); // Resistor Ratio 680K/220K
     String myData = String(SuperCap)+ " mV " + String(runcount)+ " Cycles";
     radio.transmit(myData);
     delay(500);
     }
     Counter = 0;
     runcount++;
   }
   Counter++;
   LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}

Sleeps at 6mA because the radio is not being turned off, but you can see its skips transmissions here and there.

16:40:26.079 -> success!
16:40:26.079 -> [SX1262] Data:		3700.77 mV 0 Cycles
16:40:26.079 -> [SX1262] RSSI:		-56.00 dBm
16:40:26.079 -> [SX1262] SNR:		12.50 dB
16:45:21.641 -> success!
16:45:21.641 -> [SX1262] Data:		3235.43 mV 2 Cycles
16:45:21.641 -> [SX1262] RSSI:		-58.00 dBm
16:45:21.641 -> [SX1262] SNR:		13.50 dB
16:47:49.383 -> success!
16:47:49.383 -> [SX1262] Data:		3239.82 mV 3 Cycles
16:47:49.383 -> [SX1262] RSSI:		-58.00 dBm
16:47:49.383 -> [SX1262] SNR:		12.75 dB

6mA does not sound right for a Pro Mini (in sleep mode) with no regulator and the SX1262 in idle mode. The SX1262 in idle mode should consume around 0.5mA.

Your taking a significant risk changing away from the standard sync word, it can result in dropped packets or reduced sensitivity.

Using Strings on an ATmega328 is generally not recommended, it can lead to un-stable programs.

EDIT
I get your point about current, if the lora radio is powered on its own its 500uA On the pro mini I'm use to on barebones pro mini being around 4uA. thats the reason for switching off the radio but the issue is the device still draws or did draw the 500uA event with radio completely off. the only why this normally happens if there is leakage vis the SPI bus to ground. and leaving the pins in a low state or uninitialized is how you would deal with that but im not sure if thats how these libraries works.

Ill try and see why im now getting the 6ma. I loaded the original code back on with extended delays and im back at sleeping 500uA but same unstable performance

Agreed with the string but that does not explain way the code with no sleep is reliable even using strings

Sync word. Here you have me... I'm not sure I understand how a software define sync Word has anything todo with the radio sensitivity or performance? The two are not related. Can you elaborate? I know from previous work the sx127x radios could only catch and decode packets if the sync word was seen but the sx126x radios is able to detect any part of the transmission.

Have you investigated radio.sleep() or radio.standby() ?

Nope. Will have a look at that next. I was under the impression the radio library would put the radio into low power state be default if not active. Seems not to be the case. Will see what effect that has.

Thanx for pointing it out

No Luck, current consumption states same

The SX126X should in idle mode consume circa 500uA. You dont need to put it it idle (Standby) mode, it will be in that mode if its not in TX,RX or sleep modes.

Issues with the sync word affecting performance are well known, for instance;

Stick to the standard syncwords.

I note the library your using is accepting the syncword as 8 bits, whereas the SX126X actually uses 16 bits.

That should put the SX126X into a sub 1uA sleep. There is no need to fiddle with the SPI or IO pins.