Here is the sample code I am running, I have removed the AMG8833 libs and readings for the moment. At the start of the loop that line will print every cycle even when its in sleep mode. I would have thought that when it went in to sleep mode it would not print until the next wake cycle.
On the other example prior to using the LoRaWAN.Sleep(); and using the timer to wake up it seems to work.
#include “LoRaWan_APP.h”
#include “Arduino.h”
const char myDevEui[] = { 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x** };
const char myAppEui[] = { 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x** };
const char myAppKey[] = { 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x** };
#ifndef LORAWAN_CLASS
#define LORAWAN_CLASS CLASS_A
#endif
#ifndef ACTIVE_REGION
#define ACTIVE_REGION REGION_AU915
#endif
#ifndef LORAWAN_NETMODE
#define LORAWAN_NETMODE OTAA
#endif
/LoraWan Class/
DeviceClass_t CLASS=LORAWAN_CLASS;
/OTAA or ABP/
bool OVER_THE_AIR_ACTIVATION = LORAWAN_NETMODE;
/ADR enable/
bool LORAWAN_ADR_ON = LORAWAN_ADR;
/* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */
bool KeepNet = LORAWAN_Net_Reserve;
/LoraWan REGION/
LoRaMacRegion_t REGION = ACTIVE_REGION;
/* Indicates if the node is sending confirmed or unconfirmed messages */
bool IsTxConfirmed = false;
uint8_t ConfirmedNbTrials = 8;
/* Application port */
uint8_t AppPort = 2;
/the application data transmission duty cycle. value in [ms]./
uint32_t APP_TX_DUTYCYCLE = 60000; //15000;
extern uint8_t DevEui[];
extern uint8_t AppEui[];
extern uint8_t AppKey[];
/* Prepares the payload of the frame */
static void PrepareTxFrame( uint8_t port ){
digitalWrite(Vext, HIGH);
AppDataSize = 13;//AppDataSize max value is 64
uint16_t BatteryVoltage = GetBatteryVoltage();
AppData[0] = (uint8_t)(BatteryVoltage >> 8);
AppData[1] = (uint8_t)BatteryVoltage;
//AMG8833 Data Goes Here but has been removed for testing purposes.
//data1
AppData[2] = 0x10;
AppData[3] = 0x10;
//data2
AppData[4] = 0x20;
AppData[5] = 0x20;
//data3
AppData[6] = 0x30;
AppData[7] = 0x30;
//data4
AppData[8] = 0x40;
AppData[9] = 0x40;
//data5
AppData[10] = 0xF0;
AppData[11] = 0x0F;
//data6
AppData[12] = 0xA1;
AppData[13] = 0x0A;
}
void setup() {
memcpy(DevEui, myDevEui, sizeof(myDevEui)); //Add these 3 lines to setup func
memcpy(AppEui, myAppEui, sizeof(myAppEui));
memcpy(AppKey, myAppKey, sizeof(myAppKey));
BoardInitMcu();
Serial.begin(115200);
#if(AT_SUPPORT)
Enable_AT();
#endif
DeviceState = DEVICE_STATE_INIT;
LoRaWAN.Ifskipjoin();
}
void loop()
{
Serial.println(“anyting in here prints every loop regardless of sleep”);
switch( DeviceState )
{
case DEVICE_STATE_INIT:
{
#if(AT_SUPPORT)
getDevParam();
#endif
printDevParam();
Serial.printf(“LoRaWan Class%X start! \r\n”,CLASS+10);
LoRaWAN.Init(CLASS,REGION);
DeviceState = DEVICE_STATE_JOIN;
break;
}
case DEVICE_STATE_JOIN:
{
LoRaWAN.Join();
break;
}
case DEVICE_STATE_SEND:
{
PrepareTxFrame( AppPort );
//^^^ this turns on the AMG8833 and prepares the data
LoRaWAN.Send();
DeviceState = DEVICE_STATE_CYCLE;
break;
}
case DEVICE_STATE_CYCLE:
{
// Schedule next packet transmission
TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND );
LoRaWAN.Cycle(TxDutyCycleTime);
DeviceState = DEVICE_STATE_SLEEP;
break;
}
case DEVICE_STATE_SLEEP:
{
LoRaWAN.Sleep();
break;
}
default:
{
DeviceState = DEVICE_STATE_INIT;
break;
}
}
}