Lora SDR data

Top of home page - Back to Builds section of Home Page where this page is listed

Setting up a Raspberry Pi to run a lora rnode, and making it re-start automatically when power returns

These instructions will allow you to run lora rnodes using a lora radio plugged by USB into a Raspberry Pi 4 (or 3) or Raspberry Pi Zero. (Point 11 below also works for Ubuntu 22.) You can message people directly using the Pi+rnode using the MeshChat graphical user interface (GUI) of the MeshChat program installed on the Pi. In that use case the rnode is an 'end point' rnode. Alternatively, you can just leave the Pi+rnode unattended and its messages 'unmonitored'. In this use case it is a 'place and forget', or 'mid-point rnode', acting in a so-called gateway/transport/propagation mode, and acting according to the the settings set in the MeshChat program installed on the Pi. A 'place and forget' or 'mid-point' node can relay messages onwards, such as a solar rnode or a rnode in an attic: which would normally then just forward the messages to be actually read elsewhere. To send and receive messages at an end-point rnode, or to control the settings of a 'place and forget' rnode, you can use the MeshChat GUI on a keyboard and screen connected directly to the Pi+rnode, or you can use the Pi+rnode 'headlessly' and use the MeshChat GUI from a browser on a device on the same home wifi (or wired LAN) network as the Pi+rnode. In that case here the wifi/LAN is only used to interact with the MeshChat GUI locally to your home, and the messages are propagated out using only lora, not wifi (though superbly Reticulum would allow wifi nodes in the mesh too, but that is another story).

These instructions are based mainly on what was kindly provided by Simon Phillips, and are based on Liam Cottle's instructions.

In these instructions you need a 'setup' computer to set up the Pi. It is preferable for the setup computer, that you are using to set up the Pi, to already have Reticulum MeshChat installed and its own rnode attached and running as an interface, because then you can, at the end, test the Pi + rnode to see if things are working via lora radio. See this step-by-step guide for Ubuntu.

