Crowdsourced IoT Data: Accessing The Things Network With Eclipse Scout
A tutorial on using Eclipse Scout and The Things Network to measure noise levels.
Join the DZone community and get the full member experience.Join For Free
The Things Network (TTN) is an open source project that aims at a global crowdsourced Internet of Things data network. In this blog post we describe a complete TTN show case to create real-time noise maps using the TTN in Zurich using a backend application based on Eclipse Scout and the MQTT Paho library.
TTN: A Brief Introduction
After a highly successful campaign on Kickstarter last year, the project is now implementing the necessary infrastructure, designing and producing the promised hardware and spreading the word, for example at Eclipsecon next week.
The major benefits of the project are its distributed open source approach, the low price of the components, the range of several kilometers for gateways, and the low power consumption of the involved LoRa technology for the “fog” part of the system.
The diagram below provides an overview over the setup including the noise measuring nodes and the TTN Gateways (the “fog”) on the left side, the TTN Cloud in frastructure in the middle and the backend application on the right side.
The described setup is currently using the somewhat simpler TTN prototype infrastructure. This setup is available since last year as well as instructions on how to set up your own gateway and your own nodes.
For the goal of this post the relevant aspects are the nodes on the left side that connect to one or more TTN gateways and the application on the right side that connects to a TTN handler service.
Low Cost Nodes for Measuring Noise
The goal was to assemble 40 complete nodes for less than €40. As a basis of the component selection we were using Teensy TTN node described in TTN Wiki. Due to additional taxes and some minor “mishaps” during production we ended up at €44 per node instead.
As shown below, the final node contains a microphone (1), a Teensy LC (2), a RFM95 LoRa module (3), an antenna with a company flag (4) as well as a battery box (5) inlcuding 3 AA batteries.
After being switched on, the node starts to measure differences in air pressure levels over short time windows that roughly correspond to the current noise level. Every two minutes the node then transmits the largest measured noise level and the “amount” of noise accumulated over the two minute period.
When the node is located within the range of a receiving TTN gateway, the data package is then forwarded to the TTN prototype setup.
The source code of the noise measuring node is available on Github.
The Scout Backend Application and a MQTT Paho Client
As the TTN prototype setup also includes a MQTT interface it is straight forward to implement applications that can response near real time to incoming TTN packets.
To implement an end-to-end TTN showcase, a backend application was implemented to display the data packets sent by the TTN noise nodes. The implementation of the user interface is based on Eclipse Scout, and for the communication with the MQTT broker, the Paho Java Client Library is used.
The screenshot below shows the transmitted noise levels with its corresponding time stamps. Noise levels of 10 or more indicate a train
By assigning coordinates to noise nodes, the Scout application can also show the noise levels on a real-time map. The picures below shows two situations with four noise nodes distributed at the outside of the BSI office in Zurich. During a time window with trains passing higher noise levels were measured by nodes that sit closer to the railway tracks (left image) than during a time window without any passing trains (right image).
As in the case of the noise measuring nodes, the source code of the Scout TTN application is available on Github. In addition, the application is also available as a Docker image on Docker Hub and deployed as a live instance.
Published at DZone with permission of Matthias Zimmermann. See the original article here.
Opinions expressed by DZone contributors are their own.