- Monitoring of temperature and humidity in different zones of the office building.
- Processing of collected telemetry with various alerting rules based on zone type: work space, meeting and server rooms.
- Distribution of collected alarms to assigned facility managers.
- Visualization of real-time and historical values on the configurable web dashboards.
Data flow diagram
Devices and ConnectivityWe decided to use quite cheap hardware based on ESP8266 and DHT22 sensor. The total cost of each device that includes sensor and connectivity module is approximately 5$. Since this is a prototype, we decided to use MQTT over WiFi and have not discussed other connectivity options.
Server-side infrastructureThe server-side part of the solution will be based on the Thingsboard IoT platform which is 100% open-source and can be deployed both in the cloud, on premises or even on Raspberry Pi 3. The collected data is stored to Cassandra database due to built-in fault-tolerance and scalability. We have recently launched Live Demo instance to simplify getting-started process, so we will use this instance in the tutorial.
Development and Configuration steps
Step 1. Device provisioningInitial step of the PoC was to provision several devices and their attributes. We’ve decided to support three zone types: work area, meeting and server rooms. We have registered three buildings with four rooms in each. During registration we have populated Zone Id, Zone Type server-side attributes. Note that the server-side device attributes may be used by the processing rules, but are not visible to the device itself.
Step 2. Flushing the devicesDuring this step we have flushed firmware update with individual device credentials built-in to the firmware. The firmware code and corresponding instructions are available in links below. We have used code from our previous article without modifications, since all the logic is on the server side.
Please note that steps 1 and 2 may be automated, we’ve developed simple java based application that performs provisioning of the devices and other entities using REST API and also emulates this devices for the live demo purposes.
Step 3. Processing RulesDuring this steps we have provisioned rules that analyze temperature and humidity against configurable thresholds based on zone type. For example, acceptable humidity range in server room is between 40% and 60%, however, humidity range for the work zone is from 30% to 70%.
Attributes filter body example:
typeof ss.ZoneType !== 'undefined' && ss.ZoneType === 'Server Room'
typeof temperature !== 'undefined'
&& (temperature <= 10 || temperature >= 25)
) || (
typeof humidity !== 'undefined'
&& (humidity <= 40 || humidity >= 60)
Step 4. Alarms distributionAt this step we have configured email plugin to distribute data using SendGrid mail service and provisioned rule action to send data to the configured mail address. Rule action consists of several templates that allow flexible configuration of email topic, body and adress list based on substitution of device attributes and telemetry values. For example, following email body template:
[$date.get('yyyy-MM-dd HH:mm:ss')] $ss.get('ZoneId') HVAC malfunction detected. Temperature - $temperature.valueAsString (°C). Humidity - $humidity.valueAsString (%)!
[2016-12-22 15:06:09] Server Room C HVAC malfunction detected. Temperature – 45.0 (°C). Humidity – 70.0 (%)!
Step 5. Data visualizationAt this step we provisioned several dashboards to visualize the data. We will describe them below.
Map dashboardThis dashboard shows multiple buildings on the map with their short status available in the tooltip. You can use links in the tooltips to navigate to Floor Plan and Historical Data dashboards.
Floor Plan dashboardThis dashboard uses static background image with the floor plan. We have placed widgets that show temperature and humidity in each room that is being monitored.
Historical dashboardThis dashboard shows last minute of sensor readings that are reported each second.
Live DemoIn order to demonstrate this PoC in action you need to do two simple steps:
- Sign-up or login to the live demo instance and save your login and password.
- Download and launch device emulator using this link.
java -jar facilities-monitoring.jar demo.thingsboard.io
- provision demo devices.
- create rules and dashboards.
- start emulation of the temperature and humidity sensor data for provisioned devices using MQTT.
ConclusionThis prototype was written by two engineers literally in one day. Most of the time was spent on the client-side code (Arduino sketch for real device and emulator). The server-side part of the prototype has zero coding and was all about configuration of the rules, plugins and dashboards.
This demonstrates how easy is to prototype and build IoT solutions using Thingsboard. Of course, there is certain learning curve that you need to pass, but we hope that this article and other docs will help you to do this.
- Compatible sample applications for different hardware platforms:
- Temperature upload over MQTT using ESP8266 and DHT22 sensor
- Temperature upload over MQTT using Arduino UNO, ESP8266 and DHT22 sensor
- Temperature upload over MQTT using NodeMCU and DHT11 sensor
- Thingsboard github page
- Emulator source code
- Emulator binary