It is best to have the radio rnode, that you wish to run with the Pi, already flashed and checked that it works. These instructions do not relate to flashing the rnodes, and it is not necessary nor intended herein to flash the rnode with the Pi, because these instructions cover headless use of the Pi. Flashing the rnode for the Pi rnode is best done with the setup computer, which you will also use to test the Pi + rnode setup by trying to communicate with the Pi over lora.

  1. You need a Raspberry Pi and a suitable SD memory card, and the Pi to be connected to another 'setup' computer by wifi or LAN cable in your local (home) network.

  2. If you are going to use a Pi Zero, then it is highly recommened, but maybe not essential (I will test again), for the setting up process, to have an ethernet LAN wired connection to the Pi Zero. Because the Pi Zero has USB A micro ports, you would need an USB micro to RJ45 Ethernet adapter (e.g. like this) for the most fail-safe headless installation described here. In any case you will need this adaptor if you are keen on running the rnode wirelessly and portably, see point 3 of wifi details below.

  3. These Pi setup instructions use a fresh installation of the Pi OS, because things can be different if the Pi already has software installed. If anything goes wrong during your attempt to follow these steps, then the recommendation is (unless you are confident with Linux things) to start over with a fresh installation of the OS on the Pi by re-flashing the SD card and starting over.

  4. Use the Pi imager to write/flash the SD card. When you have installed the imager on the setup computer, run the imager. Scroll down to the select your OS. For the Pi Zero select only a 'Lite' version e.g. 'Raspberry Pi OS Lite (64-bit)'. A a 32-bit Lite will work also, as will a legacy version, which may have stability and/or power advantages. For the Pi 4 or Pi 3 select 'Raspberry Pi OS (64-bit)'.

  5. When you have chosen your OS in the Pi imager software, and the storage medium i.e. the drive with the SD card, you are not finished. It is best, especially for headless operation, before pressing write, to click on the cog-wheel icon in the imager interface to perform some settings in advance. Set the name of the Pi, your username, password, and the wifi settings, especially not forgetting the country code (though in my installation process on a Pi with a display i.e. not headless, I had to set this manually again in the top bar wifi icon). It might be best not to leave the default computer name if you have, or intend to have, others Pi computers on your home network, as this might lead to confusion later when you seek the IP address of the Pi (see below). This setting up using the cog-wheel can be omitted when installing on the Pi 4 or Pi 3 with a screen (i.e. not headless) because a pop-up will ask you the same questions. It might turn out that for an installation, this step of settings the wifi using the cog-wheel settings, does not suffice to get wifi access immediately, and if so, all is not lost, see the step 10 below.

  6. For headless setup, especially for the Pi Zero, because the Raspberry Pi OS might block the wifi initially (due to the process 'rfkill', particularly e.g. if the country was not set), plug the Pi into an wired ethernet cable using a adaptor, as this is a fail-safe approach that will always make the Pi show on your router or in the output of any command line command listing the addresses on the network. Then carry out the step below. Alternatively, carry on to the next steps and you will see if the wifi is working as it was set when flashing/writing the OS above.

  7. If you are working headlessly (no screen), you need the IP address of the Pi on your local network. One can obtain the ip address of the Pi on your local (home) network by inspecting your network in your router via an internet browser when connected to your local (home) network. A typical way of doing this is to put in the router's ip address into a browser on the setup computer connected to the specific wifi network you are using with the Pi. The IP address used to acces the router is normally mentioned by you network provider, or router vendor, in their documentation and/or web help pages. When you enter the IP address in a browser tab, the router control panel appears and will ask your for a password. If it is the original password, this should be written on the router itself, and is different to the wifi password.

  8. An alternative way, for headless use, to find out the required IP address of the Pi is to use the command line of the Linux setup computer used to flash the OS. In the setup computer, install nmap (sudo apt install nmap) and use sudo nmap -T4 192.YYY.XXX.0/24 where YYY and XXX are the known IP range parts for your home network.

    To get the IP address range you need, find the IP address of your setup computer: in Ubuntu use hostname -I which will return something like 192.YYY.X.Z . The first three sets of numbers 192.YYY.X. should be those used in the command sudo nmap -T4 192.YYY.X.0/24 just mentioned. Alternatively, another way to get the IP address of your setup computer (to get the first three known parts of the IP range to use in the nmap command above) is to use nmcli -p device show and it is listed after IP4.ADDRESS[1] (ignore the / and the number after it).

    Now run the command sudo nmap -T4 192.YYY.XXX.0/24 at the command line of the setup computer. Wait a while - it takes a few minutes. Inspect the output to find the IP address associated with the name given to your Pi.

    For the purposes of this installation guide, let's say the wired LAN ip address of the Pi is represented by 192.168.W.XYZ

  9. If you have a screen and keyboard attached to your Pi, open up a terminal on the Pi. If you have the OS with desktop installed, the IP address of the Pi is shown if you hover with the cursor over the wireless connection icon in the top bar.

  10. If you are working headlessly, you need to get at the terminal prompt of the Pi by connecting via ssh into the Pi from your setup computer, then ssh into the Pi from your setup computer in the command line of your setup computer as follows:

    ssh username@192.168.W.XYZ
        

    where 192.168.W.XYZ just stands for your Ethernet wired LAN IP address found out as above, or use wifi IP address if wifi is already working. The username is that which was set in when writing/flashing the OS onto the SD card using the Pi imager. Use the password you set above, and answer appropiately concerning any ssh key questions.

  11. If your wifi is not yet working, then to get wifi connection with the headless Pi you can do the following:

    First, a remark. You may find it best to use a wired LAN connection for the installation because wifi might have a worse internet connection that interferes with, or slows down, the installation process. Then you can use wifi later, when running MeshChat, to interface to the MeshChat GUI to use the node. This is useful if the node is e.g. in the attic or out of reach high up. However using a poor wifi connection to the rnode makes controlling it over wifi not much fun, so make sure there is a good wifi connection to the wifi used by the computer running the browser that controls the rnode. Typical wifi connection improvements can be achieved by using a second wifi router strategically placed nearer the Pi, where the second router is set up connected by LAN cable to your existing local network and configured as an 'access point'. The Pi, and computer whose browser controls the Pi by providing the MeshChat GUI, would then use the SSID and password of that access point. When testing radio based communications you really do not want any in-house connection problem to the node itself, as that would add a layer of confusion.

    To get wifi working on the Pi:

    (1) at the command line of the Pi (which you are connected to via LAN cable), use sudo raspi-config, using the tab key, go to system - wireless, and enter the exact name of the wifi network (SSID) and then the password (which is called the 'passphrase' in raspi-config settings). I had a bit of keyboard trouble at times, and so used right-click paste to paste in the information.

    (2) use the above step 7 to use the router or command line to find the wifi IP address of the Pi

    (3) disconnect the Ethernet LAN cable, and run the ssh using the wifi IP address e.g.192.168.W.ABC that you found out in step 7:

    ssh username@192.168.W.ABC
        
  12. Now go to the command prompt of the Pi, or in the case you have connected to the Pi via wired LAN or wifi, you are at the command prompt of the ssh connection into the Pi.

    To be on the safe side, unplug the rnode from the Pi's USB socket.

    Now at the command prompt do the following.

    Paste in each of these commands into the command line in sequence and press enter, waiting for it to complete before continuing. (Pasting into the terminal is not done with Ctrl+V but with Ctrl+shift+V or similar for your system; or right click with the mouse/pointer). # is just a comment about what to do, or not do, and does not need pasting.

        
        sudo apt update
    
        sudo apt full-upgrade #remark answer Y to install the package manager's version of the configuration file '.../autostart'
        
        sudo reboot
        
        sudo rpi-update
        
        sudo reboot
    
        sudo apt install git
    
        sudo apt install python3-pip
    
        curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/nodesource.gpg
        
        # in ubutntu a question pops up as to whether to overwrite, and just answer 'yes'
         
        NODE_MAJOR=22
    
        echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
    
        sudo apt update
    
        sudo apt install nodejs
      
        git clone https://github.com/liamcottle/reticulum-meshchat
      
        cd reticulum-meshchat
    
        # if your are doing this on Ubuntu 22 (Ubuntu 24 is different yet again) omit the flag --break-system-packages
        pip install -r requirements.txt --break-system-packages
    
        npm install --omit=dev
        
        #run npm audit fix if it suggests to do so
        npm audit fix
        
           
        # remark: the one next step immediately below is only if you are settings up the Pi Zero where otherwise there is a Java heap error, otherwise skip to the next step shown i.e. npm run build-frontend
        export NODE_OPTIONS=--max-old-space-size=512  
    
        npm run build-frontend
    
        
        
  13. If you are working directly on the Pi with a screen and keyboard, you can execute this command in the command prompt:

    python meshchat.py
        

    and, hey presto, Reticulum MeshChat will appear and can be used. Remember to set the settings of the Pi (and your setup computer), remembering that you want the Pi rnode to be set to be a transport interface, and also maybe gateway node if it is to be a fixed node.

    The above steps are present in part of this video from 21:17 to 32:35.

    If you have run the above installation commands on Ubuntu 22, then to run MeshChat do:

    python3 meshchat.py
        
  14. If you are working headless over ssh, you execute this command (using the ssh session in the setup computer) at the command prompt of the Pi:

    python meshchat.py --headless --host 0.0.0.0
        

    Then in a browser tab on your computer, go to the following URL i.e. put this in to the address bar and hit enter:

    192.168.W.XYZ:8000 if you used the Ethernet LAN connection for the session

    192.168.W.ABC:8000 if you are used your wifi connection for the ssh session

    where 192.168.etc. is the Pi's IP address in your local (home) network.

    Now the browser on your setup computer (which is in the same network) should show Reticulum MeshChat GUI in a browser tab, and of course that is the Reticulum MeshChat program that is being run by the Pi, but seen on your setup computer.

    If you are using a VPN, then that may stop this from working unless you turn it off.

    It can be handy to run a node over a browser tab even if the node is being run, not by a headless Pi, but by a computer/laptop running under Ubuntu. Even then you can use a second different machine connected to the same local area network, to control the node via the a wifi/LAN connection. This makes working with the node far easier than using rustdesk or other vnc (virtual network computer) solutions, especially if the node's Ubuntu machine is not very accessible. To enalbe this for an Ubuntu installation run the following command:

  15. python3 meshchat.py --headless --host 0.0.0.0
        

    and use 192.168.W.XYZ:8000 or 192.168.W.ABC:8000 in the browser of the second machine on the same local area network (LAN).

     

  16. If you have Reticulum MeshChat up and working, it would be a good idea to do at least the following things:

    Add the rnode interface (assuming you have a flashed rnode ready and plugged in via usb to the Pi), set in settings the rnode to be a transport node and maybe gateway interface (otherwise it will not pass messages in the mesh not destined for the Pi), type in your identity into the field and press save to help you see yourself in the network visualiser.

    If you want to test the rnode with another rnode to see if you can pass messages by lora radio, then you have to make sure that the internet connection on the Pi and the other rnode's computer is off (no wifi and no LAN cable), or just make sure the default interface is switched off in the MeshChat interfaces menu, otherwise the messages get passed by the internet and you are not testing the radio link.

  17.  

  18. The next part is also thanks to Simon Phillips, who cracked the following issue. You want the Pi + attached rnode to keep functioning when the ssh session ends, and also want the Pi + attached rnode to automatically work as a mesh node that passes messages when the Pi is powered. This can be done by setting a service in the OS as follows:

  19.  

  20. Run the following in the command line:

    
        sudo nano /etc/systemd/system/reticulum-meshchat.service
        
  21. Then in the nano editor that appears, paste in the text shown below except replace the word "username" with the username you set at the beginning i.e. your username, in the four locations shown in the text:

    If you are not running headless at all, but with a display on the Pi, then you can omit --headless --host 0.0.0.0 from the ExecStart command below.

    If you are running headless then there is no need for the entry Environment=DISPLAY=:0 below. This entry ensure that when the Pi is booted again the service opens the Reticulum MeshChat GUI in a browser window. Omitting Environment=DISPLAY=:0 results in Reticulum MeshChat not being visible on the display after booting, even though it is running.

        
        [Unit]
        Description=reticulum-meshchat
        After=network.target
        StartLimitIntervalSec=0
    
        [Service]
        Type=simple
        Restart=always
        RestartSec=1
        User=username
        Group=username
        Environment=DISPLAY=:0
        WorkingDirectory=/home/username/reticulum-meshchat
        ExecStart=/usr/bin/env python /home/username/reticulum-meshchat/meshchat.py --headless --host 0.0.0.0
    
        [Install]
        WantedBy=multi-user.target
    
        
        

    Press Ctrl + x and answer y and press return to save the file.

  22. Now at the terminal run the following commands one after the other.

        
        sudo systemctl start reticulum-meshchat.service
    
        sudo systemctl enable reticulum-meshchat.service
    
        sudo systemctl status reticulum-meshchat.service
    
        
        
  23. Now Reticulum Meshchat is running.

  24. Now, every time the Pi starts up after being shut down and/or having its power cable removed, the rnode attached to the Pi will operate as an rnode without you having to issue any further commands. The Pi Zero is still being tested to see whether, if it shuts down due to a battery running flat, the RAK 100% of the time restarts without a manual reset of the RAK using the reset button being needed. One can test to see if the node plus Pi has restarted in a functioning manner, after power is returned, by messaging the rnode run by the Pi when you see its announce on another rnode, or by sending a message.

  25. Hats off to Simon Phillips for this solution above.

  26. If you are at the command line of the Pi after booting and you want to see which services are running, including seeing if the Reticulum MeshChat service is running, you can run the following command:

        
        systemctl list-units --type=service --state=running 
        

    To exit the displayed information and return to the command prompt, press Ctrl+c. If you want to stop the Reticulum MeshChat service at the command line, type the following:

        sudo systemctl stop reticulum-meshchat
        
