Skip to content

Raspberry Pi based IoT gateway with Waveshare SX130x 868M/915M LoRaWAN Gateway Module

License

Notifications You must be signed in to change notification settings

UC-SciTech/scitech-piot-gw

Repository files navigation

scitech-piot-gw

License: MIT Open in Visual Studio Code

Raspberry Pi based IoT gateway with Waveshare SX130x 868M/915M LoRaWAN Gateway Module.

Hardware

  1. raspberry pi 4 4GB RAM
  2. 16GB microSD card
  3. USB-C power supply 3A
  4. Waveshare SX130x 868M/915M LoRaWAN Gateway Module bought here
  5. XBee pro 900HP 250mW RPSMA bought here
  6. 915MHz 3dBi RP-SMA Antenna bought here
  7. XBee USB Adapter bought here

Waveshare SX130x 868M/915M LoRaWAN Gateway Module Documentation

The Waveshare product wiki can be found here

Software

  1. ubuntu server 22.04 LTS 64bit (arm64) - OS for the gateway
  2. docker & docker-compose - to run main network services
  3. ansible (for setup) - to install and configure the gateway remotely

Services

  1. pi-hole - ad blocker and DNS/DHCP server
  2. hostapd - wireless access point
  3. emqx - mqtt broker
  4. influxdb & telegraph - time series database and ingress from mqtt
  5. homeassistant - home automation platform
  6. node-red - flow based programming for IoT automation
  7. basicstation - lora-gateway-bridge connected to the things network
  8. homer - dashboard / landing page for all the services

Set up

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 Things Network

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.

Password SSH

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

Installation

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

Administation

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.

Access Point (hostapd)

The SSID is: piot-gw-00x The password is configured in the .env when created.

pi-hole

Go to: http://piot-gw-001/admin (change 001 to the number of your gateway)

The password is configured in the .env when created.

emqx

Go to: http://piot-gw-001:18083 (change 001 to the number of your gateway)

The password is configured in the .env when created.

influxdb

Go to: http://piot-gw-001:8086 (change 001 to the number of your gateway)

The password is configured in the .env when created.

home assistant

Go to: http://piot-gw-001:8123 (change 001 to the number of your gateway)

node-red

Go to: http://piot-gw-001:1880 (change 001 to the number of your gateway)

This is not password protected.

homer

Go to: http://piot-gw-001:8080 (change 001 to the number of your gateway)

This is not password protected.

portainer

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.

About

Raspberry Pi based IoT gateway with Waveshare SX130x 868M/915M LoRaWAN Gateway Module

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published