lib | ||
led_test.py | ||
LICENSE | ||
lora_pingpong.py | ||
lora_receiver.py | ||
lora_sender.py | ||
main_-lcd.py | ||
main_+lcd.py | ||
README.md |
LoRa-Training
An repository containing some example code written for the Raspberry Pi Pico; also contains ping pong
Requirements
To re-run this tests, you need at least two LoRa transceivers with the chip SX127x (e.g. SX1278) connected to two different Raspberry Pi Picos. Also - for improved "usability", attach two buttons, two leds (red for send and green for receive) and an LCD to the microcontrollers. The matching pins are for ...
... the LoRa transceiver:
Device | Pin on device | Pin on Pico |
---|---|---|
LoRa | VCC | 36 (V3V) |
LoRa | GND | 3 (GND) |
LoRa | MISO | 6 (GPIO 4) |
LoRa | MOSI | 5 (GPIO 3) |
LoRa | SCLK | 4 (GPIO 2) |
LoRa | NSS | 7 (GPIO 5) |
LoRa | DIO0 | 9 (GPIO 6) |
... further components (optional):
Device | Pin on device | Pin on Pico |
---|---|---|
LCD1 | SDA | 1 (GPIO 0) |
LCD1 | SCL | 2 (GPIO 1) |
LCD1 | VCC | 40 (VBUS2) |
LCD1 | GND | 3 (GND) |
BTN1 | Pin 1 | 36 (V3V) |
BTN1 | Pin 2 | 10 (GPIO 7) |
BTN2 | Pin 2 | 11 (GPIO 8) |
BTN2 | Pin 1 | 36 (V3V) |
LED green | + | 31 (GPIO 26) |
LED green | - | 33 (GND) |
LED red | + | 32 (GPIO 27) |
LED red | - | 33 (GND) |
1 with PCM5102 I2C port multiplexer
2 works only if the pico's connected over USB
Installation
To get the tests to run, start by uploading all the content of this repo on the two (ideally empty) Pi Picos with MicroPython installed on. To do this, use e.g. Thonny.
Also make sure you have at least added the LoRa transceiver module, otherwise nothing will work.
Now, depending on whether the lcd and buttons are installed or not (always buttons AND lcd, only one of these won't work), open the main_+lcd.py
for running with lcd screen and main_-lcd.py
else.
Save the opened one as main.py, so that this script (the main.py) is run at startup (when you connect power). Don't worry - you will still be able to access the data on the pico just by interrupting the execution using e.g. Thonny.
The LEDs will always turn on and off - if there are none connected, there's just no light. No way to disable that easily (you'd have to refactor all the files as LED pins are hardcoded sometimes :).
By default, the main_-lcd.py file will execute an ping-pong program as the responder. As a responder, it waits for the first message and short after receiving it, sends the response including info e.g. about the signal quality. To change this behaviour, change the variable to_run
right in this file.
When running the main_+lcd.py file, you are able to choose whether to run as a ping-pong responder, initializer, just simple sender, etc. from the list by navigating with the two buttons (this is done with the ProgramChooser library).
Credits and useful links
Lastly, thanks to all the people sharing their code, e.g. the driver for the SX127x chip series ported for MicroPython on the Pico. Here are some links:
- The SX127x driver library used in this tests
- The LCD driver lib used
- The makers of MicroPython
- Raspberry for the Pi Pico, of course
- Tutorial introducing main steps to get the SX127x board to run
- Website providing some pinout and info
- More pinout and stuff :)
- Interesting article for building general LoRa knowledge
- A collection of libraries for the Raspberry Pi Pico
- ProgramChooser, the lib used here for navigating and selecting
License
The scripts contained here are licensed under the GNU GPLv3-or-later. A copy of this license can be found in the LICENSE file