Logicify CTO, Dmitry Berezovsky, introduced our solution for air quality control at a local software development conference earlier this year. We made some progress and enhancements since then. This post discusses how the solution was built phase by phase.
We promised to share our experience on building a connected office in Logicify Kherson - an IoT solution to monitor and control office weather conditions: temperature, humidity and air quality. Our solution is based on ESP8266 WiFi and MCU, uses a web-configurable ESP Easy firmware and a custom designed board printed in China. Technical stack includes Mosquitto (implementation of MQTT server), Telegraf, InfluxDB and Grafana for data visualisation; we plan to add Home Assistant software soon.
Logicify Office Layout
Logicify Kherson office is a two-level open space with the main area and a separated kitchen zone. The main area has many windows and seats up approximately 50 workstations, a few cubicles and meeting rooms.
Season to season, we tried to keep up good office “weather” - so it is not too cold in winter and not too hot and stuffy in summer. Yet, this was not easy; hot air raised up, it was fuggy in winter, but we could not open windows as it became too cold. Objectively, our building has tricky air conditioning and heating systems, so it is hard to maintain stable climate during the day, and, subjectively, there are always people who are cold when others are hot, and vice versa. So instead of local measures, we needed a comprehensive and universal solution to keep up favorable office weather.
Our Action Plan
To solve the task, we came up with the following action plan:
- Define parameters that influence the office climate:
c) atmospheric pressure
d) air quality - level of CO2 concentration in the air.
- Define normal (standardized and generally accepted) figures for these parameters. These were: 25℃, indoor air humidity up to 40-60%, normal atmospheric pressure around 760 mm of mercury, and CO2 level around 1200 ppm.
- Split the office space into zones and track their specific weather conditions during the working day and for every season; store these data for further analysis.
- React to the changes in parameters accordingly and take certain measures when they aberrate - turn AC on/off, ventilate the rooms, adjust heating.
- Retrospectively analyze weather conditions in all office zones, discover trends and correct flaws in general office layout or its specific zone(s). We also wanted to measure how energy efficient our office was in the long run.
Existing Air Monitoring Solutions
With the above action plan in mind, we started looking for existing off-the-shelf solutions to measure and monitor office air quality. Here are a few solutions we found on the market.
Fundamental IoT Market Problems
These options have significant disadvantages, and we did not find a solution that worked for us because of a fundamental problem on the IoT solutions market.
Enterprise solutions are
- too complex and need a company-integrator, which is always time and money
- proprietary, so limited to a given functionality
- expensive because of hardware, licenses and subscription plan
- locked by vendor, so there is no access to hardware and software
Mass-market solutions are
- easy to use because aimed at general public
- cheaper than enterprise ones, yet with limited hardware ecosystem
- typically quite primitive and paired with low quality software
- not acceptable for us due to security loopholes
Both enterprise and mass-market solutions come with pros and cons. Yet we needed a solution somewhere in-between the two: solid and secure, at a reasonable price and with hardware and software that could be “tuned.” No existing solution satisfied our needs and wants, so we decided to build our own - using self-made hardware and open-source software. The solution we have today cost us approximately $25.
Logicify Air Quality Monitoring System
Phase 1. Prototype
We bought sensors to measure temperature, humidity, atmospheric pressure and air quality at AliExpress and wrestled with the prototype for air quality monitoring.
Soon we came up with a breadboard similar to a weather station built on Arduino. We compared different sensors and chose the ones that worked best to connect them to ESP8266, Wi-Fi microchip with full TCP/IP stack and microcontroller capability. We verified this prototype was working on NodeMCU, an open source IoT platform. Using custom, arduino-built firmware, we were able to collect our office weather conditions and display them on a local display. Inspired by this, we decided to make the solution more solid, so proceeded to Phase 2.
Phase 2. PCB vol.1
Hardware: We created a PCB layout with all the components and wiring. .
Instead of producing the prototype manually, we used an online printed circuit boards (PCB) fabricator service that made 10 sample PCBs with our design for $8. When we received our boards, we soldered all the sensors and other components together. The first board was ready, so we hung it up in the office to test.
Software: Meantime, we found a great open source microcontroller unit (MCU) firmware for ESP8266, ESP Easy. It is used to turn ESP8266 modules into simple multifunction sensor and actuator devices for home automation platforms. It could be loaded on the hardware and configured without programming, simply through its web interface. ESP Easy is essentially a small operating system for ESP MCU, which has data collection modules for different sensors, simple rule engine, wireless configuration module, and several modules used to transfer the sensor data for further processing, such as simple HTTP calls, integrations with HomeAssistant, and protocols such as SMTP. It can also email readings via designated email server.
Phase 3. PCB vol.2
Hardware: We monitored the way our PCB vol.1 worked for a while, fixed some design issues, added place for CO2 sensor on its outer side and ordered vol.2, which seems to be final - at least for today. We have 6 connected PCBs in the office.
Software: The end goal at this stage was to build a visual dashboard displaying graphs of the “office weather” conditions over time and a dashboard using colour-coding to display the entire set of current (momentary) information.
To build this connected solution, we used Eclipse Mosquitto, open source message broker that implements MQTT, a machine-to-machine/"IoT" connectivity protocol. MCUs gather sensor readings regularly at given intervals and then publish them to MQTT topics, so that they can be received by subscribers. We created a separate WiFi network with no Internet connection for ESP8266 and MQTT server, so it was completely secure.
On the other end, the same WiFi network had a Telegraf instance exposed on it. Telegraf was used to load the data received from MQTT topics into InfluxDB, a time series database and one of Grafana’s data sources. We have a separate time series for every sensor in InfluxDB, so all data could be visualized in Grafana graphs for further analysis. A large screen in Logicify kitchen displays office weather parameters; the dashboards are also available online.
Current Insights and Future Plans
As of now, we have a working sensor data collection unit in every office zone, so “weather” conditions are regularly monitored and displayed in Grafana - both on kitchen monitor and online.
We keep track of air quality, and our Office Manager reacts to the changes in the parameters: opens windows if the level of CO2 is too high, turns AC and humidifiers on and off. Ideally, we’d like the system to be user-independent, so sensors’ data triggered actuators per a specific set of rules.
Using time series graphs and annotations in Grafana, we traced some patterns and trends in office weather over longer periods of time: per specific month or whole season. With this data, we can budget electric power bills for a specific month, regulate heating devices and also investigate office conditions behavior depending on the weather outside.
We made the PCB design as open and reusable as possible, so that you can create your own version of the solution. Here are some helpful links:
- Schematics & Printed Circuit Board design at EasyEDA. You can make easy changes in your own version.
- ESPEasy, a configurable web-accessible firmware we used for the prototype.
For the next phase, the plan is to add HomeAssistant, an open source software for home automation, to the current stack to make our solution bidirectional. HomeAssistant should have a set of rules and corresponding actions to be executed according to the rules. In other words, it would allow us to automatically turn AC on if the temperature gets too high or turn humidifier off if it gets too humid in the office. We would share our experience with sensors and actuators once we have both in place. Stay tuned!
- IoT: How We Built Logicify Connected Office with a Soldering Iron (Slide Deck)
- Logicify Double-Sided System of User Behavior and System Condition Monitoring
- Grafana as a Yet Another Tool for Technical Monitoring of Software Products We Build
- Graylog as a Tool for Technical Monitoring of Software Products We Build