this code works perfectly if connected with usb cable. but as soon as i connect my Arduino nano with battery (two 18650 batteries in series connected to VIN) it runs loop only once. it sends only 0 to another LoRa module (3.3v) and i assume it runs loop only once. blink works without a problem.
#include <SPI.h>
#include <LoRa.h>
int counter = 0;
void setup() {
Serial.begin(9600);
Serial.println("LoRa Sender");
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
}
void loop() {
Serial.print("Sending packet: ");
Serial.println(counter);
// send packet
LoRa.beginPacket();
LoRa.print(counter);
LoRa.endPacket();
counter ++;
delay(3000);
}
Edit
battery pack voltage is 7.01v.
connections I've tried so far:
- 2x 18650 -> VIN = Does not work
- 2x 18650 + regulator -> 5v = Does not work
- 2x 18650 + regulator -> USB = Does work
- USB -> USB = Of course works
when I say it works I mean it Arduino powers up and LoRa module sends data but only once and looks like loop is running only once.