The RFM69HW and optional BMP085 modules are mounted on a Slice of Pi board. The BMP180 sensor uses the same protocol as the BMP085 and has also been tested.
RFM69HW | Slice of Pi | Notes |
---|---|---|
NSS | SPI_0 | |
MOSI | MOSI | |
MISO | MISO | |
SCK | SCLK | |
GND | Connect to GND at end of XBee connector | |
ANT | Connect 1/4 wave wire as antenna | |
3.3V | 3V3 | |
DIO4 | G23 | Wiring Pi 4 / GPIO23 |
DIO0 | G17 | Wiring Pi 0 / GPIO17 |
RESET | G04 | Wiring Pi 7 / GPIO04 |
BMP085/BMP180 | ||
GND | GND | Next to 3V3 |
+5V | 5V0 | Some breakout boards use a 3.3V supply |
SDA | SDA | |
SCL | SCL |
Based on daveake's “Basic working receiver” code which I used as a testbed to develop changes to mitigate the effect of interference and now provides a reliable gateway.
Install git and the curl and wiringpi libraries: sudo apt-get install git libcurl4-openssl-dev wiringpi
An initial download can be done with:
mkdir ~/ukhasnet ; cd ~/ukhasnet && git clone https://github.com/dbrooke/UKHASNetPiGateway.git
After which the submodules for the libraries can be initialised with:
cd UKHASNetPiGateway && git submodule update --init --recursive
The software should then build without errors by typing:
make
Configuration is read from a file gateway.ini which needs to be present in the directory from which the software is started.
A sample file is provided with all parameters commented out and showing the default value where applicable. A minimal configuration requires the node ID to be specified.
By default the software provides gateway functionality without any telemetry from the gateway itself, other than the bootup packet with the location data (if specified in the configuration file).
If the Pi is fitted with a BMP085 (or BMP180) pressure and temperature sensor then data from this can be periodically uploaded. This support can be enabled in the configuration file.
The xAP support is experimental and currently just broadcasts a message with the raw UKHASnet payload. It is likely to be replaced with MQTT.
To make sure that the SPI bus is enabled run sudo raspi-config and then select Advanced Options where you should see SPI listed and can enable it. If you have a BMP085/BMP180 sensor fitted then you should also enable the I2C bus.
Access to the SPI bus requires that the program is run as root, so from the build directory run sudo ./gateway
My preferred method to invoke the program, so that it is started when the system boots and still allows a console to attach to observe its operation, is to start it in a detached screen session from cron.
Install screen on the Pi by running sudo apt-get install screen
The following assumes the use of the default pi
account and that the repository was cloned below /home/pi/ukhasnet
Run crontab -e which will open your crontab file in an editor and add the following line at the bottom of the file:
@reboot /usr/bin/screen -dmUS gateway /usr/bin/sudo /home/pi/ukhasnet/UKHASNetPiGateway/gateway
If the name of the system running the gateway is ukhasnet-gw
then the following command on a linux desktop system will attach to the running gateway and display its output in a new window:
uxterm -title ukhasnet-gw -e ssh ukhasnet-gw -t screen -d -r gateway
To detach, leaving the gateway running, enter CTRL-A followed by d