Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

Overview

Previously, I wrote a tutorial on building a temperature and humidity monitor with 20 lines of code, and I also promised to write a tutorial without any coding. After a long delay, I finally finished it. Some content is excerpted from the Baidu Cloud IoT Platform documentation.

Development Board

NodeMCU is an open-source development board based on the ESP8266, equipped with USB to serial chip, WiFi, and GPIO interfaces.

Sensor

For the sensor, we provide a basic version of the temperature and humidity sensor – DHT11. This temperature and humidity sensor can be used to test environmental temperature and humidity, with a precision of ±5%RH for humidity and ±2℃ for temperature, and a range of 20-90%RH for humidity and 0-50℃ for temperature.

1. Cloud Platform Operations

  1. Register for a Baidu Cloud TianGong account and authenticate it. In the left side under ‘Product Services’ – ‘IoT Services’, select ‘Device Access’ and purchase a package.

Then, enter the project list and create a device-type project. Click on the project name to enter the project details page, and click ‘Create New Device Model’.

Fill in the ‘Name’ and ‘Add Attributes’. Here the attributes are the information we need to collect and report, so I added two attributes:

* D1_Temperature Temperature number type
* D1_Humidity Humidity number type

Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

  1. After creating the device model, create the device shadow next. The name can be customized, and this will be used later. Select the device model you just created and click create to complete. After creation, retrieve the connection information for later use (the key is only displayed once after generation). If the information is lost, it can be reset at the following location.

Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

At this point, the preparation work is complete. The storage part (time-series database TSDB) can be enabled at this step or connected later.

2. Wiring

Connect the sensor to the board using DuPont wires. The DHT11 typically has three pins, but the labeling and order may vary between manufacturers, so please check the markings on the module while wiring. The one I have is marked in the following order:

  • VCC (+, 3.3v, etc.)

  • DATA (D, S, SIG, etc.)

  • GND (-, G, etc.)

Connect VCC and GND to the corresponding marked positions on the board; DATA can be connected to any GPIO pin.

Since D4 is close, I chose GPIO D4.

The wiring is as shown: Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without CodingPhysical image: Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

3. Flashing the Development Board Firmware

Install Drivers

The NodeMCU available on Taobao typically integrates either a CP2102 or CH340 USB to serial chip. The download addresses for the drivers are: CH-340 http://www.wch.cn/search?q=340&t=downloads or CP2102 https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers.

Firmware Download

We provide an ESPEasy firmware adapted for Baidu TianGong by a kind customer. This firmware version supports web graphical configuration, allowing the development board to report the collected data to the cloud platform. This board can also flash other firmware, such as MicroPython, etc.

ESPEasy Baidu TianGong adapted version http://share.iotalk.top/nodemcu_baiduMQTT.bin

Of course, you can also compile it yourself on GitHub https://github.com/hetaoos/ESPEasy

Flashing Firmware on Windows

Download the flasher, click to download, click the config tab, in the first line position, click the gear on the right, and select the firmware Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

Return to Operation, select the board’s COM Port (usually the default is the correct port). Click Flash Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

Flashing Firmware on macOS / Linux

On macOS and Linux, you can flash the firmware using esptool.py. Flashing tutorial https://blog.csdn.net/YSSJZ960427031/article/details/77343019

If the flashing gets stuck at connect, press the RST button first, then press the FLASH button, then release the FLASH button, and finally release the RST button. At this point, execute the simplest command: esptool.py -p /dev/cu.SLAB_USBtoUART write_flash 0x0000 code/nodemcu_baiduMQTT.bin

Where /dev/cu.SLAB_USBtoUART should be replaced with your machine’s port address; code/nodemcu_baiduMQTT.bin should be replaced with your firmware storage path.

  • esptool.py’s GitHub https://github.com/espressif/esptool

Configuring Network

After flashing the system, open the computer’s WiFi list, and you can see ESP_Easy_0 appearing as a wireless hotspot, which is encrypted (the password is configesp). Connect to it. If you don’t see it, please restart NodeMCU. Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

Once connected, try to open 192.168.4.1 in your browser, and it will redirect to the settings page.

Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

Select your WiFi, enter the password, and click connect

Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

After the computer connects to the same WiFi as the development board, please enter the previously remembered IP address in the browser to connect to the ESPEasy web setting interface. If you cannot connect, please restart NodeMCU and try again. (If the IP address interface does not appear, or if ESP_Easy_0 disappears, please restart NodeMCU, check the router interface for the IP connected to NodeMCU, and if it exists, directly enter this IP to access the web setting interface. If it still doesn’t work, please re-flash the firmware and try again.)

Configuring Sensor

In the ESPEasy management interface, select Device, and click Edit on the first row.

Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without CodingConfigure as shown in the image Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without CodingAfter configuration, click submit.

Configuring MQTT Connection

In the ESPEasy management interface, select Controllers, and click Edit on the first row (it must be the first row, as only the first supports MQTT).Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

In the editing interface, select Baidu MQTT, Use Hostname as shown in the image.

Then fill in the device shadow information obtained from the TianGong cloud platform in the first step, where the Client Id is the device shadow name.

Then, fill in the Subscribe/Publish/lwl topic as shown in the image, the topics can be viewed in Baidu Cloud TianGong – Console – Device Shadow Details – Interaction tab.

Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without CodingAfter configuration, click submit.

After configuration, you can see the data just reported on the TianGong ‘Device Shadow Details’ page.

Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

4. Data Storage

In the chart I displayed, there are real-time values and line charts. The line chart shows the historical data for a period of time. Therefore, we need to store the data.

On the ‘Device Details’ page (where the connection information was obtained before), click edit, enable ‘Storage Configuration’, change ‘Do Not Store’ to ‘Store Immediately’, and select which database to store it in (if there isn’t one, create one, the default configuration is sufficient), fill in the metric name as monitor, and click save. Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

Now the storage part is configured, and every time data is reported, it will automatically be stored in TSDB. You can choose ‘Time Series Database’ from the left navigation and click the corresponding database’s ‘Query Panel’ to view the historical data stored.

5. Create a Beautiful Report

Now that the data is stored, the next step is to display it.

Using the IoT visualization tool, you can create a beautiful real-time chart like making a PPT.

For example, I will describe the steps to create a report similar to the one I screenshot: * First, go to the IoT visualization tool and click to create a ‘Dashboard’ * After entering, there are two tabs at the top, select ‘Data Table’ * On the left, create a new data table; since I have two gauge charts and one time-series line chart, I need to create two data tables, one for time series database type and one for device management type * After creating, return to ‘Dashboard’. Drag the required charts to the blank area, click on the corresponding chart, and set the binding data on the right as shown in the image Build a Temperature and Humidity Monitoring Station Based on NodeMCU and IoT Platform Without Coding

This introduces a small part of the functionality, and if you need to display more parts, you can refer to the documentation.

6. Conclusion

Thus, the entire process from setup to display is complete. You can publish the IoT visualization dashboard and share it with your friends.

This is the most basic temperature and humidity collection and reporting system. Based on this, you can also do some more complex things, such as adding infrared to trigger the air conditioning when the temperature and humidity reach a specified threshold; creating a mobile app or WeChat mini-program to control the infrared remote control on the board… There are many scenarios, but I won’t elaborate on them one by one.

Leave a Comment

×