念慈菴

[Tuya Smart] Multi-parameter ambient air quality monitoring recorder

 
Overview

[Tuya Smart] Multi-parameter ambient air quality monitoring recorder. The environmental parameters "temperature-humidity-illumination-atmospheric pressure-carbon dioxide-TVOC" are collected and displayed using broken code LCD or 3.5-inch TFT-LCD; powered by two 18650 batteries and charged via USB; real-time environmental data are transmitted to the Tuya backend through the WB3S module , environmental data can be monitored in real time through the mobile APP; environmental parameter data can be stored through FLASH.

1. Hardware part

1. Microcontroller minimum system.

The actual welded chip is STM32F103CBT6. The price of STM32 has skyrocketed, but I have no choice but to get familiar with it, so I grit my teeth and endure it, and try to have the opportunity to switch to domestic chips next time. picture.png

2. Power conversion module.

5V to 3.3V, AMS1117-3.3 remains unchanged for thousands of years. Don’t ask me why, just look at its sales on Lichuang Mall. (Tip: If you don’t know how to choose a chip, just go to Lichuang Mall to see which ones have the highest sales of the same type of chips!!!) picture.png

3. EEPROM.

Using AT24C04, IIC bus driver, classic chip, storage system parameters. picture.png

4. Button module.

Of the four function buttons, only KEY1 is actually used as the network distribution button. There is no time to write the programs for the other three buttons. picture.png

5. WIFI module.

The WB3S module was used in the last training camp, so I brought it over directly this time. It has BLE & WIFI dual-mode and is easy to configure the network! This time I used the MCU SDK development mode. picture.png

6. FLASH memory.

It is used to store environment monitoring parameters. I originally planned to make the file system FATFS, but the time was tight and it was too late. I just tested the storage function of FLASH. picture.png

7. Sensor part.

All sensors have IIC interfaces and are connected to the same bus. External sensor interfaces CN1 and H7 are also reserved. As long as the device is powered by 3.3V and has an IIC interface, it can be connected to it for testing. picture.png (1) Temperature and humidity sensor. SHTC3, Shengshi Ruian's chip, is very good, with high precision and low power consumption. (2) Light sensor. OPT3001, the first time I used it, I found it at Lichuang Mall. Jialichuang can do patch welding, so I chose it. (3) TVOC sensor. SGP40, a new replacement for SGP30, is also a chip from Shengshi Rui, but it needs to be ordered and I didn’t have time to debug it. I used the previous SGP30, which can monitor TVOC and carbon dioxide. Please note that SGP30 is powered by 1.8V, so be sure to do this when using it. Level conversion circuit. (4) Atmospheric pressure sensor. SPL06-007, monitors atmospheric pressure and can calculate altitude. This is my first time using it, so I don’t know if it’s accurate.

8. Segment code LCD screen.

The purpose of choosing this LCD is because it comes with a matching casing. I don’t know much about 3D printing, so I could only buy a finished common-mode casing. After adjusting it for a long time, I finally chose it. It costs 40 yuan for a set, casing + display, which is a bit expensive. I heard that it is easier to win prizes if you have a shell, so I gritted my teeth and endured it. picture.png The HT1622 is used to drive the segment code LCD screen, and the AW9364 is used as the backlight adjustment (but the debugging was not successful, so we can only wait for the future, embarrassing!)

9. Lithium battery charge and discharge management.

Using the IP5306 chip and referring to the designs of other experts on the open source platform, it was quite successful. However, I tried to detect the battery power through the three control pins of the charge and discharge indicator, but failed! picture.png

10. 3.5-inch TFT LCD interface. The reserved interface can be connected to an external TFT LCD screen, so there is no time for debugging!

picture.png

2. Software part

1. RTC driver debugging. It is not difficult to modify according to the punctual atomic program. If there is no problem with the circuit, it is easy to debug successfully. Reference code attachment: 29270W-RTC Experiment-OK.rar.

picture.png

2. AT24C04 driver. The software simulates the IIC implementation, refers to the punctual atomic code, makes simple modifications, and the test is successful. Reference code attachment: 29270W-AT24C04-OK.rar.

picture.png

3. FLASH driver. SPI reads and writes FLASH, refer to the punctual atomic code, the test is successful!!! Reference code attachment: 29270W-SPI+FLASH-OK.rar.

picture.png

4. SHTC3 driver. Read the software IIC, refer to the network code, make modifications, and the test is successful! Reference code attachment: 29270W-I2C-SHTC3-OK.rar.

5. OPT3001 driver. Read the software IIC, refer to the network code, make modifications, and the test is successful! Reference code attachment: 29270W-OPT3001-OK.rar.

picture.png

6. SPL006 driver. Read the software IIC, refer to the network code, make modifications, and the test is successful! Reference code attachment: 29270W-SPL06-OK.rar.

picture.png

7. SGP30 driver. Read the software IIC, refer to the network code, make modifications, and the test is successful! Reference code attachment: 29270W-SGP30-OK.rar.

8. HT1622 segment LCD driver. Reference code attachment: 29270W-HT1622-OK.rar.

9. WB3S module driver transplantation. Just write down a few key points.

(1) Distribution network. The main program is called, and when the button KEY1 is pressed, the network distribution is started.

picture.png

(2) To obtain the distribution network status, you can write specific functions based on the return value.

picture.png

(3) Update real-time data.

The main program is called every 10 seconds to update the environmental monitoring data and upload it, and the timer is set to 500 milliseconds. picture.png The specific implementation of the all_data_updata() function is in protocol.c. This is very critical! ! !

picture.png

3. Process pictures

1. Jialichuang production + SMT photos

picture.png

2. Temperature and humidity display

picture.png

3. Atmospheric pressure + altitude

picture.png

4. Carbon dioxide + ambient light

picture.png

5. TVOC display

picture.png

6. Battery insert

picture.png

7. Install the battery

picture.png

8. Front of finished product

picture.png

9. The back of the finished product

picture.png

3. Summary

1. Thanks to Tuya Smart & Lichuang EDA for their strong support. I have learned a lot. The Internet of Things is really not difficult. As long as you are willing to work hard, you will gain a lot in one holiday.

2. Many new things have been adopted in circuit design, and some attempts have been made, with some successes and some regrets. Future designs need to be more verified and more mature solutions should be used to avoid detours.

3. Programming is still far behind. Many programs are used directly from the Internet, forming inertial thinking. The ability to solve complex problems still needs to be improved.

4. I have met a lot of friends and am very happy. I hope to join you in the next event! ! !

Note: The code is required to be uploaded to GITHUB, but it is not completely done. I don’t know if it is due to the network.

Link: https://github.com/GitHubXieZY/Termp-Humi-Recorder .



参考设计图片
×
Design Files
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-23 11:16:37

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号