nopnop2002 / esp-idf-sx126x

SX1262/SX1268/LLCC68 Low Power Long Range Transceiver driver for esp-idf
MIT License
79 stars 18 forks source link

Error (RA01S: SetRx Illegal Status) while using RA01S library for Heltec LoRa V3 #20

Open Surbhidk opened 1 year ago

Surbhidk commented 1 year ago

Hello , I am also facing same issue regarding SX1262 lora library. I am using Heltec Wi-Fi esp32 Lora V3 . For IDE I am using : VS-code ESP IDF Extension Here is my logs I (280) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. I (300) RA01S: CONFIG_MISO_GPIO=11 I (300) RA01S: CONFIG_MOSI_GPIO=10 I (300) RA01S: CONFIG_SCLK_GPIO=9 I (310) RA01S: CONFIG_NSS_GPIO=8 I (310) RA01S: CONFIG_RST_GPIO=12 I (320) RA01S: CONFIG_BUSY_GPIO=13 I (320) RA01S: CONFIG_TXEN_GPIO=-1 I (320) RA01S: CONFIG_RXEN_GPIO=-1 I (330) gpio: GPIO[8]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (340) gpio: GPIO[12]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (350) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (360) RA01S: spi_bus_initialize=0 I (360) RA01S: spi_bus_add_device=0 I (400) RA01S: Reset I (400) RA01S: ReadRegister: REG=0x740 I (400) RA01S: DataIn:14 I (400) RA01S: DataIn:24 I (410) RA01S: syncWord=0x1424 I (410) RA01S: SX126x installed I (410) RA01S: WriteCommand: CMD=0x80 I (420) RA01S: 00 --> aa W (420) RA01S: WriteCommand2 status=0a retry=1 I (430) RA01S: WriteCommand: CMD=0x80 I (430) RA01S: 00 --> a2 I (430) RA01S: WriteCommand: CMD=0x9d I (440) RA01S: 01 --> a2 I (440) RA01S: tcxoVoltage=0.000000 I (450) RA01S: WriteCommand: CMD=0x89 I (450) RA01S: 7f --> a2 I (450) RA01S: useRegulatorLDO=0 I (460) RA01S: WriteCommand: CMD=0x96 I (460) RA01S: 01 --> aa W (460) RA01S: WriteCommand2 status=0a retry=1 I (470) RA01S: WriteCommand: CMD=0x96 I (470) RA01S: 01 --> a2 I (480) RA01S: WriteCommand: CMD=0x8f I (480) RA01S: 00 --> a2 I (490) RA01S: 00 --> a2 I (490) RA01S: WriteCommand: CMD=0x95 I (490) RA01S: 04 --> a2 I (500) RA01S: 07 --> a2 I (500) RA01S: 00 --> a2 I (500) RA01S: 01 --> a2 I (510) RA01S: WriteRegister: REG=0x8e7 I (510) RA01S: 18 --> a2 I (510) RA01S: WriteCommand: CMD=0x8e I (520) RA01S: 16 --> a2 I (520) RA01S: 04 --> a2 I (520) RA01S: WriteCommand: CMD=0x98 I (530) RA01S: a2 --> a2 I (530) RA01S: 00 --> a2 I (540) RA01S: WriteCommand: CMD=0x86 I (540) RA01S: 00 --> aa W (540) RA01S: WriteCommand2 status=0a retry=1 I (550) RA01S: WriteCommand: CMD=0x86 I (550) RA01S: 00 --> a2 I (560) RA01S: 00 --> a2 I (560) RA01S: 00 --> a2 I (560) RA01S: 00 --> a2 I (560) MAIN: LoRaBegin=0 I (570) RA01S: SetStopRxTimerOnPreambleDetect enable=0 I (570) RA01S: WriteCommand: CMD=0x9f I (580) RA01S: 00 --> a2 I (580) RA01S: WriteCommand: CMD=0xa0 I (590) RA01S: 00 --> a2 I (590) RA01S: WriteCommand: CMD=0x8a I (590) RA01S: 01 --> a2 I (600) RA01S: WriteCommand: CMD=0x8b I (600) RA01S: 07 --> a2 I (600) RA01S: 04 --> a2 I (610) RA01S: 01 --> a2 I (610) RA01S: 00 --> a2 I (610) RA01S: ReadRegister: REG=0x736 I (620) RA01S: DataIn:0d I (620) RA01S: WriteRegister: REG=0x736 I (630) RA01S: 0d --> a2 I (630) RA01S: WriteCommand: CMD=0x8c I (630) RA01S: 00 --> a2 I (640) RA01S: 08 --> a2 I (640) RA01S: 00 --> a2 I (640) RA01S: ff --> a2 I (650) RA01S: 01 --> a2 I (650) RA01S: 00 --> a2 I (650) RA01S: WriteCommand: CMD=0x08 I (660) RA01S: 03 --> a2 I (660) RA01S: ff --> a2 I (660) RA01S: 00 --> a2 I (670) RA01S: 00 --> a2 I (670) RA01S: 00 --> a2 I (670) RA01S: 00 --> a2 I (680) RA01S: 00 --> a2 I (680) RA01S: 00 --> a2 I (680) RA01S: ----- SetRx timeout=16777215 I (690) RA01S: WriteCommand: CMD=0x80 I (690) RA01S: 00 --> a2 I (700) RA01S: SetRxEnable:SX126x_TXEN=-1 SX126x_RXEN=-1 I (700) RA01S: WriteCommand: CMD=0x82 I (710) RA01S: ff --> a2 I (710) RA01S: ff --> a2 I (710) RA01S: ff --> a2 I (720) RA01S: ReadCommand: CMD=0xc0 I (720) RA01S: DataIn:2a I (720) RA01S: ReadCommand: CMD=0xc0 I (730) RA01S: DataIn:2a I (730) RA01S: ReadCommand: CMD=0xc0 I (730) RA01S: DataIn:2a I (740) RA01S: ReadCommand: CMD=0xc0 I (740) RA01S: DataIn:2a I (750) RA01S: ReadCommand: CMD=0xc0 I (750) RA01S: DataIn:2a I (750) RA01S: ReadCommand: CMD=0xc0 I (760) RA01S: DataIn:2a I (760) RA01S: ReadCommand: CMD=0xc0 I (760) RA01S: DataIn:2a I (770) RA01S: ReadCommand: CMD=0xc0 I (770) RA01S: DataIn:2a I (780) RA01S: ReadCommand: CMD=0xc0 I (780) RA01S: DataIn:2a I (780) RA01S: ReadCommand: CMD=0xc0 I (790) RA01S: DataIn:2a I (790) RA01S: ReadCommand: CMD=0xc0 I (790) RA01S: DataIn:2a E (800) RA01S: SetRx Illegal Status E (800) RA01S: LoRaErrorDefault=18

