Open pyrotechnik opened 1 year ago
The first thing to do is to stick the error text in the decoder. This will tell you, more or less, what it causing the error.
0x400d18d7: spiTransferByteNL at /Users/davidjezek/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/cores/esp32/esp32-hal-spi.c line 782
0x400d0e9e: SPIClass::transfer(unsigned char) at /Users/davidjezek/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/SPI/src/SPI.cpp line 158
0x400d0f27: LoRaClass::singleTransfer(unsigned char, unsigned char) at /Users/davidjezek/Documents/Arduino/libraries/src/LoRa.cpp line 740
0x400d0f54: LoRaClass::readRegister(unsigned char) at /Users/davidjezek/Documents/Arduino/libraries/src/LoRa.cpp line 725
0x400d1158: LoRaClass::parsePacket(int) at /Users/davidjezek/Documents/Arduino/libraries/src/LoRa.cpp line 222
0x400d0cde: loop() at /Users/davidjezek/Documents/Arduino/lora_test_2/lora_test_2.ino line 34
0x400d21e1: loopTask(void*) at /Users/davidjezek/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/cores/esp32/main.cpp line 23
0x40086155: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
So the problem start at line 34 of your code:
int packetSize = LoRa.parsePacket();
Next step, line 222 of the lib.
int irqFlags = readRegister(REG_IRQ_FLAGS);
Then line 725.
return singleTransfer(address & 0x7f, 0x00);
Then line 740.
_spi->transfer(address);
Onwards to the Espressif BSP, file SPI.cpp
. This is a little more complicated because you are using a very old BSP, 1.06. But SPIClass::transfer
calls spiTransferByteNL
in esp32-hal-spi.c
. You'll have to check what line 782 is for you – uint8_t spiTransferByteNL(spi_t * spi, uint8_t data)
for me starts at line 1174...
But that's the hill where it's dying. An SPI issue. Could it be that it doesn't like you to play with HSPI
? Anyway that's as much as I can infer from the code and logs.
Hello
I had a similar problem. I was trying to build a simple sender and got a panic error. I solved the problem by putting the SPI object construction outside of the setup function. I think in that way it doesn't go outside of scope. I hope that it will help you.
#include <SPI.h>
// - Lora Library: https://github.com/sandeepmistry/arduino-LoRa
#include <LoRa.h>
//SPI pin
#define LoRa_SCK 36
#define LoRa_MISO 37
#define LoRa_MOSI 38
#define LoRa_SS 2
#define LoRa_RST 1 // LoRa_Reset
#define LoRa_DI0 35 // LoRa_IRQ
//initialise HSPI
SPIClass hspi(HSPI);
void setup() {
hspi.begin(LoRa_SCK, LoRa_MISO, LoRa_MOSI, LoRa_SS);
LoRa.setSPI(hspi);
LoRa.setPins(LoRa_SS, LoRa_RST, LoRa_DI0);
Serial.begin(9600);
Serial.println("LoRa Sender");
/*and 1 -> Freq. 868.0-868.6 MHz | Duty cycle 1% | Max ERP 25 mW / 14 dBm
Band 2 -> Freq. 868.7-869.2 MHz | Duty cycle 0.1% | Max ERP 25 mW / 14 dBm
Band 3 -> Freq. 869.4-869.65 MHz | Duty cycle 10% | Max ERP 500 mW / 27 dBm
Band 4 -> Freq. 869.7-870 MHz | Duty cycle 1% | Max ERP 25 mW / 14 dBm
Source : ETSI TR 103 526, Table 12, Page 35
by default:
enables explicit header mode (default)
preamble lenght is 8 by default
coding rate is 4/5 by default
spreading factor is 7 by default
bandwidth is 125kHz by default
CRC is not used by default */
LoRa.setPins(LoRa_SS, LoRa_RST, LoRa_DI0);
if (!LoRa.begin(868E6)) {
Serial.println(F("Starting LoRa failed!"));
while (1);
}
LoRa.setTxPower(12); //12 dbm default on PA_OUTPUT_PA_BOOST_PIN
LoRa.setSpreadingFactor(7); //spreading factor 7
LoRa.setSignalBandwidth(125E3); //bandwidth 125 kHz
Wire.begin(SDA_PIN, SCL_PIN);
//my other code...
}
//my other code...
The SPI initialization described by @amstaff8 didn't help in my case, still getting panics :/
After switching to a very simple routine for the onReceive function, it is working without a panic.. The cause is propably the interrupt functionality of the esp32. After digging a bit into it, the solution was to only set a flag after receiving a packet (only a small operation, not time consuming) and to process the rest (like writing to the serial pipe) in the main loop. here, you could pause the receiving (so no further interrupt will kill your routine), process data and activate the receiver after you are finished.
hi , I am doing a project about esp32 with module lora sx1278. I can't start the lora module and get an error. Help meeee! thanks for reading.
void setup() { pinMode(SS_PIN,OUTPUT); digitalWrite(SS_PIN,HIGH);
LoRa.begin(433E6); // Khởi tạo module LoRa LoRa.setPins(SS_PIN, RST_PIN, DI0_PIN); // LoRa.setSPIFrequency(433E6); Serial.begin(9600);
if (!LoRa.begin(BAND)) { Serial.println("Khởi tạo LoRa thất bại. Kiểm tra kết nối chân."); while (true); }
pinMode(LED_PIN, OUTPUT); // Thiết lập chân LED là OUTPUT }
void loop() { if (LoRa.parsePacket()) { // Kiểm tra xem có gói dữ liệu đang được nhận hay không while (LoRa.available()) { // Đọc dữ liệu trong gói String data = LoRa.readString(); Serial.println("Đã nhận dữ liệu: " + data); if(data == "bat"){ Serial.println("bat den"); digitalWrite(LED_PIN, HIGH); delay(100); // Bật LED digitalWrite(LED_PIN,LOW); } else if(data == "tat"){ Serial.println("tắt đèn"); digitalWrite(LED_PIN,LOW); } } } } Erorr:
I have problem with any example from LoRa.h. My Code:
Even if I try a simple receiver, the result is always the same.
The error code is as follows:
I don't know where to look for the error. I will be glad for any idea. Thank you