Setup: software

There is now an easy interactive setup script that allows you to install this Gateway solution on a raw Raspbian image. But first let’s make sure you get the image prepared correctly.

Install raspbian, enable ssh, setup wifi

The recommended distribution to use is the latest RaspberryPi OS Lite on a Pi3 or better. If you’re new to RaspberryPi/Linux, you may find it useful to consult a Linux command cheatsheet such as this one during this process.

If you have a headless Pi (no monitor/keyboard) follow this official guide to enable ssh and setup your wifi credentials (before first boot). Other recommended steps:

  • change default password
  • change your Pi’s hostname to something other than raspberrypi
  • change timezone to where the Pi is located

Run the setup script

Open your Pi’s SSH/terminal and type these commands:

cd /home/pi
sudo wget https://raw.githubusercontent.com/LowPowerLab/RaspberryPi-Gateway/master/.setup/gatewaysetup.sh
sudo bash gatewaysetup.sh && sudo rm gatewaysetup.sh

This script was tested on RaspberryPi2 and 3. It installs everything required to support the Pi-Gateway app and will prompt you at various steps for information/passwords/etc.

Serial port check

By default the Pi-Gateway app is configured to work with the GPIO serial port /dev/ttyAMA0. The setup process automatically enables this port, disables the system console over it, and disables bluetooth (because it wired to it). Full details about the Pi’s UARTs and bluetooth module are found on this official page.

Now if your RF gateway (ex. Moteino, MightyHat) is attached to the GPIO serial you’re all set, the PiGateway app is ready to receive data.

To the GPIO serial port is enabled and bluetooth is disabled run sudo nano /boot/config.txt and ensure you have these lines at the end of this file:

enable_uart=1
dtoverlay=pi3-disable-bt

Also, ensure the console shell over serial is disabled. Run sudo nano /boot/cmdline.txt and make sure the token console=serial0,115200 is removed (only console=tty1 should remain). This can also be achieved within raspi-config (step 5 – interfacing options).

Using USB serial?

If your RF gateway (ex MoteinoUSB) is connected to a USB port, you will need to change the port setting on the UI Settings page once the app is installed. A USB port usually looks like /dev/ttyUSBn. You can use ls /dev/tty* to try to identify which one it is (ie run this command before and after connecting to the USB port).

Serial port debugging

It may be useful to debug the serial port. A lightweight serial terminal is picocom, install it with sudo apt-get install picocom. Next ensure no other application has that port open (ex. run sudo service gateway stop to stop the PiGateway app). Then open the serial port with picocom -b 19200 /dev/ttyAMA0. If your RF gateway is attached, you should start seeing packets coming in from your RF nodes.

FTP-ing into your Pi

It’s very useful to FTP into your Pi and you should install proftpd. The setup script offers to do it for you, but you can also do it manually at any time by running sudo apt-get install proftpd.

By default proftpd will not show hidden files (ex. anything prefixed with a .) so it’s useful to enable hidden files access – by running sudo nano /etc/proftpd/proftpd.conf and change the line ListOptions -l to ListOptions "-a".