📜 ⬆️ ⬇️

ESP data acquisition system. Part I. CO2

Good day! In this article I want to talk about the implementation of devices on ESP modules. The theme of similar devices has already been disclosed on the Internet, but does not cease to be relevant.
Idea

I have long thought about the implementation of a certain display and control system in an apartment, but I could not find any use of commercially available sensors for myself. The first thing that confused was the presence of a certain server (a separate piece of iron) that collects data, processes it and throws it somewhere for viewing. I would like to have a scalable system of independent devices, preferably working with a single application, optimally if the application is ready, which seemed almost impossible (looking ahead to say that such an application exists and it can be quite flexible for our tasks). And of course I wanted to make a line of their devices.

System requirements

  1. No hardware server ("central unit").
  2. Independent sensors / controls.
  3. Sensors must be wireless.
  4. When changing the composition and types of sensors, there should be no dependence (adding a new device should not be necessary to “cut” something on others).
  5. If possible, the sensors should be battery-powered.
  6. If necessary, the sensors should be able to customize, but without digging into the code (optimally web).
  7. Notifications. This is a separate requirement. We are all accustomed to using cell phones and receiving notifications instantly.

This is not a complete list of "hotelok", but this is the main.

Finding a solution

The decision to create the system came a little later. First, the first device was developed, which I will write about in this article.

Hardware part ESP-12E and ESP32. All projects described below are implemented on the first module. On the second module there are several commercial projects that will not be considered under this article.

About ESP-12E there are many articles and forums on the Internet, and I will not repeat about all the pros and cons. All the "gags" occurred mainly due to the lack of experience in working with the module and with the environment, in principle.


Figure 1. Photo of ESP-12E.

The software part. The firmware for ESP was written in the Arduino IDE environment. The “Blynk” application is running on the phone / tablet side. This is a very handy constructor for displaying data. The application has a cloud server, where devices (sensors) send data, and Blynk receives it and allows displaying it (www.blynk.cc). Feedback is organized in the same way with the device. Importantly, one application can collect and display data from multiple devices.




Figure 2. Screenshots of the application.

Later we will post an article on the software and links to the source. I do the hardware. The software implementation is carried out by my colleague.

The first trio of sensors

1. OpenWindAir Carbon Dioxide Sensor.

Built on the basis of Wi-Fi module ESP-12E. Measurement takes place using the CO2 sensor MH-Z19. It is widely known and allows you to quickly and accurately measure. In addition, the device has a built-in temperature and humidity sensor AM2302. There is also support for a remote sensor for use, for example, with the People Monitoring system. The device is powered by miniUSB from a PC or 5V power supply. LED and audible alarms are implemented (the latter can be disabled from the application, or used by the clock - so as not to wake up at night).

2. LifeOfFlowers Sensor soil moisture for plants.

Built on the basis of Wi-Fi module ESP-12E. Soil moisture measurement is performed using a plug-in electrode into the ground (part of the device board). What is important is that the electrode, like the entire board, is filled with varnish (it had to be clever with the measurements), which would prevent the contacts from rotting. In addition to soil moisture, the device measures the humidity and ambient temperature (AM2302), light intensity and battery voltage. Yes, LifeOfFlowers runs from 1 to 3 years from two AAA batteries (the running time depends on the data refresh rate).

3. WarningWater Leak Sensor.

Built on the basis of Wi-Fi module ESP-12E. Measurement takes place with the help of electrodes that are part of the IP-65 housing. The device operates on two AAA batteries (or AA), the operating time is also from 1 year. The dimensions of the device are only 55x55x30mm. To get started, you need to put the device in a potentially dangerous place and it will signal the presence of water on the floor. The application also displays the voltage of the batteries, so as not to forget to replace them in time.

OpenWindAir - hardware implementation

Circuit delicacies here not to meet, everything is simple and datasheets. If someone needs a scheme, I can give.

Structure of the device:

ESP8266 ESP-12E is the module itself, which is responsible for collecting, processing and sending data. Power 3.3V.
The MH-Z19 is a carbon dioxide sensor. Works on the UART, measures up to 5000ppm and is powered by 5V.
AM2302 - measurement of humidity and temperature. Since the sensor is inside the case, calibration constants had to be entered, and the measurement data are for reference only. For more accurate measurements using a remote sensor.

1-1462037-8 (IM03TS) - the relay, for switching the weak point, laid, just in case, to play. In principle, the piece is interesting, but the applications have not yet been invented (brought to the same external connector as the external humidity sensor).

CP2102-GM - USB-UART. Yes, we decided to make beautiful logs to display information in real time, it turned out very convenient, you can watch the data in the terminal, watch the boot order, debug it.

LM1117MP-ADJ - LDO for 3.3V.

There is also a beeper, a pair of buttons and three LEDs. In addition to the thresholds of CO2 concentration, LEDs indicate the process of loading the device, connecting to an access point (or working offline), and updating.

The device has an OTA update. We throw the firmware on any server (after registering it), press the button, apply power and the firmware process begins. After flashing (or restarting) for a specified time, you can go to the web interface (the device is represented as an access point) and drive the network settings - after that, everything is ready for operation.


Figure 3. Photo board with components.

I want to write a little about the form and features of the printed circuit board. When testing, it was found that during long-term Wi-Fi operation, the module warms up the board. It would not be critical if the built-in temperature and humidity sensor inside the case. I had to push the ESP module with the feeder and the sensors in different directions, and also to make a cutout in the board, where, like the designer, a special partition is still inserted. Thus, there is no mixing of air inside the case and measuring the temperature and humidity are much more reliable.


Figure 4. Photos of the partition on the board.

Housing

There were many doubts here - I wanted to have a beautiful metal, streamlined body with a matte display strip, etc., but as always, minimalism came to the rescue. The form factor of the case determined the presence of old-school 5mm LEDs, which, as it turned out, are very convenient. Due to the fact that they are convex - this allows you to put the device, for example, on the shelf and the display will still be clearly visible. The case itself was cut out of 2mm plexiglas by laser.

We made several options, in different colors and with a combination of colors, as well as from different materials. It looks very decent. I even tried to make PCB immediately with the order of printed circuit boards. At the moment, we are considering an option with the manufacture of housing in production, but for now this is only in the plans. Models can also lay out.


Figure 5. Photo device.

Plans

In general, plans to make a few more devices (in addition to these three). For example, ESP32 has built-in Ethernet (only physics is needed) and more built-in ADCs, which will allow you to do without a multiplexer, as is the case with LifeOfFlowers, but more on that later.

Shl. Blynk has a server API that is easily deployed (checked) on a PC. Thus, the binding to the server disappears.

ZZY. To have less negative renamed article. When we proceed to control the house with the help of devices, I will correct the article.

Thanks for attention!

ZZZY: As promised, here is the link to the article on the software geektimes.ru/post/122601

Source: https://habr.com/ru/post/410405/