Lora SDR announce data

Connecting wirelessly to your headless rnode to use the MeshChat GUI on an interface device with a display e.g. laptop or Apple iOS smartphone / tablet

The rnode is used via the MeshChat GUI, to send messages etc.. The MeshChat GUI can be used via a browser interface on an interface device, such as a laptop/tablet/smartphone. The MeshChat GUI is accessed in a browser by putting the URL "<ip_address_of_pi>:8000" into the address bar of a browser.

The Raspberry Pi can provide an independent wifi hotspot. In the steps below the result is that the interface device (laptop/tablet/smartphone) is connected by wifi only to the rnode, and so you would lose internet access by wifi on that interface device (laptop/tablet/smartphone). See section below for alternatives that might preserve wifi connectivity to the internet while also connecting by wifi to the rnode to use MeshChat.

The Pi can be set up so that the hotspot is automatically available as soon as it boots. You can then use the rnode, via the wi-fi interface device (laptop/tablet/smartphone) with a display, as soon as the node is powered up. The fact that the Pi provides the wifi connection, allows you to use the rnode in an entirely portable manner, because you are not bound to any home wifi network. This is, of course, just like the bluetooth connection used in Meshtastic, or by sideband, to run a node from a smarthphone, but here the rnode is using wifi rather than bluetooth. Wifi has range advantages. It appears that a Raspberry Pi Zero 2W operating a RAK node and running a wifi hotspot uses about 1.0 W on average.

