-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix configuration for Spreading Factor = 6 #10
Conversation
This PR has been pending for a few weeks. Are there any concerns with it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jerryneedell are the two new examples expected to work on microcontrollers too or just RPi?
If they are intended to run on MCU, can you describe their intended behavior briefly?
I can run them on two different feathers with radio featherwings connected and they don't crash, but the one running the base code seems to get "stuck" in a fast loop of receiving the same data over and over.
Even if I stop the node device with ctrl-C after it the base keeps printing it's received output
Received (raw payload): bytearray(b'message from node 0')
Sometimes the repeated message is the startup message, and other times it is the counter message, but I've never seen the counter higher than 0 yet.
examples/rfm_lora_sf_node.py
Outdated
print([hex(x) for x in packet]) | ||
print(f"RSSI: {rfm.last_rssi}") | ||
# send reading after any packet received | ||
if time.monotonic() - time_now > transmit_interval: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could time_now
be called last_transmit_time
like it is in the other script?
subtracting time_now
from time.monotonic()
for comparison threw me for a loop slightly since both kind of describe "now".
Thanks for testing. I'll try them on both MCU and pi again and see if I can replicate. |
hmm -- I have the "base" running on metro_m4 with an rfm9x featherwing attached and it does to loop as you rescript.
|
I am having a problem though. The node is not receiving back the packets as expected. Looking into it. The node should send a packet every 10 seconds and the base should echo that packet back after 5 seconds. I'm not seeing the echoed packet. OK -- I found that issue. I'll fix it and explain -- The sample code is very simplistic -- maybe too simple.... In any case, I cannot reproduce your problem -- |
I made a few minor changes mainly the node should send and the base should receive. I've been running the base on am MCU and the node on a PI. I'll dig out another MCU to run the node as well. |
I tried with a few different combinations of a PyGamer + Featherwing as one device and a Feather RP2040 / Feather S3 + featherwing as the other device. I'm not certain which was base and which was node in all cases, but I tried a few different combinations of devices with the different scripts. They were unmodified except for the pins changed. I'll pull the latest version and try some other permutations of devices today or tomorrow. |
I made one more tweak to the "base" program and added a note about setting the transmit delay. You want to avoid multiples of the node receive_timeout (typically .5 seconds) or you can get into a situation where the node is between receive calls when the packets arrive and it misses them I now have both the node and base on MCUs = node on a feather_rp2040_rfm9x and the base on the metro M4. |
from base
from node:
|
I really need to work on a guide for this library... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thank you @jerryneedell
I was able to test successfully with a Feather M4 + Featherwing as base and RP2040 + Featherwing as node.
It seems that the issue I described before about getting stuck repeatedly receiving the same message over and over in a very fast loop is tied to the PyGamer. I went back and tested PyGamer as node and Feather M4 as base, and I see that stuck repeating issue on the pygamer. My only hunch about it was maybe the display sharing the SPI bus caused weirdness, but I tried displayio.release_displays()
and then re-running the base and node scripts, and I still see the same behavior with repeated receive messages. Maybe the display could still be impacting it somehow, or there is some other difference in this hardware that is causing it.
Strange -- I'll dig out my pygamer and see if I can reproduce it.... Thanks for approving. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_RFM to 1.0.5 from 1.0.4: > Merge pull request adafruit/Adafruit_CircuitPython_RFM#10 from jerryneedell/jerryn_spreadf
FIxes #8
Implemented changed to rfm9x.py to correctly configure SF=6 and facilitate other SF settings
low_datarate optimize is updated whenever the Spreading Factor or Signal Bandwidth are changed.
Added two examples for experimenting with setting the Spreading Factor:
rfm_lora_sf_base.py
rfm_lora_sf_node.py
For simplicity, The RadioHead Header is disabled for those examples.
It can be enabled if desired except that SF=6 is not currently compatible with "reliable datagram mode" (ACK). SF = 6 requires that the sender and receiver both know the length of each packet.
I'll continue working on this but it may be worth making these changes available now.. There are many use-cases that do not require SF=6 AND reliable datagram mode.
Tested on Raspberry Pi5 and Raspberry Pi Zero W with RFM9x Bonnets.