Novice LorRa pi coding questions

97 views
Skip to first unread message

James Bell

unread,
Jun 14, 2024, 6:44:05 PMJun 14
to UKHAS
Hi everyone,

Apologies if the questions below aren't appropriate for here, not sure where else to ask (other than maybe stackoverflow!)

I am building my own tracker, I've got the GPS module working but have been falling at the first hurdle with the LoRa module.

I've got this module https://store.uputronics.com/index.php?route=product/product&product_id=99

For which I understand the pinout configuration is:
  1. MOSI - GPIO10
  2. MISO - GPIO9
  3. SCK - GPIO11
  4. CE1 DIO0 GPIO16 
  5. CE1 DIO5 GPIO 5
  6. CE1 NSS GPIO7
  7. CE1 data LED GPIO13  
And no Reset pin connectivity

I've been trying to use pyLoRa library to connect and send a message but it seems to be failing on the board setup. I get the error "Failed to add edge detection". I've tried simply using the RPi.GPIO library directly without pyLoRa to add event detection on the GPIO 16 pin and get the same error. Infact I get the error on trying to add event detection to ANY pin.

I'm not sure where im going wrong / what to try next. I know connectivity and power to the chip is working (I can make the data LED flash, I can read from it over SPI). SPI is turned on in the Rasperry Pi config. Any advice on where to start? I've considered trying to use the pi in the sky software and debug from there but wasnt sure what part of that card to isolate out as the Lora sender. I don't mind switching away from python (rest of the code is in node), i simply selected python as I believed that had the best LoRa transceiver libraries (that may be wrong)

Thanks for any advice!
James

Mika Köching

unread,
Jun 15, 2024, 3:04:52 AMJun 15
to UKHAS
Do you use the original pyLoRa library or the python3 fork? The newer version works quite well for me though I still can't figure out how to receive it properly. From what I've read the rfm is slightly different to the sx127x series which might explain your problems.

Mika, DL8MIK

James Bell

unread,
Jun 15, 2024, 7:32:25 AMJun 15
to UKHAS
I’m using the original I think so will switch to the newer one and try that. 

In the meantime I switched away from using RPi.GPIO to using pigpio. This actually seems to be working though I don’t understand why that would work if RPi.GPIO doesn’t (though can’t verify it’s working until I build the receiver)

Thanks,
James

Tom Wardill

unread,
Jun 16, 2024, 3:57:11 AMJun 16
to uk...@googlegroups.com
Which version Pi are you using?
The pi5 completely reworked GPIO and is not backwards compatible with most libraries. 

Sent from a device prone to typos and terseness, apologies.


--
You received this message because you are subscribed to the Google Groups "UKHAS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ukhas+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ukhas/34dd785b-c411-4dc0-950a-88c62e7338e5n%40googlegroups.com.

Josh Atkins

unread,
Jun 16, 2024, 3:57:11 AMJun 16
to uk...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "UKHAS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ukhas+un...@googlegroups.com.

Mika Köching

unread,
Jun 16, 2024, 4:07:06 AMJun 16
to UKHAS
He's using a raspberry pi zero, just like I do. As far as I know circuitpython won't work. I am using the legacy version of raspberry pi os because of the camera drivers so you might want to try that out. pyLoRa works just fine for me as long as I'm using the low data rate option and set the bandwith to 32.25 khz or something lower to decode it using sdrangel. See this (german) post http://raphuscucullatus.blogspot.com/2019/11/ai-thinker-lora-ra-02-am-raspberry-pi.html

James Bell

unread,
Jun 16, 2024, 5:06:08 AMJun 16
to UKHAS
Thanks for the links - will take a look!

I’m using the Pi Zero 2 W

James Bell

unread,
Jun 28, 2024, 6:37:40 AMJun 28
to UKHAS
Hey thanks for the assistance before - I've got further but now got stuck again and was wondering if people had thoughts

Since last update basically I:
- Switched to the recommended RFM library https://github.com/adafruit/Adafruit_CircuitPython_RFM9x/
- Using this I can transmit and it appears to work fine (I have an RTL-SDR usb radio receiver and can see the transmissions coming through clearly)

Where I am having trouble now is receiving - for some reason the transceiver is not picking up any signal at all, despite that same transceiver working fine for transmitting. I have two transceivers - both can transmit, neither receives anything. I've verified that the antennas work fine because using that antenna with the RTL-SDR enables it to pickup

Diagnostics in the code gives RSSI -157 - it seems to me simply that the transceiver is not receiving anything at all even background noise.

This is the case for both my transceivers - both can transmit (verified by seeing the signal on the SDR), neither receive anything at all, both antennas work.

I can only think that I'm configuring the transceivers incorrectly somehow for receiving but basically using almost exactly the default library code - any ideas? https://github.com/adafruit/Adafruit_CircuitPython_RFM9x/blob/main/examples/rfm9x_simpletest.py

Thanks,
James

Josh Atkins

unread,
Jun 28, 2024, 7:03:17 AMJun 28
to uk...@googlegroups.com
It's worth trying the following settings:
rfm9x.enable_crc = True
rfm9x.node = 1
rfm9x.destination = 2
rfm9x.coding_rate = 5
rfm9x.spreading_factor = 7

Swap node and destination for the other module. signal_bandwidth is worth setting and should be the same on both modules.
Frequency should be valid and the same for both modules.
Sometimes coding_rate and spreading_factor need adjusting. Higher values improve the chance of success.


Josh

Mike Sharps

unread,
Jun 28, 2024, 11:11:32 AMJun 28
to uk...@googlegroups.com
Try tweaking the frequency of the rxer either side of center frq , the xtals on the lora chips are not Particularly accurate and the lora chips can only tolerate a few khz error (i think it is about 4khz) before they will not receive at all , Ive had this kind of issue a few times . 
Mike


David Akerman

unread,
Jun 28, 2024, 11:46:04 AMJun 28
to UKHAS
-157 is IIRC what you get if the device isn't seen, so the RSSI register is being read as FF.

Dave

James Bell

unread,
Jun 28, 2024, 11:51:53 AMJun 28
to UKHAS
Thanks Dave that was what I expected - in which case its an issue in my configuration or code - but given im able to transmit its really confusing me as to what the error could be.

Mike Sharps

unread,
Jun 28, 2024, 1:34:05 PMJun 28
to uk...@googlegroups.com
If you want to check the lora chip is talking you should be able to do a SPI register read via the Circuit Python REPL . try reading reg 0x42 (lora version register) and you should get a value of 0x12 back. If you do, the chip is talking to the SPI bus. There are some adafruit example articles which show how to set up and read the SPI bus via REPL
Mike


David Akerman

unread,
Jun 28, 2024, 1:50:38 PMJun 28
to UKHAS
If you can't transmit then the SPI stuff must be fine.

You might not have the chip in LoRa mode.   Remember that many register addresses are shared with different functions in LoRa Vs FSK mode.  So check that and if course the that you have the correct address of the current RSSI register. 

Dave


Reply all
Reply to author
Forward
0 new messages