Raspberry Pi based IoT gateway with Waveshare SX130x 868M/915M LoRaWAN Gateway Module.
- raspberry pi 4 4GB RAM
- 16GB microSD card
- USB-C power supply 3A
- Waveshare SX130x 868M/915M LoRaWAN Gateway Module bought here
- XBee pro 900HP 250mW RPSMA bought here
- 915MHz 3dBi RP-SMA Antenna bought here
- XBee USB Adapter bought here
The Waveshare product wiki can be found here
- ubuntu server 22.04 LTS 64bit (arm64) - OS for the gateway
- docker & docker-compose - to run main network services
- ansible (for setup) - to install and configure the gateway remotely
- pi-hole - ad blocker and DNS/DHCP server
- hostapd - wireless access point
- emqx - mqtt broker
- influxdb & telegraph - time series database and ingress from mqtt
- homeassistant - home automation platform
- node-red - flow based programming for IoT automation
- basicstation - lora-gateway-bridge connected to the things network
- homer - dashboard / landing page for all the services
The pi needs an OS image installed on the microSD card. The image is installed on the microSD card using the Raspberry Pi Imager. The OS image can be selected from the menu. It is a good idea to set up ssh and a default user when flashing the image. This can be done using the settings menu in the imager.
Make sure the use the ubuntu server 22.04 LTS 64bit (arm64) image. This is the only image that will work with the ansible playbooks provided (probably).
Once the image is flashed, the microSD card can be inserted into the pi and the pi can be powered on. The pi will boot and the OS will be installed. Once the OS is installed, the pi will reboot and the OS will be ready to use. Power cycle the pi to make sure that it boots up correctly after the installation.
The rest of the setup can be done remotely using ansible.
The gateway is configured to connect to the things network using a service called basicstation. The gateway will need to be registered with the things network. The gateway ID and key will need to be added to the environment
files.
Ansible remote ssh password requires sshpass to be installed on the local machine.
# install sshpass
sudo apt install sshpass
# use the ask pass option in ansible commands
ansible gateways --ask-pass -m ping
Once the code is downloaded, create a virtual python environment and install the requirements. This will install ansible tools and the python libraries required to run the ansible playbooks.
#Install a virtual python environment (make sure that python3 venv is installed)
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Create some secrets for the gateway. This will create a env/env.yaml
file in the project. This file is used by the ansible playbooks to configure the gateway.
# create a env/env.yaml file from the example
mkdir env
cp env.example.yaml env/env.yaml
# edit the env/env.yaml file and change credentials
# Run ansible setup playbook
ansible-playbook -k -K install.ansible.yaml
# start services
ansible-playbook -k -K start.ansible.yaml
Log in to the to verify the installation.
# login to the gateway
ssh scitech@piot-gw-001 # replace 001 with the number of your gateway
To test the containerized services, log in to the gateway and run the docker compose file (without the -d
option).
# run the docker compose file
cd /home/scitech/ws/scitech-piot-gw
# start and detach services
docker-compose up -d
There is an access-point, dhcp/dns server, mqtt broker, time series db, node-red, and lora gateway running on the device. Some of these are accessible via the web interfaces.
The SSID is: piot-gw-00x
The password is configured in the .env
when created.
Go to: http://piot-gw-001/admin (change 001 to the number of your gateway)
The password is configured in the .env
when created.
Go to: http://piot-gw-001:18083 (change 001 to the number of your gateway)
The password is configured in the .env
when created.
Go to: http://piot-gw-001:8086 (change 001 to the number of your gateway)
The password is configured in the .env
when created.
Go to: http://piot-gw-001:8123 (change 001 to the number of your gateway)
Go to: http://piot-gw-001:1880 (change 001 to the number of your gateway)
This is not password protected.
Go to: http://piot-gw-001:8080 (change 001 to the number of your gateway)
This is not password protected.
Go to: https://piot-gw-001:9443 (change 001 to the number of your gateway)
This service will need to be configured with a username and password when it is first run.