Internet of Things Intelligent Curtain Control System
Without further ado, here are the renderings:
curtains closed | curtains open |
The demonstration video is at the end, and the text begins next!
=============================================Text dividing line== ============================================
1. Project introduction
After 6 pm on the 19th , I was watching the official account push as usual, but I just happened to catch up with the training camp news released by Lichuang EDA ! It also happened to be my favorite Internet of Things topic, so I quickly clicked in to check the details and sign up (because I didn’t catch up with the summer training camp, I didn’t know where to sign up at the time, but now I caught up hahh ), and then went to learn about Tuya Platform, I found that I can bind Xiao Ai (because I am a rice fan and have been exposed to some IoT platforms before. It is not particularly convenient to connect to Xiao Ai classmates. The ones that can be connected ... just don't achieve the desired effect. There are still many platforms that are not open to individual developers, so ... ) I started exploring Tuya with excitement ... Then I started thinking about what to do. After 2 days of observation, I found that no matter where I am at station B , , tb, and p Xixi have no smart curtain modifications. The products are hundreds or even thousands (the cheapest p Xixi is more than 200 ). To reinstall the electric track is not only high cost but also troublesome. But for DIY electronics enthusiasts, if they can modify their own curtains, wouldn’t it be a joy? So I will use this opportunity to implement a smart curtain design in the simplest and crudest way and at the lowest cost! Thanks again to Lichuang EDA and Tuya Smart for providing learning opportunities ~
2. Implementation principle
The principle of this project is very simple. First, I tied the curtains with nylon ropes, and used the seats on the wall to fix the curtains to form a loop, so that the two ropes could move with each other to open and close the curtains. Here is a simple diagram I drew:
When the curtain is closed, pull the green rope inward and release the blue rope outward to open the curtain. | When the curtain is open, push the green rope outward and pull the blue rope inward to close the curtain. |
3. Schematic analysis
3.1 Power supply
As for the power supply, because the motor I chose is 12v, the power supply also needs a 12v input, which is convenient for connecting an adapter or battery. For the pressure reduction part, I used the simplest and crudest method AMS1117 ! If I directly reduce it to 3.3, I am worried that the LDO will consume too much power and cause serious heat, so I used a 5V buffer. I also used a small LDO for the Tuya module. When drawing the pcb, I also drew the wb3s into a module. The pins come out for easy play later!
3.2 Peripherals
There is an LED left on the motherboard to facilitate debugging and indication. The two low-power Hall models are FDH002BH used to detect whether the curtain has reached the limit position. A program download and debugging interface is reserved. As for the wireless module, I chose a transparent transmission module LC12S , which is very convenient. It can be configured to one-to-many or many-to-many. As long as it is configured once, there is no need to move it. It also greatly reduces the amount of code and shortens the development cycle.
3.3 Motor drive
For the motor driver chip, I chose RZ7889 . Its operating voltage range is: 3-18V. The maximum continuous operating current is 4.2A.
Advantages: It has built-in MSOFET and some protection circuits. It does not require external circuits. It is directly controlled when power is turned on. It has built-in protection circuits and can be used directly according to the truth table in the manual. It is very convenient.
Disadvantage: It should be that the speed cannot be adjusted. I heard that the frequency is 1k, but this project does not require speed adjustment, so this chip is the most suitable!
3.4 MCU
Here, the main control of the motherboard and remote control is STM32F070F6P6 . Because this project is very simple, and I also like to play with 32, I chose the lower-cost STM32F0 series microcontroller, so this project is cost-effective for me. and difficulty level are controlled.
3.5 Tuya Smart Module
The Tuya module I chose is WB3S. For this part of the circuit, I just took out the pins of the Tuya module and added an ldo for future use. I would also like to complain here. The Tuya platform is indeed more convenient and easy to use. The delay when controlled by mobile phone is also very small. I have used some IoT platforms before. Relatively speaking, Tuya is quite good. But I think the only regret is that I can't connect with Xiaoai classmates (you can, but you need to activate value-added services)...
3.6 Remote control buttons
The remote control has a total of 8 buttons, all of which have hardware debounce, which can also save most of the programs and reduce the burden of the program.
3.7 Remote control charging circuit
The charging circuit is designed with reference to the typical structure of typical lithium battery charging and discharging:
As for the charging protection chip, I chose the commonly used TC4056A . This one is relatively simple and has many functions. It has all kinds of protection and temperature monitoring, but I didn’t use it here. The charging indicator light and the full indicator These two lamps are more practical. Adjust the maximum charging current to 1A through R9 in the picture. As for the battery, I happened to have a few 800mAh lithium batteries here, so I just used them. Then I used a SC662K low voltage dropout LDO to power the remote control. As for the charging interface, I personally like to use type-c , mobile computers and DIY. Everything is like unity.
Charging status indication | |
The red light is on indicating charging | Green light on indicates charging is complete |
4. PCB design
Smart curtain motherboard PCB top layer | Intelligent curtain mainboard PCB bottom layer | Smart Curtain Main Board 3D Front | 3D reverse side of smart curtain motherboard |
Smart curtain remote control PCB top layer | Intelligent curtain remote control PCB bottom layer | Smart curtain remote control 3D front view | Smart curtain remote control 3D reverse side |
5. Physical construction
The components were already in place, and coincidentally, the board and module arrived together on Sunday, so we started the road of welding and debugging:
Below is the welding and debugging: board diagram ↓
A photo of the motherboard and remote control✌ | |
Motherboard front | Reverse side of motherboard |
Front of remote control | The reverse side of the remote control |
Below is a reduction motor and nylon rope bought at tb:
JGY-370 reduction motor, voltage 12v, 66 rpm | Nylon rope is very cheap and very strong. 1mm thick , 30 meters long |
In order to make the production convenient and fast, I used the simplest idea: I only used one of the simplest functions of the Tuya smart module, which is the socket, which only opens and closes. Then I used STM32 to detect the output level and control it automatically in the app control interface. Define it, and the socket becomes a curtain. (Because it is not open to individual developers, I can only use it this time. I don’t want to study in depth and use it in the future. I am still studying, interning, and busy at work. In fact, it is most important for rice fans and electronics enthusiasts. The reason should be that it does not support Xiao Ai ... ).
6. STM32 code part
Although what I want to do now is a smart curtain, this is just the beginning for my hobbies. I will continue my smart home DIY road ( there are some ESP8266 videos on my B site before, if you are interested Students can go and take a look ). The offline remote control also has 8 buttons, and functions can be added using programs in the future (it’s a pity that I haven’t added a casing to the work now, because I can’t draw yet, hahaha, but there will be in the future). So I made a protocol that is simple and easy to add later:
As for the program, since I am also a beginner, I only have curtains now, so I wrote it very simply. Just post some key codes:
The following is the sending part of the smart curtain remote control :
The following is the receiving program part of the smart curtain mainboard :
7. Some problems encountered during the process and their solutions
Generally speaking, there are no big problems, they are all caused by small details and temporary negligence. The main points are as follows:
1. The SET pin of the LC12S of the wireless module is drawn incorrectly ( the schematic pcb has been modified ). During normal operation, the SET pin should be pulled high or floating (due to negligence, I did not read the official manual carefully, and there is a typical circuit drawn on it. The SET pin is grounded, so I copied it without thinking... Solution: After the board arrives, configure the module and cut a wire ).
2. The silk screen printing of the debugging interface of the remote control is reversed ( the schematic PCB has been modified )
3. The signal in the Hall circuit is not pulled up, and sometimes it triggers itself, which is unstable. Solution: Internal program pull-up or hardware pull-up , I chose program pull-up.
8. Tuya APP panel display
Below is the panel I customized. Although the icons I found online are relatively simple, they are clear, intuitive, and practical even the elderly can understand!
This is the homepage -----you can see the smart devices under the current account |
This is the control page----the icon shows that the current curtains are open |
This is the control page ----the icon shows that the current curtains are closed |
9. Demonstration video
++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++
+ Welcome to jump to watch the finished product demonstration video of this work~~ +
+ +
+ Video address: https://www.bilibili.com/video/BV1qK411V7PN +
+ +
+ Okay, the project is over here, goodbye everyone! + +++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++
---END---
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