A sensor network for the home.
The currently used architecture is made up of five parts:
- Sensor nodes
- Gateway
- Middleware
- Back end
- Front end (SPA)
The nodes in the diagram represent single programs or hardware modules. The groups - indicated by the fuzzy rectangles - represent devices or services. All components in red-ish/purple hues are custom developments. Components in blue-ish/teal hues are commercial of the shelf.
The sensor nodes are split into two modules: the controller including the radio and the sensor itself.
Details about the controller can be found in a separate repository.
There are two sensors breakout boards that are designed to work with the available controller:
For the gateway two different options have been explored:
- a simple USB device that communicates with the host using a custom driver
- using a single-board-computer to directly talk to the receiving module
The first iteration used an STM32 with a built-in USB interface. It worked fine, but it was unstable. After playing around with different options and versions of the STM HAL library, I concluded that it would be easier to have a dedicated chip for the USB interface.
In the second iteration, I used an FTDI USB to UART bridge chip. The gateway receives the messages from the sensor node, adds the RSSI and outputs them over USB (UART) as JSON strings.
{
"type":"rfm",
"rssi":"-74",
"data":"<encrypted message from sensor>"
}
The third generation of the gateway it built around the Laird BL651 module. Therefore, it operates in the 2.4-2.5 GHz region as opposed to the former gateways operating at 434 MHz. It uses the same FTDI USB to UART bridge chip as the second generation.
In a first iteration, the SBC implementation was implemented using a RaspberryPi Zero W and an RFM98 break-out. The code to interface with the RFM98 can be found in a separate repository.
The middleware consist of a simple ZeroMQ queue to which the data from the sensors are published as JSON documents. An agent subscribes to the queue and puts the messages into the repository.
The first iteration of the middleware can be found in a separate repository.
In the second iteration, is a re-implementation based on the second iteration of the USB gateway.
The third iteration is a re-implementation of the functionality of the second iteration in Rust.
The back end consist of a server implementing a web API and a postgres database. The currently used version can be found in the back end repository.
The front end was built as a single page application using vue.js. For the visualization of the data d3 was used. It can be found in the web app repository.
A former version of a REST service for serving the data can be found in the data api repository.