Indoor environment controller, this work can detect indoor temperature and humidity, light intensity, smoke concentration (or combustible gas) and make corresponding controls based on these values, such as constant temperature and humidity control, constant light control, and smoke alarm. And can be connected to the cloud through the Tuya networking module to achieve remote control. For example, the environment of an electric vehicle can be monitored when it is being charged, and an alarm can be issued for combustion caused by charging. At the same time, the temperature and humidity can be controlled within a reasonable range to increase the life of the battery.
This project uses STM32F103C8T6 as the main control, Tuya wb3s as the networking module, SHT30 is the temperature and humidity sensor, OPT3001 is the light sensor, and MQ2 is the smoke sensor. SHT30 and OPT3001 are IIC communications, and MQ2 is the analog signal; used in this project An OLED and three buttons serve as the human-computer interaction interface, and an EEPROM is used to record alarm content and set some information.
Update: Added an interface for external smoke sensor, the signal is 0-20mA signal. Reason for change: Since the installation location of the smoke sensor was not considered at the beginning of the design, the smoke sensor was centralized on the board. After thinking about it, I decided not to change the original design of the board, but added an external sensor signal interface, and used the onboard sensor as a verification module, which can be closed or opened through a jumper cap.
Demo video
Design ideas
The design block diagram is as follows
In this work, FreeRTOS is used as the operating system to adjust various tasks, as shown in the figure. All tasks are roughly divided into several tasks in the figure.
Instructions
Interface display
Introduction to use
In this work, the homepage displays the real-time data of each sensor, network connection status, and current time. Use three buttons for human-computer interaction. The left button is always the confirmation button, the middle button is the select or delete button, and the right button is the exit button. Relevant function tips will be displayed at the bottom of the screen.
Among all interfaces, only the control setting interface has the function of inputting settings, and the rest are viewing functions. Related settings can be performed on the mobile phone. The function of the control terminal can control the opening and closing of IO points, as well as the control mode "AUTO" automatic or "OPER" manual. The principle of automatic control is the simplest two-position control principle.
Code https://github.com/xiaoengineer/IEMCS.git
There is a small problem: the buzzer is passive, so it must be driven by a signal of a certain frequency. However, I did not expect that the timer pin of stm32f103c8t6 conflicts with I2C, so I can only use the IO port to simulate reverse driving of the buzzer. Therefore, it is recommended to switch to an active buzzer.
During the demonstration, an external sensor interface was used. Since it was a voltage signal, the 150 ohm resistor was removed.
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet