Enable LoRaWAN communications on your Raspberry Pi Pico or any RP2040 based board using a Semtech SX1276 radio module or Waveshare's SX1262-based LoRaWAN module.
Based on the Semtech's LoRaWAN end-device stack implementation and example projects.
- RP2040 board
- Semtech SX1276 board
- Semtech SX1262 board
Default Pinout for Semtech SX1276:
Raspberry Pi Pico / RP2040 | Semtech SX1276 |
---|---|
3.3V | VCC |
GND | GND |
GPIO 18 | SCK |
GPIO 19 | MOSI |
GPIO 16 | MISO |
GPIO 7 | DIO0 / G0 |
GPIO 8 | NSS / CS |
GPIO 9 | RESET |
GPIO 10 | DIO1 / G1 |
Default Pinout for Semtech SX1262 on Waveshare Pico-LoRa-SX1262-868M:
Raspberry Pi Pico / RP2040 | Waveshare Pico-LoRa-SX1262-868M |
---|---|
3.3V | VCC |
GND | GND |
GPIO 10 | SCK |
GPIO 11 | MOSI |
GPIO 12 | MISO |
GPIO 3 | NSS / CS |
GPIO 15 | RESET |
GPIO 20 | DIO1 |
GPIO 2 | BUSY |
GPIO pins are configurable in examples or API.
By default this library only supports the Semtech SX1276 boards mentioned in the first section. Support for Waveshare's SX1262-based Raspberry Pi Pico Hat is available, but needs to be enabled actively.
Take the following steps to switch from SX1276 to Waveshare SX1262 support:
Uncomment
set(WITH_WAVESHARE_SX126X ON)
in CMakeLists.txt
.
In your example application, e.g. otaa_temperature_led/ set the region to EU868 in config.h
:
#define LORAWAN_REGION LORAMAC_REGION_EU868
(and also provide your Device EUI, App EUI and App Key here!)
In the example application's main.c
make sure that you're using the proper sx12xx_settings
for your SX1262 Waveshare module:
const struct lorawan_sx12xx_settings sx12xx_settings = {
.spi = {
.inst = spi1,
.mosi = 11,
.miso = 12,
.sck = 10,
.nss = 3
},
.reset = 15,
.busy = 2,
.dio1 = 20
};
There is no guarantee that other SX1262-based boards will work. Tests have only been run using Waveshare's board.
See examples folder.
There is a config.h
file to your ABP or OTAA node configuration for each example.
git clone --recurse-submodules https://github.com/sandeepmistry/pico-lorawan.git
- Set up the Pico C/C++ SDK
- Set
PICO_SDK_PATH
export PICO_SDK_PATH=/path/to/pico-sdk
- Create
build
dir, runcmake
andmake
:
mkdir build
cd build
cmake .. -DPICO_BOARD=pico
make
- Copy example
.uf2
to Pico when in BOOT mode.
This library uses the last page of flash as non-volatile memory (NVM) storage.
You can erase it using the erase_nvm
example, when:
- Changing the devices configuration
- If your board is timing out with joining the network
A big thanks to Alasdair Allan for his initial testing of EU868 support!
Thanks to Waveshare and siuwahzhong for providing their modified version of this library. Parts of their work have been merged back into this library by Thomas Leister. Original source: ZIP | GitHub
This project was created on behalf of the Arm Software Developers team, follow them on Twitter: @ArmSoftwareDev and YouTube: Arm Software Developers for more resources!