To make the Pi provide its own wifi hotspot, and to use the rnode, do the following.

  1. Disclaimer: the below worked for me and is hot off the press, and I am no Linux expert. If there are problems with this, or stupidities, my apologies. There may be a better solution using the sudo systemctl enable servicename.service and sudo systemctl start servicename.service commands.

  2. Run the following in the command line to make a service you are calling "hotspot":

    
        sudo nano /etc/systemd/system/hotspot.service
        

  3. To name the hotspot e.g. "pizero2hotspot" and give it the access password e.g. "reticulum", paste the following into the editor to make the .service file:

    
        [Unit]
        Description=hotspot
        After=network.target
        StartLimitIntervalSec=0
    
        [Service]
        Type=simple
        Restart=always
        RestartSec=1
        ExecStart=nmcli device wifi hotspot ssid pizero2hotspot password reticulum
        ExecStop=sudo systemctl stop hotspot
    
        [Install]
        WantedBy=multi-user.target
        

    and save by using ctrl+x and answering y.

  4. To find the IP address that the Rasberry Pi has given itself, you need to connect the Pi by wired LAN cable to the home local area network (LAN). Do this with an adaptor, such as this one, plugged into the USB A micro port. This means unplugging the rnode briefly from the Pi. When you have a wired connection, you can ssh into the Pi over the wired connection using the IP address of the wired connection by using username@192.168.W.XYZ. The wired LAN IP address of the Pi is found as described in point 7 above.
  5. At the command prompt run ifconfig and read off the IP address of the Pi wlan0 entry e.g. 10.42.0.1 . I will call this address <ip_address_of_pi>. It will not change (as far as I can tell) so you hopefully only need to do this once and make a note of it for all future connections, though the browser history will usually show it.

  6. Disconnect the wired LAN connection from the Pi and plug the rnode back into the USB A micro port.

  7. Connect your interface device (laptop/tablet/smartphone) by wifi to the hotspot of the Pi by selecting the wifi network named pizero2hotspot and entering the password 'reticulum' as set above.

  8. Now open a browser on the wi-fi interface device (laptop/tablet/smartphone) and put '<ip_address_of_pi>:8000' into the address bar. You can use a laptop, iPad or iPhone. Not all Android devices seem to support this mode of access (which is really hard to fathom).

  9. The wifi connection provided by the rnode's Pi to your wi-fi interface device (laptop/tablet/smartphone) is then unfortunately of course dedicated to the rnode only, and such that the wifi interface on your wi-fi interface device (laptop/tablet/smartphone) is used up, and cannot also provide internet. See the alternative below if you do not want this disadvantage.

  10. You may find that the wifi connection allows you to place the node easily outside for best radio reception, and use the MeshChat GUI on the device comfortably at a distance away from the node.

  11. A build using the above approach.