Please suggest me the possible solution

nopnop2002 commented 1 year ago

Option with SX1262/1268

LoRa modules with SX1262/1268 have several options.

You need to look at the schematic to set these options properly, but it's very esoteric.
The default settings for this library are for Ra-01S / Ra-01SH.
When using other than Ra-01S / Ra-01SH, you need to set them appropriately.

Surbhidk commented 1 year ago

yeah.. got it . now its working for me Changes i have done :- Kconfig.projbuild:

config USE_TCXO
    bool "Enable TCXO"
    default false
    help
        Enable TCXO.

LoRaInit();
//int ret = LoRaBegin(915000000, 22, 0.0, false);
int8_t txPowerInDbm = 22;
float tcxoVoltage = 0.0; // don't use TCXO
bool useRegulatorLDO = false; // use only LDO in all modes

if CONFIG_USE_TCXO // Use external tcxo at 3.3v alimentation.

tcxoVoltage = 3.3; // use TCXO
useRegulatorLDO = true; // use TCXO

endif

//LoRaDebugPrint(true);
int ret = LoRaBegin(frequencyInHz, txPowerInDbm, tcxoVoltage, useRegulatorLDO);
ESP_LOGI(TAG, "LoRaBegin=%d", ret);         
Surbhidk commented 1 year ago

