chandrawi / LoRaRF-Arduino

Arduino library for basic transmitting and receiving data using LoRa and FSK modulation
MIT License
53 stars 15 forks source link

Esp8266 ESP32 cannot use lorarf Library #5

Closed yaniot closed 1 year ago

yaniot commented 2 years ago

When using lorarf, use the SPI pins of esp8266 and esp32. When uploading sketches, the esp8266 door opener is turned on, esp32 has no response, and Arduino nano can be used.

Operating environment: Esp8266 uses nodemcu 0.9 Esp32 uses esp32 dev module Arduino IDE 1.8.19 LoRaRF library 2.0.0

LSC862 commented 1 year ago

Have you solved the problem now?I tried to add print to.cpp and.h, and found that the function in app.h does not seem to work, it seems that there is no write and read function in SPI, _write/_readBytes mentioned in app.h seems not to be the method in spi.h. I don't know if I'm right. If you have solved it, could you please send a demo to me for study? Thank you for your

chandrawi commented 1 year ago

Dear Yanqisui,

I'm sorry I have not solved the SPI library problem yet. But I have a suggestion to fix the SPI connection to the LoRa module problem. The default SPI frequency in SX127x.h and SX126x.h are half of CPU frequency. You can check the SPI frequency in SX127x.h at this link https://github.com/chandrawi/LoRaRF-Arduino/blob/main/src/SX127x.h at line #128 and SX126x in this link https://github.com/chandrawi/LoRaRF-Arduino/blob/main/src/SX126x.h at line #236.

ESP32 have CPU frequency up to 80 Mhz, so the SPI frequency is 40 Mhz which is higher than maximum LoRa can handle (16 Mhz). So to overcome the problem you should adjust the SPI frequency with setSPI() method before begin() method. See the code below.

include

SX127x LoRa; void setup() { LoRa.setSPI(SPI, 16000000); int8_t nssPin = 10, resetPin = 9, irqPin = -1, txenPin = 8, rxenPin = 7; LoRa.begin(nssPin, resetPin, irqPin, txenPin, rxenPin); // other LoRa setup code goes here }

Notice the SPI in the first argument setSPI() method is an SPIClass instance, you must set the instance to match SPI bus connected to the LoRa module.

Regards, Chandra Sentosa

On Tue, Jul 19, 2022 at 12:14 AM LSC862 @.***> wrote:

Have you solved the problem now?I tried to add print to.cpp and.h, and found that the function in app.h does not seem to work, it seems that there is no write and read function in SPI, _write/_readBytes mentioned in app.h seems not to be the method in spi.h. I don't know if I'm right. If you have solved it, could you please send a demo to me for study? Thank you for your

— Reply to this email directly, view it on GitHub https://github.com/chandrawi/LoRaRF-Arduino/issues/5#issuecomment-1187803296, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR5MCKUFWVR4H4BA5UEH7ULVUWGGLANCNFSM52QOHSMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

chandrawi commented 1 year ago

I try the suggestion by changing the default SPI speed and it is works. I just upload new 2.1.0 version. Now LoRaRF library works on ESP32 and ESP8266.

chandrawi commented 1 year ago

Dear Yanqisui,

There is issue using LoRaRF library with ESP32 and ESP8266. The issue is SPI bus Arduino library compatibility. I am working around this issue. Hopefully LoRaRF library will support ESP32 soon.

The microcontroller supported by LoRaRF library are ATmega based Arduino (Uno, nano, pro mini) and STM32duino.

Regards,

On Sun, Jul 3, 2022, 6:03 PM @yanqisui @.***> wrote:

When using lorarf, use the SPI pins of esp8266 and esp32. When uploading sketches, the esp8266 door opener is turned on, esp32 has no response, and Arduino nano can be used.

Operating environment: Esp8266 uses nodemcu 0.9 Esp32 uses esp32 dev module Arduino IDE 1.8.19 LoRaRF library 2.0.0

— Reply to this email directly, view it on GitHub https://github.com/chandrawi/LoRaRF-Arduino/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR5MCKSVU4KIG6WUCTAOHW3VSFQODANCNFSM52QOHSMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>