Alternative ways to connect an interface device (laptop/tablet/smartphone) by wifi to your Pi+rnode while also keeping the interface device connected to the internet/LAN

Lora SDR announce data

Next steps

Remember: If you want to test the rnode with another rnode to see if you can pass messages by lora radio, then you have to make sure that the internet connection on the Pi and the other rnode's computer is off (no wifi and no LAN cable), or the default interface is deactivated in the MeshChat settings, otherwise the messages get passed by the internet and you are not testing the radio link.

The automatic restarting of MeshChat represents a big step forward in the case that the rnode + Pi are run on a battery which runs flat and needs swapping for a new full one, or a battery that is re-charged by solar power when the sun is strong enough, and is perfect for running an rnode in a car from the USB power supply because the node will just start up automatically when you start the car. This setup means that the battery / solar node will act autonomously as it should in the mesh after so-called brownout, provided it is provided with enough power again at the right voltage level. With an automatically starting rnode, a solar rnode could be out of reach e.g. on a roof, and yet resurrect itself of its own accord when power and voltage is sufficient again thanks to nuclear fusion (sunlight).

If you have ever tried making a Meshtastic solar node start every time after a power outage (brownout due to lack of sun) without manual intervention, then this setup will probably be right up your street: but the solar power demands will be far higher in this setup here for the Pi: far higher than than a stand-alone node, as in Meshtastic nodes, that need no Pi/computer to run it. Thus running a Pi node permanently via solar power will require a correspondingly large solar setup e.g on the roof or balcony, with much larger battery and much larger panel than a small solar Meshtastic node. In the long-run, of course, the option of moving the necessary code for a transport node entirely on the node is a nice prospect, though ESP32 nodes (like the Lilygo T-beam, T3S3) are in any case far higher (10x) in power demands than a RAK or T114 system and need some special solar designs to keep them running.

