Skip to content

Enable LoRaWAN communications on your Raspberry Pi Pico or any RP2040 based board. 📡

License

Notifications You must be signed in to change notification settings

illuminatux/lorawan-library-for-pico

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pico-lorawan

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.

Hardware

Default Pinout

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.

Enabling support for Waveshare Pico-LoRa-SX1262-868M

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.

Examples

See examples folder.

There is a config.h file to your ABP or OTAA node configuration for each example.

Cloning

git clone --recurse-submodules https://github.com/sandeepmistry/pico-lorawan.git 

Building

  1. Set up the Pico C/C++ SDK
  2. Set PICO_SDK_PATH
export PICO_SDK_PATH=/path/to/pico-sdk
  1. Create build dir, run cmake and make:
mkdir build
cd build
cmake .. -DPICO_BOARD=pico
make
  1. Copy example .uf2 to Pico when in BOOT mode.

Erasing Non-volatile Memory (NVM)

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

Acknowledgements

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!

About

Enable LoRaWAN communications on your Raspberry Pi Pico or any RP2040 based board. 📡

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 81.2%
  • CMake 18.8%