通通

[Training Camp_Advanced Class] TFT display smart socket based on Alibaba Cloud

 
Overview

1. Origin of design:

The winter in the north is really cold, but the company's heating pipes have been broken since I started working. I only rely on an air conditioner for heating. When it snows, the office becomes even colder. I had no choice but to buy a small air heater and put it under my feet. Now my legs are no longer cold, but a new problem has arisen. Every time after get off work, I always worry about whether the hot air blower is turned off. I have driven back to the company several times to confirm whether the hot air blower has been turned off after get off work. Now it happens that Lichuang EDA is conducting an advanced version of summer training to train people on Internet of Things related knowledge. Therefore, making a remote-controlled socket can come in handy this winter. I can use the mobile phone APP to remotely view and control my small hot air blower, so I don’t have to drive back to the company to confirm whether it is turned off and whether it is safe. Isn’t it wonderful?

2. Planned functions and solution selection:

Functional requirements
  1. Connect to the Alibaba Cloud platform to remotely control the on/off switch.
  2. Local control switch on and off
  3. Can be plugged into other electrical appliances to detect voltage, current and power, and can be used as a power meter
  4. Has perpetual calendar function
  5. Can measure indoor temperature and humidity
  6. Various functions can be displayed on the TFT color screen.
Solution selection
  • Main control selection:

Choose STMicroelectronics STM32F030C8T6.          STM32F030 uses ARM Cortex core with operating speed up to 48 MHz. STM32F030 is the lowest-priced product in the STM32 series, with extremely high cost performance, FLAS capacity of 64K, RAM 8K, and supports online simulation functions. I have used it in many projects and its performance is stable and reliable.                image.png

  • WIFI module selection:

Since I have no foundation in cloud platforms, I followed the training group to choose the Qingke module EMW3080 and the ILOP.A236 Alibaba Cloud Feiyan firmware.               image.png

  • Relay selection:

Choose the affordable Songle relay model: SRD-05VDC-SL-C            image.png

  • High-precision RTC clock: DS3231M, a milestone in the RTC industry, was selected. After project testing, its accuracy is comparable to that of radio-controlled clocks.

image.png

  • The EEPROM memory selected is FT24C16A-ELR-T, which is small in size, low in price, large in capacity, stable and reliable.

image.png

  • Temperature and humidity sensor

Use DHT11     humidity measurement range 5-95%RH     Resolution: 16Bit    Temperature range -20-60 degrees   Resolution: 16Bit

  • Voltage current power measurement part

Heli chose the HLW8032 fuel gauge chip, which has excellent performance, high precision, simple circuit and no need for transformer sampling.  It can measure active power, apparent power, current and voltage effective value.   The active energy pulse PF pin output  is within the dynamic range of 1000: 1. The measurement error of active power reaches 0.2%.  Within the dynamic range of 1000: 1, the effective current is The measurement error reaches 0.5%.  Within the dynamic range of 1000: 1, the measurement error of the effective voltage reaches 0.5%.  UART communication, convenient access * SOP8 package type image.png

  • Isolate the communication part:

Since the control part is the weak point, and the sampling part uses strong electricity and needs to be isolated, the DCDC module of Hailink HLK-1D0505 is used to power the power measurement part. image.png Rongpai π121U31 isolated communication is used for power module data to be sent to MCU for sampling after being electrically isolated. image.png

  • IPS display part

Using Zhongjingyuan IPS0.96 color screen module, the display is clear and the resolution is high. image.png

  • The WIFI module of the power supply part uses the AMS1117-3.3 classic buck module, and the MCU part uses the XC6206P332MR for separate power supply to reduce mutual interference.

image.pngimage.png

3. Schematic diagram and PCB design

  • The power supply part is designed to use both USB and XH socket designs. USB is convenient for early debugging and power supply. The actual product uses a 2-core socket for power supply. Multiple filter decoupling capacitors are added to ensure stable power supply for each module.

image.png

  • WIFI module part: Refer to the official circuit design, and a jumper cap is designed for the serial port part. Conveniently connect to computer for debugging and upgrading programs.

image.png

  • For the MCU part, the official recommended basic working circuit adds a simulation interface and a button.

image.png

  • The temperature and humidity sensor is relatively simple. The single bus part only requires a pull-up resistor.

image.png

  • Display part, a TFT color screen module and 2 indicators

image.png

  • Since the clock module and EEPROM are both IIC interfaces, they are connected to an IIC bus.

image.pngimage.png

  • Finally, there is the strong current part, power measurement: this part refers to the recommended circuit of the chip, and adds isolated power supply and communication parts.

