Skip to content

3. Headless Raspberry Pi Operation

Mark Jessop edited this page Oct 20, 2018 · 8 revisions

These are a basic set of instructions for setting up a Raspberry Pi as a LoRa Ground Station, using the horus_utils software.

This is useful if you want to deploy a standalone receiver somewhere, or if you want to have an automatic LoRa receiver running in the back of your chase car!

Requirements

  • A Raspberry Pi (2 / 3 / Zero / ZeroW). All will work.
  • Some kind of network connection for the Pi, be it onboard wifi/ethernet, or a USB WiFi dongle.
  • A LoRa Shield for the frequency band you are interested in.

Instructions

  1. Download the latest Raspbian image and copy it onto a SD card: i.e.
> sudo dd if=2015-11-21-raspbian-jessie.img of=/dev/mmcblk0 bs=4M
  1. Mount the SD card on your machine (assuming Linux here) and edit the following files:

2.1. If using WiFi: /etc/wpa_supplicant/wpa_supplicant.conf Add the following:

	network={
		ssid="YourWIFISSID"
		psk="YourWiFiPassword"
		id_str="MyWifi"
	}

You can add multiple network blocks if you wish.

2.2 /etc/hostname Modify this to something like:

loragatewayX

Assuming avahi works on your network & OS, this will let you ssh into the RPi at loragatewayX.local

2.3 /etc/hosts Add a line in here with the above hostname, so it resolves to localhost.

2.4 /boot (a different partition)

Create a file called 'ssh' i.e. using

$ touch ssh

This will enable ssh on next boot. You MUST do this before first boot, else SSH keys won't be generated.

  1. Unmount the SD card, insert into Pi, and boot up. If all went well, the Pi should appear on your network, and you should be able to SSH in using:
$ ssh pi@loragatewayX.local

(Default password: raspberry)

  1. Change the pi user's password!
$ passwd
  1. OPTIONAL: Create a user for yourself.
$ sudo adduser myusername
$ sudo usermod -aG sudo myusername
  1. Run raspi-config
$ sudo raspi-config

Do the following:

  1. Under "Advanced Options", Expand Filesystem

  2. Under "Interfacing Options", enable SPI

  3. On exit, let the pi reboot.

  4. Update the Pi.

$ sudo apt-get update
$ sudo apt-get upgrade

(wait a while...)

  1. Install the packages we need.
$ sudo apt-get install python-dev python-serial python-pip python-spidev python-requests python-shapely git 
$ sudo pip install crcmod
  1. Clone the required repositories.
$ git clone https://github.com/darksidelemm/pySX127x
$ git clone https://github.com/projecthorus/horus_utils.git
  1. Install the horus_utils libraries.
$ cd horus_utils
$ sudo python setup.py install
  1. Copy what we need out of pySX127x
$ cp -r ~/pySX127x/SX127x/ ~/horus_utils/apps/
  1. Check LoRaUDPServer.py runs...
$ cd ~/horus_utils/apps/
$ sudo python LoRaUDPServer.py --rpishield -d device -f frequency

Where:

  • devicenum = 0 or 1 (the SPI device ID, should be labelled on the LoRa shield, most use 0)
  • frequency = operating frequency in MHz (Project Horus launches use 431.650 MHz)

You should now be able to run the apps/HorusGroundStation.py python script on another machine on the network and see STATUS packets flowing.

  1. Make LoRaUDPServer.py autostart...
$ sudo nano /etc/rc.local

Modify the section after # Print the IP Address to read:

# Print the IP address
sleep 30
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
  python /home/YOURUSERNAME/horus_utils/apps/LoRaUDPServer.py --rpishield -d <device> -f <frequency> &
fi

exit 0

Optionally you might want to run TelemetryUpload.py on boot as well. Add the following line below the LoRaUDPServer line:

python /home/YOURUSERNAME/horus_utils/apps/TelemetryUpload.py YOURCALLSIGN &
  1. GPS UDP-Broadcast Server

If running, this will push out GPS position data out via UDP broadcast, and also push the receiver position to Habitat, either as a chase car, or as a stationary receiver (see default.cfg.example for info).

Copy and edit default.cfg.example as per the configuration instructions, and test that ChaseTracker_NoGUI works by running:

$ cd ~/horus_utils/apps/
$ python ChaseTracker_NoGUI.py

Add the following line under the loraudpserver line in /etc/rc.local if you want to run this at boot:

python /home/YOURUSERNAME/horus_utils/apps/ChaseTracker_NoGUI.py &
  1. Reboot and check it works!
$ sudo shutdown -r now

Once the RPi has booted, you should be able to run apps/HorusGroundStation.py on another machine to view the LoRa status information (in the main text box), and chase car position (under the 'Low-Rate Uplink' section at the bottom right of the window).

  1. OPTIONAL: Set up Tor hidden service access:

Follow instructions here: https://www.khalidalnajjar.com/access-your-raspberry-pi-globally-using-tor/

Clone this wiki locally