The image below shows a Raspberry Pi 4 with Lilygo T3S3 and fully-charged Anker 737 Power Bank 24,000 mAh, reading about 3W and reporting 20 hours of power remaining. This reading fluctuates up to 4 W and then it reads 13 hours remaining. The proof of the pudding is in the eating and a test showed almost exactly 13 h of power was provided from the full battery.

Raspberry Pi 4 with Lilygo T3S3 and Anker 737 Power Bank reading about 3 W and reporting 20 hours of power remaining.

Image below shows a Raspberry Pi Zero 2W (running Raspberry Pi OS Lite (32-bit) bookworm) with RAK4613 (RAK WisBlock Meshtastic Starter Kit SKU 115017) and fully-charged Anker 737 Power Bank (24000 mAh), reading about 0.8 W and reporting 48 hours of power remaining. This reading fluctuates up between 0.6 and 1.0 W, and then it reads 50 to 41 hours remaining. In tests the 24000 mAh battery running the Pi Zero from the USB A port lasted 48 hours (Pi Zero was not running wifi, but Bluetooth was not off)

Raspberry Pi Zero with RAK node and Anker 737 Power Bank reading about 0.8 W and reporting 48 hours of power remaining.

Some Pi & Linux tips

Last edit 03-07-2025 MMDDYYY 12:00:00 EST

Lora SDR announce data