3228

[Training Camp_Advanced Class] Three-way smart socket + temperature display

 
Overview

The device is connected to the Internet through the emw3080wifi module to receive the control information sent from the mobile phone and the return of the device information. After receiving the information, the data is processed through the microcontroller, and then fed back to the device to realize cloud control of the device. Through the temperature The sensor can also transmit the current temperature to the mobile phone. Because it was the first time I came into contact with PCB design during the summer vacation, there were some shortcomings in the design process. In the schematic diagram, the CH340 and the D+D- of the USB interface were accidentally connected reversely, which resulted in the computer being unable to recognize the MCU after it was soldered. After getting to the chip, I discovered this problem with the help of the big guys in the group. 11111.pngAs a newbie flying cables for the first time, I finally succeeded in getting the computer to recognize the CH340 chip after a busy morning. Then when compiling the example code, an error of insufficient data data space was reported. Baidu found that using xdata data space was enough. 123123.pngAfter adjusting the settings in keil, the compilation was successful and the MCU was burned in. The LED started to flash. The next step is The network is configured. I didn't pay attention to the 11.0592MHZ used for burning at first. It turned out that the microcontroller sent garbled information. Change it to 22.1184 and it is normal. Press and hold the button and the microcontroller enters the network configuration mode. After that, the mobile phone scans the code to configure the network. After a short time After waiting, the network configuration is successful, and the indicator light starts to flash quickly to indicate that the WiFi is connected. At this time, you can control the opening and closing of the device in real time through the mobile APP (I haven’t figured out how to connect the electrical appliances, so I will temporarily turn off the relay. to represent), since the function of the inverter was not considered during the design, I originally wanted to use LED to represent the current power-on status of the device. As a result, the LED's on and off are opposite to the power-on status. The LED goes off when the relay is closed, that is, when the socket is opened. The LED lights up when disconnected. . . Prepare to re-wire the LED later, and re-board the board. Correct the wiring errors of CH340, and then use spare components to make another one. Currently, two buttons and two relay positions have been reserved. I will study Song Gong's code and add the control of the two relays myself.

APP.jpg At present, the code of the three-way switch has been changed. Through the app, you can remotely control the on and off of the three switches through wifi, or you can manually control it through the buttons. When the buttons are controlled, the device status will be uploaded in real time, and the status can be seen synchronously on the app. The change. At the same time, Alibaba Cloud's interface design is used to record the hourly temperature and display it through a curve chart. There is a C file in Song Gong's code that specifically operates keys, because at first only one key was used and one key was reserved, and I used three keys. After changing the macro definition of key count to When it is 3, it cannot be controlled by keys. After checking, it is found that the number three is used for the third key. In the for loop, because 0 starts from 1 and corresponds to the key number, the for loop ends when it reaches 2. When reading, The third button cannot be detected. You can successfully control it by changing the number of buttons to 4 in the macro definition.

9162313.jpg0819162304.jpg There are 4-pin OLED headers reserved on the PCB, and the status information can be viewed on the device in real time through the 0.96 screen later.

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-07-02 19:17:29

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号