LoRa, high consumption.

There is a problem in the device with low consumption (Atmega 328P-PU + LoRa transmitter) - a very high sleep current - 2.5 mA.

#include <SPI.h>
#include <LoRa.h>
#include <LowPower.h>

unsigned int sleepCounter; // sleep cycles
String messageTout;  // LoRa-Message

void SendMessage (){
// sending data (temperature, battery voltage)
 float Tout = 22.22;
 float batteryLevel = 2.88;
 
  messageTout = String(Tout) + "#" + String(batteryLevel); 
  Serial.println(messageTout);
  delay(1000);
  LoRa.beginPacket();
  LoRa.print(messageTout);
  LoRa.endPacket();
}

void setup() {
  Serial.begin(9600);
  Serial.println("Initializing ...");

  int counter = 0;  
  while (!LoRa.begin(433E6) && counter < 10) {
    Serial.print(".");
    counter++;
    delay(500);
  }
  
  if (counter == 10) {
    Serial.println("Failed to initialize ...");
  }
  LoRa.setSyncWord(0xF3); // synchronic word: 0...0xFF
}

void loop() {


    //sleepCounter = 15 - 2 min (8s * 15 = 120s)
    for (sleepCounter = 8; sleepCounter > 0; sleepCounter--)
    {
      LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);  
    }
    Serial.println("");
        SendMessage ();
        LoRa.sleep ();

    for (int i = 1; i < 15; i++) {
    pinMode(i, OUTPUT);
    digitalWrite(i, LOW); } 
 }

The quiescent current measured by the test circuit is 8 μA.
I can not find a mistake in my sketch. Please help me find a bug. Or I ask you to give an example of a sketch for LoRa, in which there is an internal watchdog timer.
Thanks in advance for your help.
P.S. Sorry, bad computer translation.

Lora_Sleep_test_orig.ino (938 Bytes)

From the link you provided;

The RFM95 works with 3.3V so do not connect to 5.0V, the chip will die if you do that!

Post a circuit diagram. Hand drawn is fine, Fritzing is not.

"The RFM95 works with 3.3V so do not connect to 5.0V, the chip will die if you do that!"
I'm afraid this is a myth. After the experiments, I will switch to 3V power.

I'm afraid this is a myth.

You are misinformed, and extremely unwise to not check when informed of your error.

The manufacturer's data sheet clearly states the absolute maximum voltage, which is 3.9V.

You can sometimes get away with violating the manufacturer's recommendations, but it is pretty likely that even if the chip seems to work, it has been damaged.

We've all done this accidentally, so throw it away, chalk one up to experience, and start over.

jremington:
Post a circuit diagram. Hand drawn is fine, Fritzing is not.

Transmitter and receiver LORA are working.
LoRa Connection - Atmega328 (Arduino):
NSS -16 (D10)
DIO0-4 (D2),
SCK-19 (D13)
MISO-18 (D12)
MOSI-17 (D11)
RESET-15 (D9)

jremington:
You are misinformed, and extremely unwise to not check when informed of your error.

The manufacturer's data sheet clearly states the absolute maximum voltage, which is 3.9V.

You can sometimes get away with violating the manufacturer's recommendations, but it is pretty likely that even if the chip seems to work, it has been damaged.

We've all done this accidentally, so throw it away, chalk one up to experience, and start over.

Thank!
I checked the operation of 2 chips on 3V and 5V. They work. It's easy for me to work with a 5V USB-UART converter.
Please focus on my problem. This is a high power sleep LoRa. I need help editing the wrong code.

The code is not the problem.

Cadis:
Please focus on my problem. This is a high power sleep LoRa. I need help editing the wrong code.

Waste of time, no way of knowing if there is a problem in the code, or the devices are missbehaving because they are being abused outside of specification.

A SX127x LoRa device has a sleep current of a little less than 0.1uA, which is easy to achieve when used within specification.

jremington:
The code is not the problem.

The code is being executed. But in the code without problems, the sleep current is 8 μA, and I have 2.5mA!

srnet:
Waste of time, no way of knowing if there is a problem in the code, or the devices are missbehaving because they are being abused outside of specification.

A SX127x LoRa device has a sleep current of a little less than 0.1uA, which is easy to achieve when used within specification.

I repeat - meeting the conditions of the specification does not lead to a solution to the problem. When I run the correct code from the example and Vcc=3V: Isleep = 5 мкА (LoRa+Atmega328).

I will formulate the question differently. How to write code using internal watchdog instead of external interrupts in this code?

#include "LowPower.h"
#include <SPI.h>
#include <LoRa.h>

const int wakeUpPin = 3;

void wakeUp()
{
}

void setup() {
   if (!LoRa.begin(915E6)) {
      LoRa.end();
      pinMode(LED_BUILTIN, OUTPUT);
      while (1) { 
         digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); 
         LowPower.powerDown(SLEEP_250MS, ADC_OFF, BOD_OFF);
      }
   }
   pinMode(wakeUpPin, INPUT_PULLUP);
   attachInterrupt(digitalPinToInterrupt(wakeUpPin), wakeUp, FALLING);
   LoRa.sleep();
}

void loop() {
   LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
   LoRa.idle(); 
   LoRa.beginPacket();
   LoRa.print("Hello!");
   LoRa.endPacket(); 
   LoRa.sleep();
}

When the pin 3 goes to ground, the board wakes up and send some packet and goes to sleep again.

Cadis:
I repeat - meeting the conditions of the specification does not lead to a solution to the problem. When I run the correct code from the example and Vcc=3V: Isleep = 5 мкА (LoRa+Atmega328).

You did say the devices worked at 3V and 5V, but not what the sleep currents were. And then went on to imply you were going to work the devices on 5V, despite knowing this was outside spec.

Stick to 3V, the first step should be to check the sleep current of the bare processor without the LoRa device connected, it should be 0.1uA or so.

srnet:
Stick to 3V, the first step should be to check the sleep current of the bare processor without the LoRa device connected, it should be 0.1uA or so.

I have followed your instructions. Really, current sleep LoRa < 1uA.

The problem is deeper. An Adafruit expert claims that an external timer must be used to solve the problem. Check out the discussion here. And the author of the publication “LoRa and Sleep” claims that the implementation of an internal watchdog timer is possible here together with the LowPower.h library, but does not give an example.
I plan to make a simple device without an external timer.