Problem:
I have problem about ESP32+Lora SX1276 connect with gateway and connect with server ChirpStack by writing firmware send uplink every 1 min. After that, ESP32 +Lora SX1276 not sending uplink then i add watchdog firmware for reset. The result sending uplink again.
Question:
I need to know why ESP32+Lora SX1276 stop sending uplink??
This action, i cannot prove, please help me to solve.
What kit are you using?
What libraries for your firmware?
I see you opened a thread on the esp32 forum which is a better place to get help unless one knows and has used the same kit and libraries here. They will be interested to know the exact kit and libraries to be able point you in the right direction.
The firmware library forum would be the next place to get help.
I use ESP32-WROOM-32E + Lora sx1276 SEMTECH, and send data to Chirpstack and using the gateway by setting 923MHz Lora end node module.
The library use "lmic.h", and can see the firmware for send data uplink and downlink.
void printHex2(unsigned v) {
v &= 0xff;
if (v < 16)
Serial.print(â0â);
Serial.print(v, HEX);
}
void onEvent (ev_t ev) {
Serial.print(os_getTime());
Serial.print(": ");
switch(ev) {
case EV_SCAN_TIMEOUT:
Serial.println(F(âEV_SCAN_TIMEOUTâ));
break;
case EV_BEACON_FOUND:
Serial.println(F(âEV_BEACON_FOUNDâ));
break;
case EV_BEACON_MISSED:
Serial.println(F(âEV_BEACON_MISSEDâ));
break;
case EV_BEACON_TRACKED:
Serial.println(F(âEV_BEACON_TRACKEDâ));
break;
case EV_JOINING:
Serial.println(F(âEV_JOININGâ));
break;
case EV_JOINED:
Serial.println(F(âEV_JOINEDâ));
{
u4_t netid = 0;
devaddr_t devaddr = 0;
u1_t nwkKey[16];
u1_t artKey[16];
LMIC_getSessionKeys(&netid, &devaddr, nwkKey, artKey);
Serial.print("netid: ");
Serial.println(netid, DEC);
Serial.print(âdevaddr: â);
Serial.println(devaddr, HEX);
Serial.print(âAppSKey: â);
for (size_t i=0; i<sizeof(artKey); ++i) {
if (i != 0)
Serial.print(â-â);
printHex2(artKey[i]);
}
Serial.println(ââ);
Serial.print(âNwkSKey: â);
for (size_t i=0; i<sizeof(nwkKey); ++i) {
if (i != 0)
Serial.print(â-â);
printHex2(nwkKey[i]);
}
Serial.println();
}
LMIC_setLinkCheckMode(0);
break;
case EV_JOIN_FAILED:
Serial.println(F("EV_JOIN_FAILED"));
break;
case EV_REJOIN_FAILED:
Serial.println(F("EV_REJOIN_FAILED"));
break;
case EV_TXCOMPLETE:
Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
if (LMIC.txrxFlags & TXRX_ACK)
Serial.println(F("Received ack"));
if (LMIC.dataLen) {
Serial.print(F("Data Received: "));
String dpayload = "";
char temp[3];
for(uint8_t i=0;i<LMIC.dataLen;i++)
{
// Serial.println(i);
Serial.print(LMIC.frame[LMIC.dataBeg + i], HEX);
// sprintf(temp, "%02x", LMIC.frame[LMIC.dataBeg + i]);
sprintf(temp ,"%x", LMIC.frame[LMIC.dataBeg + i]);
dpayload = String(dpayload) + String(temp);
}
Serial.println(dpayload);
Serial.println();
if(dpayload != ""){
pinMode(arr_relaypin[1], OUTPUT);
pinMode(arr_relaypin[2], OUTPUT);
pinMode(arr_relaypin[3], OUTPUT);
pinMode(arr_relaypin[4], OUTPUT);
dpayload = dpayload.substring(0, 12);
if (dpayload.length() == 12) {
String cmd_status = String(dpayload.substring(1, 2)) + String(dpayload.substring(3, 4));
String cmd_pin = dpayload.substring(5, 6) + dpayload.substring(7, 8);
String cmd_time = dpayload.substring(9, 10) + dpayload.substring(11, 12);
int pin = cmd_pin.toInt();
long timedelay = cmd_time.toInt() * 1000* 60 ;
if(cmd_status =="01"){
for(int i = 1; i <= arr_size; i++){
Serial.print(String(i) + ". Pin "+String(arr_relaypin[i])+ " Status: ");
Serial.println(digitalRead(arr_relaypin[i]));
sprintf(tmp,"%02d",digitalRead(arr_relaypin[i]));
}
}else if(cmd_status =="02"){
if(cmd_pin=="99"){
Serial.println("Payload: " + dpayload);
Serial.println("Relay No: BOTH");
Serial.println("Turn On...");
for(int i = 1; i<= arr_size; i++){
digitalWrite(arr_relaypin[i], HIGH);
}
Serial.print("Delay: ");
Serial.print(timedelay);
Serial.println(" ms");
delay( timedelay );
for(int i = 1; i<= arr_size; i++){
digitalWrite(arr_relaypin[i], LOW);
}
Serial.println("Turn Off...");
}else{
Serial.println("Payload: " + dpayload);
Serial.print("Relay No: ");
Serial.println(pin);
Serial.print("Pin: ");
Serial.println(arr_relaypin[pin]);
Serial.println("Turn On...");
digitalWrite(arr_relaypin[pin], HIGH);
Serial.print("Delay: ");
Serial.print(timedelay);
Serial.println(" ms");
delay( timedelay );
digitalWrite(arr_relaypin[pin], LOW);
Serial.println("Turn Off...");
}
}
}else{
Serial.println("!! Package Lost : Payload Error !!");
Serial.print("Payload: ");
Serial.println(dpayload);
}
}
Serial.println();
}
esp_task_wdt_reset();
os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
break;
case EV_LOST_TSYNC:
Serial.println(F("EV_LOST_TSYNC"));
break;
case EV_RESET:
Serial.println(F("EV_RESET"));
break;
case EV_RXCOMPLETE:
// data received in ping slot
Serial.println(F("EV_RXCOMPLETE"));
break;
case EV_LINK_DEAD:
Serial.println(F("EV_LINK_DEAD"));
break;
case EV_LINK_ALIVE:
Serial.println(F("EV_LINK_ALIVE"));
break;
/*
|| This event is defined but not used in the code. No
|| point in wasting codespace on it.
||
|| case EV_SCAN_FOUND:
|| Serial.println(F("EV_SCAN_FOUND"));
|| break;
*/
case EV_TXSTART:
Serial.println(F("EV_TXSTART"));
break;
case EV_TXCANCELED:
Serial.println(F("EV_TXCANCELED"));
break;
case EV_RXSTART:
/* do not print anything -- it wrecks timing */
break;
case EV_JOIN_TXCOMPLETE:
Serial.println(F("EV_JOIN_TXCOMPLETE: no JoinAccept"));
break;
default:
Serial.print(F("Unknown event: "));
Serial.println((unsigned) ev);
break;
}
}
void do_send(osjob_t* j){
// Check if there is not a current TX/RX job running
if (LMIC.opmode & OP_TXRXPEND) {
Serial.println(F(âOP_TXRXPEND, not sendingâ));
} else {
// Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(22, mydata, sizeof(mydata)+4, 0);
Serial.println(F(âPacket queuedâ));
}
}