image.png

  • When laying out the PCB, the main consideration is that the WIFI antenna part needs clearance, and a sufficient safety distance needs to be left for strong and weak electricity. If the distance is not enough, slotting will reduce creepage and increase the safety distance.

image.png

Fourth, design the shell.

  • Now that PCB is here, it’s time to find a home for him. Design the enclosure and prepare it for 3D printing. The shell effect of software simulation.

image.png

Fifth, the PCB was sent to Jiali Creation for production, and the code began to be transplanted.

The code shared by Mr. Lingyao is 51. I use STM32F030 so I need to transplant the key parts of the code. Mainly need to transplant two parts of code, one part is the timer, and the other part is the serial port.

  • In the timer part, set the timer 2 to 1ms to interrupt once, and the user can schedule each task.

image.png         The timer interrupt service program performs timing operations for each task.          image.png

  • Serial port part

Configure serial port 0 to 115200, 1,8,N,1 mode to connect to the WIFI module.        image.png       image.png

image.png    The main bottom part of the serial port 1 interrupt processing WIFI business logic     has been transplanted.

6. Anxiously waiting for PCB

On August 15, there were still two days before the deadline for the job, and the PCB was still on the way. I called SF Express several times, and the PCB was finally delivered in the afternoon. image.png

  • Take one out and see: it’s not bad.

image.png

  • I quickly started welding. I was so anxious that I forgot to take pictures in the middle, and I welded it like this in one go.

image.png

  • Test the TFT screen, it's suitable.

image.png

  • Can’t wait to download the program

image.png

  • Yes, the WIFI module can communicate. Next, debug the power measurement and RTC clock, DHT11 temperature and humidity measurement, and TFT display part that you added.
  • Program debugging corner

image.png

7. Debugging program

Before the PCB came back, the program had already done some preliminary work, and the subsequent debugging was mainly about adding functions.

  • The debugging of the IPS0.96 color screen part took a lot of time. The main problem was that there was too much data displayed on the screen, which caused the main program to run slow enough and the scheduler to not work properly. Finally, based on the Zhongjingyuan routine , modify the SPI mode to DMA operation, which increases the serial number efficiency, so that the program can run normally.

Key configuration of DMA part image.png

  • HLW8032 part, this part is not difficult, configure the serial port 2-bit 4800, 1,8,E,1 mode. After receiving the data, just parse the data according to the official manual. The main work is to deal with the data valid bit flag. , special attention should be paid to the status register, otherwise inaccurate data will be read.

image.png

  • DS3231 part, this part of the code is transplanted from the previous project code, which is relatively easy to handle. One of the function parts does automatic conversion of the week

image.png

  • Finally, there is the temperature and humidity sensor DHT11. This single bus protocol chip has a lot of information on the Internet. For reference, after modifying IO, it works normally.

image.png After the program was completely transplanted, the device could work normally. It was already 2 o'clock at night.

8. APP part

Click to create a new project, image.png enter the project name, and click Confirm. image.png After selecting the project, add the required functions image.png and custom functions image.png . Record each identifier. The program must correspond to each identifier, otherwise the APP and the physical object cannot correspond. Choose to use the public APP image.png to choose the sharing method image.png . The preferred network distribution method is one-click network distribution, and the backup method is AP network distribution. image.png There is a compatibility issue with some routers and the configuration cannot be successful. I can easily configure the network at home and at work. But in the hotel where I am on a business trip, the configuration cannot be successful. Maybe the router has been set up. I do not understand! Scroll to the end of the multilingual list and click Save, because it is not for foreigners. image.png


I started to choose the panel design function. It took a lot of time here. The panel I made could not control the device. Later I found out that the identifier did not correspond to the program. After many attempts and code modifications, I finally found the problem. image.png Open the Tmall Elf option image.png and design the APP myself. For me, who is weak in color, the design panel is a nightmare. Fortunately, the functions can be realized normally, haha. . . . image.png Select the next step of device debugging, image.png add a new test device image.png , then record the triplet   image.png and add the triplet to your own device, and you can exchange messages with Alibaba Cloud.

  • APP debugging

image.png

9. Finished product display

Now comes the shell. The 3D printed one is a bit ugly, but at least it has some clothes, hehe. image.png

  • How to put on clothes

image.png

  • Let’s take a close-up of the screen;

image.png

  • Compared with commercial power meters, the accuracy is very good.

image.pngimage.png

  • The Tmall Genie control is also normal. I also wanted to upload the video controlled by the Tmall Genie, but I was on a business trip and the Tmall Genie was not around.









参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2024-11-22 12:07:40

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

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号