element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Set up Elecrow TTN LoRaWAN gateway on Raspberry Pi - Pt. 2: full install and run as service
  • 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 Dec 2023 8:24 PM Date Created
  • Views 5032 views
  • Likes 7 likes
  • Comments 18 comments
  • raspberry
  • the things network
  • lorawan
  • ttn
  • gateway
  • iot
Related
Recommended

Set up Elecrow TTN LoRaWAN gateway on Raspberry Pi - Pt. 2: full install and run as service

Jan Cumps
Jan Cumps
29 Dec 2023
Set up Elecrow TTN LoRaWAN gateway on Raspberry Pi - Pt. 2: full install and run as service

In part 1,  Set up Elecrow TTN LoRaWAN gateway on Raspberry Pi - Pt. 1: build and test , I compiled the software for the Elecrow LoRaWAN gateway (see  Low-Cost LoRaWAN Gateways! ), and enabled the gateway on The Things Network (TTN). I used Raspberry OS bullseye 32-bit lite on a Raspberry Pi  A+. I tested this on a B+ with the same OS too.

In part 2, the software gets properly installed, and I configure it as a systemd service.

image

Install the software.

I'm going to install it in a bin folder of the user that will run the service (jancumps).

Instructions are on GitHub: SX1302 LoRa Gateway project - 4.2. Install executables and associated files in one directory:

mkdir ~/sx1302_hal

mkdir ~/sx1302_hal/bin

Then navigate to the build folder from post 1 and edit the install config file 

cd LR1302_loraWAN

cd LR1302_HAL

cd sx1302_hal

nano target.cfg

Check that the right folder and user are configured. Don't use the relative user path, but the full one.

image

Then it's time for installing the software in the bin folder we just created. It's worth investigating how to set up ssh certificate logon for localhost, or you'll have to type your password a lot of times. See the link at the start of this section for instructions.

Then install the binaries and config:

make install

make install_conf

Different than the instructions:

cd ~/sx1302_hal/bin

chmod +x reset_lgw.sh

The application is now installed.

Test: 

./lora_pkt_fwd -c global_conf.json.sx1250.EU868

success:

image

Install and run as a daemon

The instructions are also on Github: How to auto-start the with systemd.

In your build directory, there is a script file:

cd ~/LR1302_loraWAN/LR1302_HAL/sx1302_hal/tools/systemd

nano lora_pkt_fwd.service

Adapt to the directory structure and user for your install. If you followed my instructions, you should only check the home folder.

I also tell systemd what group and user name to run this particular service under:

User=jancumps
Group=jancumps

image

Then copy the service file, register it, and enable:

sudo cp lora_pkt_fwd.service /etc/systemd/system

sudo systemctl daemon-reload

Before starting the service, let's redirect the output, so we can monitor it

sudo cp lora_pkt_fwd.conf /etc/rsyslog.d

sudo systemctl restart rsyslog

Start a second console to the Pi, to view the log (a new PuTTY session, or whatever Terminal program you use):

journalctl -u lora_pkt_fwd -f

Let it sit there. Any message from the service will show up there.

In the original terminal, enable and start the service;

sudo systemctl enable lora_pkt_fwd.service

sudo systemctl start lora_pkt_fwd.service

 

image

You can safely close all consoles now. Things will keep on running. Even after reboot. Executing this command at any time will show the log:

journalctl -u lora_pkt_fwd -f

And this will show the service status:

systemctl status lora_pkt_fwd.service

Enjoy

In theory, you don't need the build directory structure anymore ...

See also: Set up Elecrow TTN LoRaWAN gateway on Raspberry Pi - Pt. 3: manage the service log size 

  • Sign in to reply
Parents
  • shabaz
    shabaz over 1 year ago

    Hi Jan,

    I have a stretch goal; it would be nice to have a way of turning on an LED whenever LoRaWAN packets of interest arrive (and possibly when sent; could be the same LED or a different one).

    I *think* this is possible by checking the logs that the system will generate, or alternatively it could be possible to modify the source code and rebuild (possibly it will be the lora_packet_forward.c file, if they are using the same source as RAK (I briefly looked into it at the time but didn't investigate much; I'd much rather put the effort in to the elecrow module now rather than RAK. It would be nicer to do it via log file changes detected I reckon, rather than source modification, assuming the logs do supply the required level of detail for that.

    When I install it on the Pi 3, I'll see if I get anywhere with this idea. It could be nice for troubleshooting, seeing via big blinking light whenever activity occurs that meets a desired match term : )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to shabaz

    tail and grep help here:

    image

    image

    These (except the last one) are all devices that I don't know:

    image

    Examples on reacting when such an even occurs:

    https://unix.stackexchange.com/a/12077

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to shabaz

    tail and grep help here:

    image

    image

    These (except the last one) are all devices that I don't know:

    image

    Examples on reacting when such an even occurs:

    https://unix.stackexchange.com/a/12077

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to Jan Cumps

    Cool thing is that you can set up multiple listeners. That may be interesting if you're interested in different events - join, success, fail, reject, ...

    image

    In the capture above, I had two listeners looking for the same info. For the rest they did nothing but print detected Thing messages...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 1 year ago in reply to Jan Cumps

    That's awesome! This is great news that the logs contain all this valuable information, and easy to pull out.

    Now it will be straightforward to set up a light indication system for this, or even (if desired) something like an I2C LCD screen showing the activity. Personally I will go with an LED blinking one of two colors, for devices of interest, and devices not of interest.

    • 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