Design of WiFi-based environmental information IoT cloud platform monitoring system
[Copy link]
Abstract: Aiming at the environmental information monitoring problems in the fields of smart home, smart building, forest fire prevention monitoring, ecological environment monitoring, etc., an environmental information monitoring system based on esp8266 WiFi module is designed. The DHT11 temperature and humidity sensor is used to monitor the temperature and humidity information of the surrounding environment, the MQ-2 sensor is used to monitor the smoke concentration, and the photoconductivity effect of the photoresistor is used to monitor the light intensity of the environment.
At the same time, cloud monitoring applications and mobile phone APP software are designed, which can upload the monitored environmental information to the cloud via WiFi, and then transmit it to the mobile phone APP, so that users can monitor remotely. After circuit design and production, programming development, software and hardware debugging, this system realizes functions such as data collection, data display, data reporting, and mobile phone APP viewing of environmental data.
In the fields of smart home, smart building, forest fire monitoring, ecological environment monitoring, etc., the monitoring of environmental information such as temperature and humidity, light intensity, and smoke concentration has an important impact on smart life, fire prevention and disaster prevention [1-3]. Therefore, accurately monitoring and recording environmental temperature, humidity, light intensity, smoke concentration and other information, and making effective feedback in a timely manner, is of great significance to people's production and life.
To this end, this paper designs an air quality monitoring module based on the ESP8266 WiFi module, which is used to monitor the temperature, humidity, light, and smoke of the current environment, and display the relevant environmental information through OLED. At the same time, a cloud monitoring application and mobile phone APP software are designed, which can upload the monitored environmental information to the cloud via WiFi, and transmit the data to the mobile phone APP via the Internet, which is convenient for users to monitor remotely and lays the foundation for monitoring and prevention in specific application fields.
1 System Design
1.1 Overall Plan
The system functional framework is shown in Figure 1. The system is mainly divided into the following modules:
(1) The ESP8266 module is the main control module for program control and WiFi wireless communication. Its main functions include controlling the sensor module to collect environmental information and transmitting the collected information to the cloud platform through the WiFi module and the router [4-6];
(2)(1) The ESP8266 module is the main control module for program control and WiFi wireless communication. Its main functions include controlling the sensor module to collect environmental information and transmitting the collected information to the cloud platform through the WiFi module and the router [4-6];
(3) The cloud platform module is mainly used for cloud storage and web page display of detection data[7-8];
(4) Mobile APP is mainly used for remote monitoring. The cloud platform transmits user information and detection data to the mobile APP via the Internet;
(5) The OLED module is used to display local detection information.
Figure 1 System functional framework
1.2 Main control module ESP8266
ESP8266 is a cost-effective, highly integrated WiFi MCU for IoT applications. It can run independently or as a slave to other host MCUs. ESP8266 integrates an enhanced version of the Tensilica L106 Diamond series 32-bit core processor and on-chip SRAM. At the same time, ESP8266 has complete independent WiFi network functions and can connect to the Internet through a WiFi router to achieve local and cloud data interaction [9]. The I/O of ESP8266 can be used as the input channel of the sensor, drive LED or OLED, etc.
1.3 Temperature and humidity sensor module
The selected temperature and humidity sensor module is a temperature and humidity composite sensor DHT11 with calibrated digital signal output, using a single bus bidirectional serial communication protocol. During data collection, the microcontroller initiates a start signal, and the DHT11 sends a response to the microcontroller and transmits 40 bits of data. The specific format is: 8-bit humidity integer + 8-bit humidity decimal + 8-bit temperature integer + 8-bit temperature decimal + 8-bit check.
1.4 Photosensitive module
The photoconductivity effect of photoresistors is used to detect ambient light intensity. Photoresistors are directly related to light intensity. As light intensity increases, resistance decreases; conversely, as light intensity decreases, resistance increases. The resistance change is converted into a voltage signal through resistor voltage division. ADC0832 is used for analog-to-digital conversion to transmit light information to ESP8266 and then uploaded to the cloud.
1.5 Smoke sensor module MQ-2
The smoke sensor module MQ-2 uses the gas-sensitive material tin dioxide (SnO2), which has a low conductivity in clean air. If there is combustible gas in the environment where the sensor is located, the conductivity of the sensor will increase with the increase of the concentration of combustible gas in the air, and the change of conductivity will be converted into an output signal corresponding to the gas concentration through the internal circuit. The MQ-2 DC output signal will change with the smoke concentration, and the smoke concentration will be converted by ADC0832.
1.6 OLED Module
This paper uses a 0.96-inch organic light emitting diode (OLED) screen, driven by the I2C bus, to display the detected environmental information such as temperature, humidity, light, and smoke. OLED has the advantages of ultra-fast response speed and ultra-thinness, and is widely used in mobile devices.
2 Hardware Principle
Figure 2 shows the hardware principle of the system. This article uses the ESP8266 D1 Mini module.
Figure 2 Hardware Principle
As shown in Figure 2, the D2 pin of ESP8266 is connected to the data pin and pull-up resistor of the temperature and humidity sensor DHT11. Since the analog output of the photoresistor and smoke sensor needs to be converted into digital quantity for data storage, processing and display, this article uses the chip ADC0832 to perform analog-to-digital conversion of light-sensitive and smoke signals: the CH0 and CH1 channels of ADC0832 are connected to the output ports of the smoke sensor and the photosensitive sensor respectively, and the ESP8266 controls the ADC module for data acquisition and transmission. The ESP8266 module uses the RX and D1 pins to control the I2C timing to drive the OLED screen to display data information: the RX pin of ESP8266 is connected to the SDA pin of the OLED, and the D1 pin is connected to the SCL pin of the OLED.
The Gizwits AIoT development platform is a one-stop intelligent hardware development, software and cloud service platform for individual and enterprise developers launched by Gizwits IoT Technology Co., Ltd. The platform provides capabilities covering the entire life cycle of intelligent hardware access to operation and management, from product definition, device-side development and debugging, application development, cloud development, operation management, and data services. The Gizwits IoT platform provides developers with self-service tool operations, SDKs, and API services for developing intelligent hardware and open cloud services, which reduces the technical threshold and R&D costs of IoT hardware development[10].
3.1 Register an account
Log in to the Gizwits homepage ( https://www.gizwits.com/ ), register a Gizwits account, enter the Developer Center page, click Create New Product, and select the corresponding category in the Product Category.
3.2 Create a new product
Set the product name, select product category and technical solution (WiFi/mobile network solution, Bluetooth solution, gateway solution), communication method, data transmission method and other parameters. As shown in Figure 3, the communication method of this design is WiFi, the data length is fixed, and the power consumption is low.
Figure 3: Gizwits Cloud platform creates a new product technical solution and parameter setting interface
3.3 Define product features
The Gizwits IoT platform abstracts the functions of device products and defines "data points" to describe product functions and their parameters. After creating data points, the data format for device-cloud communication can be determined, and the device and Gizwits IoT can mutually identify the data of the device-Gizwits IoT interconnection. Figure 4 shows the data points of this project, which mainly include temperature, humidity, smoke, and lighting sensor data identifiers and data types.
Figure 4 Data points of Gizwits IoT platform product functions
3.4 Gizwits MCU SDK Development
Gizwits AIoT development platform can automatically generate the necessary code for MCU development according to the software and hardware solutions, speeding up the application development process. This design chooses to generate SoC solution SDK, and the hardware platform is ESP8266_32M. Gizwits generates the corresponding device-side code based on the data points of the defined products, automatically implements the parsing and packaging of the communication protocol, and can not only be encapsulated into a simple API, but also provides example codes for multiple platforms. The cloud platform MCU SDK development is shown in Figure 5.
Figure 5 Cloud platform MCUSDK development
Gizwits automatically generates Internet of Things (IoT) application development platforms, including basic platforms and upper-level application development examples, such as smart lights, smart switches, security monitoring, energy transportation, industrial Internet, etc. The SDK basic platform can be divided into two versions: Non-OS and RTOS, depending on whether it is based on an operating system. This article uses the Non-OS SDK version, which is an SDK that is not based on an operating system. It mainly uses timers and callback functions to achieve the nesting of various functional events, so as to trigger specific functional functions under specific conditions.
4 Embedded Software Development
This article develops embedded software based on the Non-OS SDK generated by Gizwits. The main software process is shown in Figure 6.
Figure 6 Main process of embedded software
The user program entry is user_init(), which completes the initialization functions of the application: I/O port initialization, ADC0832 initialization, OLED initialization, and Gizwits Cloud service initialization. After the initialization is completed, it enters the empty loop mode, waits for WiFi connection and sets the button callback function, WiFi timed connection interrupt, and sensor timed detection interrupt. Once the interrupt arrives, the CPU jumps to the interrupt service function for interrupt processing.
When the WiFi connection is detected to be successful, the data update timer is set. Environmental data such as temperature, humidity, light, smoke, etc. are detected regularly and displayed on the OLED display. If the WiFi connection is successful, the detection data is uploaded to the Gizwits Cloud server. If the WiFi information needs to be configured for the first time, long press the button to start the one-key configuration mode, use the mobile phone APP to configure, and after the configuration is completed, the device connects to the WiFi, and the data is updated after the connection is successful. The process of WiFi timed connection interruption and sensor detection timed interruption is shown in Figure 7.
Figure 7 WiFi scheduled connection interruption and sensor scheduled detection interruption process
5 Mobile APP application development
Mobile APP application development is based on the demo version (Android version) provided by Gizwits official website, and the interface design and development are carried out in Android Studio according to the requirements. As shown in Figure 8, linear layout is used in the mobile APP interface design of this article to display the interface information of temperature, humidity, light, and smoke. Each linear layout has 1 ImageView image view and 1 TextView text view. ImageView is used to load interface information type images, and TextView is used to display data.
Figure 8 Android app interface development
6 System operation results
After the device is powered on, long press the button to trigger the configuration mode, the OLED displays WiFi config, use the APP to click the "+" sign in the upper right corner, select one-key configuration, before configuration, the mobile phone needs to be connected to the target router, enter the WiFi password, and click "Next" to configure. After the configuration is completed, return to the device list and click the device to view the sensor data. Device and application debugging is shown in Figure 9.
Figure 9 Device and application debugging
This paper designs a WiFi-based environmental data collection cloud platform monitoring system, which mainly includes sensor information collection, WiFi-based information transmission, IoT cloud platform and mobile APP monitoring functions. Under the control of the ESP8266 module, the system collects environmental information such as temperature, humidity, light, smoke, etc., transmits it to the cloud of the Gizwits development platform through the WiFi module, and uses the mobile APP to monitor the environmental information.
After debugging, the system can complete the functions of data collection, data display, data reporting, and mobile phone APP to view the measurement environment data, and basically achieve the design requirements. It can be used in smart homes, smart buildings and other fields, and can also provide early warnings for safety accidents such as fires and mountain torrents. The WiFi communication used can be expanded to mobile communication networks, NB-IoT, LoRa, Bluetooth, etc., and can be applied in smart transportation, smart logistics, smart agriculture, health monitoring, industrial control and other fields according to different sensor information.
|