element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Internet of Things
  • Technologies
  • More
Internet of Things
Blog Port Semtech LoRaWan Modem library to Pico: Pt. 1: Gather info and prepare development infra
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Internet of Things to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 29 Jun 2024 9:57 AM Date Created
  • Views 1649 views
  • Likes 5 likes
  • Comments 18 comments
  • raspberry
  • lorawan
  • pico
  • semtech
  • rp2040
Related
Recommended

Port Semtech LoRaWan Modem library to Pico: Pt. 1: Gather info and prepare development infra

Jan Cumps
Jan Cumps
29 Jun 2024

The Semtch LoRa-node lib, that I used with some success in  Test LoRaWan Thing code ported for Raspberry Pico . is deprecated. It's replaced by LoRa Basic Modem.  I'm going to try and port that for the RP2040 controller. I've set ambitious goals:

  • don't change Semtech's code
  • port as specified by LoRa Basics Modem Porting Guide (30 pages of instructions)
  • use CMake, for compatibility with the Pico C/C++ SDK. Unless I find a way to integrate the make files in the build.
  • reusable for other projects

image
image source: Semtech Porting guide

Create a directory structure and get the LoRa Modem lib

I created a directory in the IDE workspace. I use VSCode, but the project works for any environment that can build one of Raspberry's Pico examples.

C:\Users\jancu\Documents\Pico\PicoSDKv1.5.1\workspace_1.5.1\pico_lorawan_modem

Then checked out Semtech's LoRa Modem lib:

git clone --recurse-submodules https://github.com/Lora-net/SWL2001.git

I created a main file, empty at the moment, and 2 CMake config files.

main.cpp

#include <stdio.h>
#include "pico/stdlib.h"

int main() {
    stdio_init_all();
    while (true) {
    }
    return 0;
}

CMakeList.txt

cmake_minimum_required(VERSION 3.13)

set(PICO_DEOPTIMIZED_DEBUG 1)

# Pull in SDK (must be before project)
include(pico_sdk_import.cmake)
set(PICO_BOARD seeed_xiao_rp2040)

project(pico_lorawan_modem C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)

pico_sdk_init()

set(RADIO sx1276)
include (CMakeSWL2001.txt)

add_executable(${CMAKE_PROJECT_NAME} main.cpp )

pico_set_program_name(${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_NAME})
pico_set_program_version(${CMAKE_PROJECT_NAME} "0.1")

pico_enable_stdio_uart(${CMAKE_PROJECT_NAME} 0)
pico_enable_stdio_usb(${CMAKE_PROJECT_NAME} 1)



# Add any user requested libraries
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
        pico_stdlib
        )

pico_add_extra_outputs(${CMAKE_PROJECT_NAME})

This is a very common RP2040 file. You'll see that I only added two lines for the LoRa Modem:

set(RADIO sx1276)
include (CMakeSWL2001.txt)

That's because I plan to have anything related to the Semtech lib in a separate file.

CMakeSWL2001.txt

set(LORAWAN_LIB_NAME SWL2001)
add_library(${LORAWAN_LIB_NAME} INTERFACE)

target_include_directories(${LORAWAN_LIB_NAME} INTERFACE)
set(LORAMAC_LIB_PATH ${CMAKE_CURRENT_LIST_DIR}/SWL2001/lbm_lib)

if(NOT DEFINED RADIO)
  message("You must set a radio")
  message("set(RADIO <semtech radio model>")
  message("Valid options: (lr1110 lr1120 lr1121 sx1261 sx1262 sx1268 sx128x sx1272s) sx1276")
  message(FATAL_ERROR "Fix this before continuing.")
endif()
message("Radio selected: ${RADIO}")


target_sources(${LORAWAN_LIB_NAME} INTERFACE
#    ${LORAMAC_NODE_PATH}/src/peripherals/soft-se/soft-se.c
)

target_include_directories(${LORAWAN_LIB_NAME} INTERFACE
#    ${LORAMAC_NODE_PATH}/src
)

You can see it's still in its infant stage. It can manage a few things that I'll need later:

  • configure it so that the Pico example will see it as "one of the usual" libraries
  • check if a LoRaWan radio chip is selected. Error the build if not.
  • infra to collect all include and source files that 'll be required later.

image

  • Sign in to reply
  • jcof
    jcof 8 months ago in reply to Jan Cumps

    All my Hats have sx1262 radios. Their working fine...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps 8 months ago in reply to jcof

    I'll check. Because I couldn't get the port working for SX1276 radios ...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jcof
    jcof 8 months ago

    I stumbled across this while searching for pico lora basics modem.  Not sure if you got this going but I have ported lora basics modem to pico/pico2.  I've got it working with ping pong example and OTAA with my gateway (chirp stack).   Haven't done anything with FOUTA.  I had a bunch of Waveshare Lora Hats (pico and rpi) that I wanted to get going.

    If anyone is interested you can check out:

    github.com/.../lora_basics_modem_ports

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • eriklundh
    eriklundh 11 months ago in reply to eriklundh

    I used  two different LoRA gateway boards for PI: RAK831 and RAK2245, both from RAK Wireless  

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • eriklundh
    eriklundh 11 months ago in reply to Jan Cumps

    I forgot to mention that I used opensource Chirpstack on Raspberry Pi4 for testing, which allowed me full control of the whole chain from Gateway hardware to MQTT feed

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube