sandeepmistry / arduino-LoRa

An Arduino library for sending and receiving data using LoRa radios.
MIT License
1.6k stars 621 forks source link

Use LoRa Radio and WiFi together #534

Open atharvapashankar opened 2 years ago

atharvapashankar commented 2 years ago

Hello,

I am trying to use LoRa Radio and WiFi together on Heltec WiFi Lora 32 V2. There will be two nodes :- end node and Main station End node is used for collecting the data using BME 680 sensor End node collects the data and sends to the Main station using LoRa radio (LoRa library) Final station receives the data and sends to AWS using MQTT protocol (PubSub library)

Problem:- I am receiving the data on the receiver side but I am not able to publish to AWS as it throws error

Guru Meditation Error: Core  1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC      : 0x4008c254  PS      : 0x00060f34  A0      : 0x8008b46f  A1      : 0x3ffbfa30
A2      : 0x3ffcc3d0  A3      : 0x3ffb8074  A4      : 0x00000001  A5      : 0x00000001  
A6      : 0x00060f23  A7      : 0x00000000  A8      : 0x3ffb8074  A9      : 0x3ffb8074
A10     : 0x00000018  A11     : 0x00000018  A12     : 0x00000001  A13     : 0x00000001  
A14     : 0x00060f21  A15     : 0x00000000  SAR     : 0x00000010  EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff  
Core 1 was running in ISR context:
EPC1    : 0x4013d15f  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x4008c254

ELF file SHA256: 0000000000000000

Backtrace: 0x4008c254:0x3ffbfa30 0x4008b46c:0x3ffbfa50 0x40089787:0x3ffbfa70 0x4013d0dd:0x3ffbfab0 0x4013dba7:0x3ffbfad0 0x4013d425:0x3ffbfb00 0x4013d8b9:0x3ffbfb20 0x40134017:0x3ffbfb60 0x40134ab1:0x3ffbfbe0 0x40134b42:0x3ffbfc10 0x401529cd:0x3ffbfc30 0x4000bdbb:0x3ffbfc50 0x400017ea:0x3ffbfc70 0x40128c09:0x3ffbfc90 0x40118229:0x3ffbfcc0 0x4011a003:0x3ffbfce0 0x4011a075:0x3ffbfd00 0x4011a516:0x3ffbfd20 0x400d3ef2:0x3ffbfd40 0x400d35dd:0x3ffbfd60 0x400d3551:0x3ffbfd80 0x40165936:0x3ffbfda0 0x40165865:0x3ffbfdd0 0x400d234b:0x3ffbfdf0 0x400d23d1:0x3ffbfe10 0x400d103e:0x3ffbfe30 0x400d16bf:0x3ffbfec0 0x40080fb1:0x3ffbfee0 0x40080ffd:0x3ffbff00 0x40086fe5:0x3ffbff20 0x4000d06f:0x3ffb1f40 0x4008127f:0x3ffb1f60 0x400d0b89:0x3ffb1f80 0x400d5d6c:0x3ffb1fb0 0x4008994e:0x3ffb1fd0

Core 0 register dump:
PC      : 0x4008a952  PS      : 0x00060234  A0      : 0x8008baad  A1      : 0x3ffb3db0  
A2      : 0x3ffbf300  A3      : 0x0000cdcd  A4      : 0xb33fffff  A5      : 0x00000001
A6      : 0x00060223  A7      : 0x0000abab  A8      : 0x0000abab  A9      : 0x80000020  
A10     : 0x00000003  A11     : 0x00060623  A12     : 0x00000005  A13     : 0x00000020
A14     : 0x00000020  A15     : 0x00000000  SAR     : 0x00000019  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff

ELF file SHA256: 0000000000000000

Backtrace: 0x4008a952:0x3ffb3db0 0x4008baaa:0x3ffb3de0 0x400896ef:0x3ffb3e00 0x4013d006:0x3ffb3e40 0x4013d2f4:0x3ffb3e60 0x4013efea:0x3ffb3e80 0x4013da15:0x3ffb3ea0 0x4008994e:0x3ffb3ed0

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8

Code snippet:-

void onReceive(int packetSize) {
  if (packetSize == 0) return;          // if there's no packet, return

  byte sender = LoRa.read();            // sender address

  byte incomingLength = LoRa.read();    // incoming msg length

  String incoming = "";                 // payload of packet

  while (LoRa.available()) {            // can't use readString() in callback, so
    incoming += (char)LoRa.read();      // add bytes one by one
  }

  if (incomingLength != incoming.length()) {   // check length for error
    Serial.println("error: message length does not match length");
    return;                             // skip rest of function
  }

  if (destination != sender) {
    Serial.println("This message is not for me.");
    return;                             // skip rest of function
  }

  Serial.println("Received from: 0x" + String(sender, HEX));

  Serial.println("Message length: " + String(incomingLength));
  Serial.println("Message: " + incoming);
  Serial.println("RSSI: " + String(LoRa.packetRssi()));
  Serial.println();
  if(incoming){
    flag = true;
  }

  delay(10*1000);

   pubSubClient.publish(topic, incoming.c_str());

  /*
  pubSubCheckConnect();
    String msg = "T:";
  msg += String(incoming);
  boolean rc = pubSubClient.publish(topic, msg.c_str());
  Serial.print("Published, rc="); 
    Serial.print( (rc ? "OK: " : "FAILED: ") );
    Serial.println(msg);

  */
}

Please do help me

IoTThinks commented 2 years ago

Never process heavy stuffs in ISR onReceive(). Actually, inside ISR onReceive, it is recommended to set a flag only.

Then in loop you check for the flag, process and send to MQTT/AWS.