I am using the HTCC-AB02A to send LoRa data. Then I put the board into deep sleep.
After the command ‘Radio.Sleep( );’ I have to pause for 3 seconds, otherwise the command ‘lowPowerHandler();’ will not work and the board will not go into deep sleep.
Is there any way around the problem?
code:
/* Heltec Automation send communication test example * * Function: * 1. Send data from a CubeCell device over hardware * * * this project also realess in GitHub: * https://github.com/HelTecAutomation/ASR650x-Arduino * */ #include "LoRaWan_APP.h" #include "Arduino.h" /* * set LoraWan_RGB to 1,the RGB active in loraWan * RGB red means sending; * RGB green means received done; */ #ifndef LoraWan_RGB #define LoraWan_RGB 0 #endif #define RF_FREQUENCY 868000000 // Hz #define TX_OUTPUT_POWER 14 // dBm #define LORA_BANDWIDTH 0 // [0: 125 kHz, // 1: 250 kHz, // 2: 500 kHz, // 3: Reserved] #define LORA_SPREADING_FACTOR 7 // [SF7..SF12] #define LORA_CODINGRATE 1 // [1: 4/5, // 2: 4/6, // 3: 4/7, // 4: 4/8] #define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx #define LORA_SYMBOL_TIMEOUT 0 // Symbols #define LORA_FIX_LENGTH_PAYLOAD_ON false #define LORA_IQ_INVERSION_ON false #define RX_TIMEOUT_VALUE 1000 #define BUFFER_SIZE 30 // Define the payload size here #define SLEEP_TIME 3600000 // 1 hour static TimerEvent_t DeepSleep; char txPacket[BUFFER_SIZE]; static RadioEvents_t RadioEvents; void setup() { // Serial monitor at 115200 baud Serial.begin(115200); // Pin pinMode(Vext,OUTPUT); // init LoRa module Radio.Init( &RadioEvents ); Radio.SetChannel( RF_FREQUENCY ); Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH, LORA_SPREADING_FACTOR, LORA_CODINGRATE, LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON, true, 0, 0, LORA_IQ_INVERSION_ON, 3000 ); Radio.SetSyncWord(0x12); } void loop() { // Battery uint16_t voltage = getBatteryVoltage(); sprintf(txPacket,"%s","/Zisterne/Batterie="); sprintf(txPacket+strlen(txPacket),"%d",voltage); Serial.printf("\rsending packet \"%s\" , length %d\r\n",txPacket, strlen(txPacket)); Radio.Send( (uint8_t *)txPacket, strlen(txPacket) ); // send the package out // Sensor digitalWrite(Vext, LOW); // sensor power on delay(100); uint16_t level=analogRead(ADC2); digitalWrite(Vext, HIGH); // sensor power off sprintf(txPacket,"%s","/Zisterne/Level="); sprintf(txPacket+strlen(txPacket),"%d",level); Serial.printf("\rsending packet \"%s\" , length %d\r\n",txPacket, strlen(txPacket)); Radio.Send( (uint8_t *)txPacket, strlen(txPacket) ); // send the package out Radio.Sleep( ); // aktivate sleep for LORA // go back to deep sleep mode TimerSetValue( &DeepSleep, SLEEP_TIME ); TimerStart( &DeepSleep ); delay(3000); //??????? lowPowerHandler(); }