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);
}