Hello!
Begginer here, I'm trying to sense temperature and humidity with an Adafruit SHTC3 connected to an Arduino MKR WAN 1300, and then send that data to The Things Network. No problem with that, the network is configured correctly and the data is sent from my Arduino using LoRa every 10 min (it senses, goes into sleep mode, and wakes up when it needs to sense again) and received correctly from TTN.
But power consumption was too large in sleep mode, so I bought a TPL5110 to try and replicate this: GitHub - AmedeeBulle/TTNMkrWanNode: Ultra Low Power with Arduino MKR WAN
My problem is, when I try to do this, communication starts, but the message won't reach TTN. The live data stream will look like this:
Only if I add a delay of ~10s after the package is sent and before I activate the TPL to "power off" the Arduino, the message reaches its destination. Any idea why this happens or how could I get it to work without that delay so I can minimize power consumption? This is my code with the delay:
// Importacion de librerias
#include <MKRWAN.h>
#include "Adafruit_SHTC3.h"
// Instancia de objetos
Adafruit_SHTC3 shtc3 = Adafruit_SHTC3(); // Permite interaccion con el sensor SHTC3
LoRaModem LoRa; // Permite configuracion y control de la comunicacion LoRa
// Configuracion de los parametros de LoRa en TTN
String appEui = ""; // EUI de la aplicacion en TTN
String appKey = ""; // Key de la aplicacion en TTN
// Declaracion de variables para el temporizador del programa
//const unsigned long interval = 600000; // Constante que representa el intervalo de tiempo antes de realizar nuevo envio de datos (en milisegundos; 10000ms = 10s)
sensors_event_t humidity, temp; // Se capturan los datos de temperatura y humedad
const byte pinDone = 7; // Pin conectado al TPL5110
// Configuracion inicial
void setup() {
pinMode(pinDone, OUTPUT);
// Configuracion e inicializacion del modulo en la region EU868 (UE)
if (!LoRa.begin(EU868)) { // Se verifica la iniciacion del modulo
while (1);
}
if (!LoRa.joinOTAA(appEui, appKey)) { // Se verifica la iniciacion del modulo
while (1);
}
LoRa.setPort(3); // Se configura el puerto LoRa 3
// Inicializacion del sensor SHTC3
if (!shtc3.begin()) { // Verificacion de la inicializacion del sensor
while (1); // Bucle infinito para detener la ejecucion del programa si se produjo un error en la inicializacion del sensor
}
}
void loop() {
SenseAndSend();
delay(12000);
GoToSleep();
}
void SenseAndSend() {
shtc3.getEvent(&humidity, &temp); // El resultado de la medida se almacena en la variable result
String message = "Temperatura: " + String(temp.temperature) + ", Humedad relativa: " + String(humidity.relative_humidity);
// Se envia la cadena a traves de LoRa
LoRa.beginPacket(); // Inicializacion de un paquete LoRa
LoRa.print(message); // Se envia la cadena a traves de LoRa
LoRa.endPacket();
LoRa.sleep();
}
void GoToSleep(){
//LowPower.idle(interval);
digitalWrite(pinDone, LOW);
delay(1);
digitalWrite(pinDone, HIGH);
delay(1);
}
appEui and Key are left blank on purpose to upload it here