Now, I have one more question: How do I create a mesh connection in this?

nopnop2002 commented 1 year ago

Unfortunately this library does not support meshes.

Your PR is welcome.

Surbhidk commented 1 year ago

In lora chip SX1276 , it can receive multiple device data. Is there any changes to make for SX1262 library for SX1276 is https://github.com/nopnop2002/esp-idf-sx127x

My logs for SX1272 : I (209458) task_tx: 11 byte packet sent... Sent data=456!! 20910 Received Data :123!! 21322 Received Data :894 7768 I (211518) task_tx: 11 byte packet sent... Sent data=456!! 21116 Received Data :123!! 21528 Received Data :894 7972 I (213578) task_tx: 11 byte packet sent... Sent data=456!! 21322 Received Data :123!! 21734 Received Data :894 8176 I (215638) task_tx: 11 byte packet sent... Sent data=456!! 21528 Received Data :123!! 21940 Received Data :894 8380

Could you please check the Lora receive function of both lora chip and inform me about the respective changes?

nopnop2002 commented 1 year ago

I don't quite understand your problem.

Surbhidk commented 1 year ago

I am using two LoRa chips, SX1276 and SX1262. In the SX1276 code, it can receive data from two devices simultaneously, as shown in the above logs. However, when I try the same with the SX1262, it only receives data from one device at a time.

nopnop2002 commented 1 year ago

I will investigate.

Surbhidk commented 1 year ago

Hello , Do you how to convert rssi to distance . Any formula?

nopnop2002 commented 1 year ago

@Surbhidk

rssi has nothing to do with distance.

RSSI changes depending on antenna performance, etc.

Surbhidk commented 1 year ago

Then how to calculate distance between two lora device ? Can we do that ?

nopnop2002 commented 1 year ago

We can't.

ABHITHLALC commented 8 months ago

@nopnop2002 I'm facing the same issue trying to use this code with my SX1262 LoRa module, the Waveshare Core SX1262-868, and an ESP32 using the ESP-IDF framework. Can I use this library for my module? If yes, how can I adapt it? What should be the pin configuration? Any help would be greatly appreciated.

nopnop2002 commented 8 months ago

Can I use this library for my module?

I don't have Waveshare Core SX1262-868. I'm not sure if this repository will work properly.

What should be the pin configuration?

Check the documentation provided by the manufacturer.

LoRa modules with SX1262/1268 have several options.

You need to look at the schematic to set these options properly, but it's very esoteric.

ABHITHLALC commented 8 months ago

Is this intended for point-to-point LoRa communication or communication between LoRa nodes and gateways? or both?

nopnop2002 commented 8 months ago

Both.

ABHITHLALC commented 8 months ago

Thank you for the clarification. Do you know what modifications needed to use this library for communicating the device to the gateway?

nopnop2002 commented 8 months ago

Do you know what modifications needed to use this library for communicating the device to the gateway?

These act as gateways.

https://github.com/nopnop2002/esp-idf-sx126x/tree/main/http https://github.com/nopnop2002/esp-idf-sx126x/tree/main/mqtt

ABHITHLALC commented 8 months ago

I apologize for any confusion. I was wondering if this is intended for the connection of LoRa devices to a LoRaWAN network server through LoRa gateway . Your clarification would be greatly appreciated. Thank you

nopnop2002 commented 8 months ago

This repository does not support LoRaWAN.

ABHITHLALC commented 8 months ago

Thank you for your response. 😊

On Tue, Jan 9, 2024, 6:44 PM nopnop2002 @.***> wrote:

This repository does not support LoRaWAN.

— Reply to this email directly, view it on GitHub https://github.com/nopnop2002/esp-idf-sx126x/issues/20#issuecomment-1883039358, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ57QRKU2L76Q5POJNQYTCLYNU7DNAVCNFSM6AAAAAA2VIDMVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBTGAZTSMZVHA . You are receiving this because you commented.Message ID: @.***>

udayalawa commented 7 months ago

i stumbled across same problem and idk why but by setting
lora.DebugPrint(true); my errors were resolved and one more thing to mention use voltage level shifter (it might be a issue too)