Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Circuitpython RFM69 Gateway
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Circuitpython RFM69 Gateway

by jerryn on Sun Aug 23, 2020 6:28 am

Thank you for the follow-up. That sounds very encouraging. I am curious about the changes you had to make to get the libraries working with MP. Would you be willing to post the modified code? I will be happy to take a look a the RFM69 code to see if I can help get it working. It sounds like it is very close. What boards have you been testing with?

jerryn
 
Posts: 1291
Joined: Sat Sep 14, 2013 9:05 am

Re: Circuitpython RFM69 Gateway

by smccamy1 on Sun Aug 23, 2020 8:59 am

Here you go. The main changes are of course the SPI connection and the syntax difference in changing pin values. I also changed time.monotonic to time.time as I could not get the module installed in MP (didn't try very hard and not sure it matters).

The issue on the rfm69 code is you will get the payload back but not the header. Example if you are receiving "Hello" as a message you will get something like b'/x00Hello/xff/xff/xff' when reading the FIFO.

I tested with several ESP32 boards. The TinyPICO is nice and very low power. The board linked below tested at 9 micro amps which is impressive. The code itself works on any cheap ESP32 dev board I tried.
https://www.ezsbc.com/index.php/feature ... 0JoXchKiWE

The code will also work on an ESP8266 if you compile it first to mpy. I get the exact same results on that chip.

There are example connects for both in main.py.

Thanks for looking!
Attachments
esprfm.zip
(21.15 KiB) Downloaded 2 times

smccamy1
 
Posts: 21
Joined: Tue May 17, 2016 8:57 pm

Re: Circuitpython RFM69 Gateway

by jerryn on Sun Aug 23, 2020 10:58 am

Thanks - I will give it a try.

I think there is just a simple error in your main.py for the rfm69

try changing
Code: Select all | TOGGLE FULL SIZE
packet = rfm69.receive(with_ack=True)

to
Code: Select all | TOGGLE FULL SIZE
packet = rfm69.receive(with_ack=True,with_header=True)


If with_header=False (the default) the header is stripped before the packet is returned.

jerryn
 
Posts: 1291
Joined: Sat Sep 14, 2013 9:05 am

Re: Circuitpython RFM69 Gateway

by smccamy1 on Sun Aug 23, 2020 11:17 am

I could not get the packet to return from the function so I just started adding in print statements upstream to see where the issue was. If you print the packet right after it checks the fifo_lenght, around 749, you will see it does not have the header there.

Code: Select all | TOGGLE FULL SIZE
if fifo_length < 5:
    packet = None
else:
    print(packet)

I think the issue is when this is called.

Code: Select all | TOGGLE FULL SIZE
self._read_into(_REG_FIFO, packet)
.
The fifo_lenght is correct so the buffer is set correctly and the register write seems correct but when it reads back into the buffer the header bytes are just not there.

Code: Select all | TOGGLE FULL SIZE
self.spi.write(bytes([address & 0x7F]))
self.spi.readinto(buf)

I messed with a lot of stuff in that function but just could not get it working. Its basically the same logic in the rfm9x library and it seems to work fine.

smccamy1
 
Posts: 21
Joined: Tue May 17, 2016 8:57 pm

Re: Circuitpython RFM69 Gateway

by jerryn on Sun Aug 23, 2020 11:36 am

hmm -- OK - I'll dig into this in the next few days. I am trying to track down another subtle issue in the rfm69 code that has been driving me nuts -- perhaps they are related ...

jerryn
 
Posts: 1291
Joined: Sat Sep 14, 2013 9:05 am

Re: Circuitpython RFM69 Gateway

by jerryn on Mon Aug 24, 2020 8:17 pm

Just a quick update. I put your code on an ESP32 and am having the asme issue you described with the rfm69. I'll try to look into it more tomorrow. Off to a good start in that I got the pins correct ;-)

I also fond that the issue I had been chasing was due to the SPI baud rate and likely only impact the SAMD21 boards. Still working on that, but probably not relevant here.

Thanks for porting this to MP --looking forward to working with it.

- Jerry

jerryn
 
Posts: 1291
Joined: Sat Sep 14, 2013 9:05 am

Re: Circuitpython RFM69 Gateway

by jerryn on Tue Aug 25, 2020 11:47 am

OK - I have the rfm69 working now.
There were a few minor issues.
the timeouts had to be restructured for MP time functions.
the header was being lost because the RFM69 FIFO is handled a bit differently than the rfm9x - I reworked some of the read functions.

I also found that I was having problems with the SPI baudrate at 5MHz so I lowered it to 1MHz -- seems much happier.
also for communicating with my other node on a Raspberry Pi, I had to set an ack_delay of 100 ms

here is a zip file with the new module and updated examples.
the test_rfm69.py is just an updated version of your main.py
the rfm69_node2_ack is the example in the adafruit library updated for MP.
Both are working for me.

This still needs more work, but I think it's a good start.

I'll make similar updates to the RFM9x module and post it, hopefully, later today. Let me know if you have any questions about the changes.
gjn_esprfm69.zip
(10.5 KiB) Downloaded 3 times

jerryn
 
Posts: 1291
Joined: Sat Sep 14, 2013 9:05 am

Re: Circuitpython RFM69 Gateway

by smccamy1 on Tue Aug 25, 2020 12:39 pm

Awesome! Ok yeah, I just stuck time.time() in there and it "worked" and I forgot to go back to read up on time.monotonic() more. Thanks for chasing that down. This is great!

smccamy1
 
Posts: 21
Joined: Tue May 17, 2016 8:57 pm

Re: Circuitpython RFM69 Gateway

by jerryn on Tue Aug 25, 2020 2:40 pm

Here are the files for the RFM9x
Note : I had to change the Pin assignments for my configuration.


AS with the rfm69, I think this is a good starting point. MP offers some great opportunities for improvement possibly using interrupts to make the packet receipt much more reliable,

Thank you so much for getting this going.
Jerry

gjn_esp32_rfm9x.zip
(12.36 KiB) Downloaded 2 times

jerryn
 
Posts: 1291
Joined: Sat Sep 14, 2013 9:05 am

Re: Circuitpython RFM69 Gateway

by brubell on Fri Aug 28, 2020 5:09 pm

This is a great start - the CircuitPython TinyLoRa repo was recently converted to work with MicroPython (https://github.com/fantasticdonkey/uLoRa) and has more stars than the CircuitPython version.

smccamy1 , would you be interested in making a github repository for your work? You will need to maintain it - but the advantage is others, like Jerryn, could fork and expand it.

brubell
 
Posts: 1040
Joined: Fri Jul 17, 2015 10:33 pm

Re: Circuitpython RFM69 Gateway

by smccamy1 on Fri Aug 28, 2020 11:43 pm

Sure thing. I will get it committed this weekend and post a link.

smccamy1
 
Posts: 21
Joined: Tue May 17, 2016 8:57 pm

Re: Circuitpython RFM69 Gateway

by smccamy1 on Sun Aug 30, 2020 9:19 pm

I will document my project at the account below and post the ported libraries there. Thanks

https://github.com/nohcpy

smccamy1
 
Posts: 21
Joined: Tue May 17, 2016 8:57 pm

Re: Circuitpython RFM69 Gateway

by jerryn on Mon Aug 31, 2020 5:48 am

That looks great -- thank you!. Will you also be creating a repository for the RFM9X library?

jerryn
 
Posts: 1291
Joined: Sat Sep 14, 2013 9:05 am

Re: Circuitpython RFM69 Gateway

by smccamy1 on Mon Aug 31, 2020 1:51 pm

Got it up there now as well.

smccamy1
 
Posts: 21
Joined: Tue May 17, 2016 8:57 pm

Re: Circuitpython RFM69 Gateway

by jerryn on Tue Sep 01, 2020 10:50 am

Thank you! It will be fun to play with these with MicroPython.

jerryn
 
Posts: 1291
Joined: Sat Sep 14, 2013 9:05 am

Please be positive and constructive with your questions and comments.