89 lines
4.5 KiB
Markdown
89 lines
4.5 KiB
Markdown
# 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 |
|
|
| ------ | ------------- | ----------- |
|
|
| LCD<sup>1</sup> | SDA | 1 (GPIO 0) |
|
|
| LCD<sup>1</sup> | SCL | 2 (GPIO 1) |
|
|
| LCD<sup>1</sup> | VCC | 40 (VBUS<sup>2</sup>) |
|
|
| LCD<sup>1</sup> | 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) |
|
|
|
|
|
|
<sup>1</sup> with PCM5102 I<sup>2</sup>C port multiplexer
|
|
|
|
<sup>2</sup> 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](https://micropython.org/download/?vendor=Raspberry%20Pi)** installed on. To do this, use e.g. **[Thonny](https://thonny.org/)**.
|
|
|
|
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](https://git.privacynerd.de/BlueFox/ProgramChooser)**).
|
|
|
|
|
|
## 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](https://github.com/lemariva/uPyLoRaWAN/)
|
|
- [The LCD driver lib used](https://github.com/T-622/RPI-PICO-I2C-LCD)
|
|
- [The makers of MicroPython](https://micropython.org/)
|
|
- [Raspberry for the Pi Pico, of course](https://www.raspberrypi.com/products/raspberry-pi-pico/)
|
|
|
|
---
|
|
|
|
- [Tutorial introducing main steps to get the SX127x board to run](https://www.electroniclinic.com/raspberry-pi-pico-w-with-lora-sx1278-for-sensor-monitoring/)
|
|
- [Website providing some pinout and info](https://wei1234c.blogspot.com/2017/08/sx127x-lora-transceiver-driver-for.html)
|
|
- [More pinout and stuff :)](https://www.electroschematics.com/rf-radio-frequency/)
|
|
- [Interesting article for building general LoRa knowledge](https://circuitdigest.com/microcontroller-projects/arduino-lora-sx1278-interfacing-tutorial)
|
|
- [A collection of libraries for the Raspberry Pi Pico](https://git.privacynerd.de/BlueFox/micropython-libraries)
|
|
- [ProgramChooser, the lib used here for navigating and selecting](https://git.privacynerd.de/BlueFox/ProgramChooser)
|
|
|
|
|
|
## License
|
|
|
|
The scripts contained here are licensed under the GNU GPLv3-or-later. A copy of this license can be found in the [LICENSE](LICENSE) file |