Configuring mesh networking for the IoT Edge
Implement mesh networking over wifi with Raspberry Pis
This code pattern is part of the 2020 Call for Code Global Challenge.
The 2018 Call for Code Global Prize winner, Project Owl, implemented an IoT hardware solution that created a mesh network when it is deployed. While mesh networking topologies are not new, with IoT hardware becoming more and more affordable, mesh networks are a more viable solution for the Internet of Things.
In this tutorial, we present the high-level steps (from our workshop) that are involved in setting up a mesh network over wifi using Raspberry Pis and then using the mesh network to connect sensors to the Internet and allow other devices that are not part of the mesh network to connect to the Internet by using the mesh network. The following figure shows this mesh network topology.
To understand more about what a mesh network is and why they are useful in IoT solutions, read the workshop section on mesh networks.
Configuring mesh networking for the IoT Edge involves these three main steps:
This mesh network requires at least 2 Raspberry Pis, with SD cards to hold the file system, and power supplies for each Pi. You’ll also need temperature and humidity sensors and an RGB LED. Also, you’ll need an Ethernet connection, or a wifi connection, and of course Internet connectivity as well.
You can complete this tutorial using an IBM Cloud account.
For the complete list of prerequisite hardware, software, and knowledge for this project, read the prerequisites section of the main readme file for the workshop.
Set up the mesh network
In Step 1, you set up the mesh network over wifi and also set up network access for the mesh devices. You’ll use an Ethernet connection to connect the mesh network to your home or office network and also to allow non-mesh devices to use the mesh network to access the internet.
Create a mesh network over wifi
We use the batman-adv standard Linux kernel module to create the mesh network on the Raspberry Pi. This module will enable the Pi to send network traffic over the mesh network.
Follow the steps in the “Build a mesh network” section of our workshop.
Set up network access for the mesh devices
Now that you have created the mesh network you need to allow the nodes of the mesh network to access the internet. To do this, you need to add a gateway device to the mesh network. Also, you need to allow non-mesh devices to use the mesh network to access the internet and other nodes of the mesh network. To do this, you need to add a bridge device to the mesh network.
Complete the steps in the “Network access” section of our workshop.
Connect the mesh network using wifi
In Step 2, which is optional, you connect the gateway device to your home or office network using wifi (instead of Ethernet) and also turn the bridge device into a wifi hotspot so that you can bridge wifi-connected devices into the mesh network. The following figure shows the mesh network using wifi.
If you do not need a wifi-enabled gateway or bridge device, you can skip this step and move on to Step 3.
Connect your gateway to your network via wifi
To convert the Ethernet connection to a wifi connection and to route mesh traffic over the wifi connection via the gateway device, complete the steps in the “wifi gateway” section of the workshop.
Create a bridge access point
To convert the bridge node into an access point and enable the network traffic coming over the access point to access the mesh network, complete the steps in the “wifi bridge” section of the workshop.
Create an IoT app that sends sensor data over the mesh network
Finally, in Step 3, you will build an Internet of Things application that gathers sensor data and uses the mesh network to send the sensor data to the IBM Cloud. An IBM Cloud app receives and processes the sensor data and sends a command back to the Raspberry Pi to set the color of the LED light on the Pi.
In this step, you connect the sensors, install Node-RED and some Node-RED packages, create the IoT app in IBM Cloud, and send the sensor data across the mesh to Watson IoT Platform.
Complete the steps in “Part 3” of the workshop.
Summary and next steps
With this tutorial, we tried to demystify the process of configuring mesh networking for the IoT Edge. Can you imagine other IoT solutions that can make use of mesh networking?