adafruit / Adafruit_CircuitPython_RFM69

CircuitPython module for the RFM69 series of 433/915 mhz packet radios.
MIT License
31 stars 28 forks source link

standard python and interrupt - update documentation #36

Open Pythonaire opened 3 years ago

Pythonaire commented 3 years ago

this library works very well (little modification) in conjunction with python3 on a raspberry, a Adafruit RFM69 breakout board and the interrupt feature (DIO0). In my case, the raspberry work as a bridge between a RFM69-network and LAN.

To use this: io.setup(self.dio0_pin, io.IN,pull_up_down=io.PUD_DOWN)

and

io.add_event_detect(self.dio0_pin, io.RISING, callback = the_script_to_handle_the data)

maybe people are interested in this.

jerryneedell commented 3 years ago

It is very good to know it has been working well for you. There is an example for this in the repository https://github.com/adafruit/Adafruit_CircuitPython_RFM69/blob/main/examples/rfm69_rpi_interrupt.py

Did you have to make any changes to the library? If so, please share them or create a PR to add them.

Pythonaire commented 3 years ago

Yes, it works well and stable since months. The only things, thats different: i waive the extra check of payload.ready and set a time delay of 50 ms after each send/received Action, to make shure, i get no overlapping.

jerryneedell commented 3 years ago

Are those changes in your application code or in the library? If they are in the library would you please post a copy of your modified library. I'd like to see exactly what you changed.

Pythonaire commented 3 years ago

the files are placed here: https://github.com/Pythonaire/RFMGate

jerryneedell commented 3 years ago

@Pythonaire Thank you. I am a bit confused. The files you posted include rfm69_driver.py which appears to be a very old version of the library. Is that what you are using? I don't see where you made your changes. Your rfm69_test.py imports adafruit_rfm69 but what version of the library are you using?

jerryneedell commented 3 years ago

Ah - I see that main.py uses the rfm69_driver.py...

Pythonaire commented 3 years ago

yes - this driver is the older version. the changes are marginal, just suppress the permanent listening of payload_ready bit. May be i'm wrong - i'm stumbled across the note ".. note:: The D0/interrupt line is currently unused by this module and can remain unconnected."(line 153). I need the "fire and forget" technic (no "reliable datagram"), because of my use case and the interrupt feature is the solution i needed. The raspberry is a Apple homekit bridge for sensors and switches.

jerryneedell commented 3 years ago

hmm -- I will look into that comment about D0 - hopefully it is just a comment that should have ben removed. I know the interrupt works for the rfm9x library but I have to tested it on the rfm69 for a long time. Thank you for pointing that out. I will test it.

Also note that "fire and forget" is still the default for sending packets, "reliable datagram" is available, but not required.

jerryneedell commented 3 years ago

I just tested the interrupt example using 2 Raspberry Pis with rfm69 bonnets. It does work!

pi@gjnpirfm69:~/projects/blinka/rfm69 $ python3 rfm69_rpi_interrupt.py
Temperature: 32.0C
Frequency: 915.0mhz
Bit rate: 250.0kbit/s
Frequency deviation: 250000.0hz
IRQ detected on pin 22 payload_ready <bound method RFM69.payload_ready of <adafruit_rfm69.RFM69 object at 0xb655a990>> 
Sent hello world message!
Waiting for packets...
IRQ detected on pin 22 payload_ready <bound method RFM69.payload_ready of <adafruit_rfm69.RFM69 object at 0xb655a990>> 
Received (raw bytes): bytearray(b'Hello world!\r\n')
['0x48', '0x65', '0x6c', '0x6c', '0x6f', '0x20', '0x77', '0x6f', '0x72', '0x6c', '0x64', '0x21', '0xd', '0xa']
RSSI: -26.5
received message!

I will review the code and update the comments -- For normal use, D0 does not have to be connected, but it can be used on a Raspberry Pi as in the example.

Pythonaire commented 3 years ago

i think, waiting for an interrupt is much better, than permanent cycling through the code.