sandeepmistry / arduino-LoRa

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

Enhancement request: interrupts on FALLING edge #488

Open Addictek opened 3 years ago

Addictek commented 3 years ago

I've designed a new circuit using ESP8266 and SX1278.

IO0 output of SX1278 is connected to GPIO2 input pin of ESP8266 through an inverter gate (NOT). This is required by ESP8266 since the GPIO2 pin must be pulled up on startup and the IO0 pin of SX1278 is low on startup.

Due to the inverted connection between IO0 and GPIO2, to use the onReceive() callback, I would need to attach the interrupt on the FALLING edge of GPIO2.

The current implementation only supports interrupts on the RISING edge.

The request is to make the interrupt type configurable keeping the default value to RISING.

IoTThinks commented 3 years ago

Generally, you should avoid using GPIO0 and 2 of esp32/esp8266. You should fix your board design instead.

I believe the SX127x will trigger a HIGH signal on DIOx of the chip when there is an event. When the event is processed, then the chip will set DIOx back to LOW signal. I wonder if your suggestion will work.

Addictek commented 2 years ago

I used GPIO0/2 because I ran out of i/o pins. You are right, SX127x chip triggers HIGH signal but in my case this is going through a mosfet gate that inverts the signal before reaching the GPIO2 pin. This way, ESP chip starts up regularly, but I can still use GPIO2 to handle the interrupt. Note that the mosfet gate circuit is also able to keep the output high regardless the input signal on start up for the time required by esp8266 to boot. I have modified the library for testing purposes and it is working fine.

Il Mar 6 Lug 2021, 07:19 IoTThinks.com @.***> ha scritto:

Generally, you should avoid using GPIO0 and 2 of esp32/esp8266. You should fix your board design instead.

I believe the SX127x will trigger a HIGH signal on DIOx of the chip. When the event is processed, then the chip will set DIOx back to LOW signal. I wonder if your suggestion will ever work.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sandeepmistry/arduino-LoRa/issues/488#issuecomment-874467968, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUXRJBGA5IT4P5C7FAEDDITTWKG65ANCNFSM4724QAHA .

Addictek commented 2 years ago

Just to add that my change was something like:

ifndef LORA_ISR_MODE

define LORA_ISR_MODE RISING

endif

and then using LORA_ISR_MODE in place of the hardcoded value in the library code. This will have no impact on projects currently using the library.