pj0kLwt

ESP32 Desktop Assistant

 
Overview
Based on the LCSC ESP32 S3 development board and using the ESP IDF as the development environment, a simple desktop assistant was created to achieve WiFi connectivity, remote air conditioner on/off control, temperature and humidity monitoring and uploading, and time display functions.
 
 
1. Function Introduction
This project was designed and built using the LCSC ESP32 S3 development board. Currently, it has achieved WiFi connectivity, remote air conditioner on/off control, temperature and humidity monitoring and uploading, time display, and cloud-based intelligent APP interface display and control functions.
 
2. Schematic Diagram Explanation
2.1 Power Supply Circuit
The power supply adopts a USB + lithium battery power supply scheme. When the USB socket is plugged in, the system is powered by the USB and charges the lithium battery; when the USB socket is unplugged, the power circuit is powered by the lithium battery.
                               USB power supply interface Lithium battery charging circuit
2.2 Automatic Switching of Power Supply Circuit
The key to achieving automatic switching of the power supply circuit is the use of a PNP type MOSFET. The
voltage Vgs of the MOSFET determines the on/off state of the circuit. When powered by USB, the potential at point G of the PNP transistor is pulled high by the voltage divider resistor, Vgs > 0, the MOSFET is cut off, and the lithium battery does not supply power. When only the lithium battery is powered, point G is grounded, the voltage is 0V, the Vgs
transistor is turned on, and a Schottky diode is connected at the USB output to prevent the two circuits from interfering with each other.
 
                                                     The power supply switching circuit
2.3
includes a 5V boost circuit. The ESP32S3 development board has a 3.3V LDO. Considering the instability of the lithium battery, a 5V boost regulator circuit is designed in the circuit to stabilize the voltage and maintain stable device operation. The boost chip selected is the Chipstar X4310, which outputs a fixed 5V when the input is 2.7~5V,
providing a stable voltage for chip operation. 2.4 Lithium Battery
                                                 Charging
Management Circuit
: Regarding the lithium battery charging and discharging circuit, the commonly used TP4054 charging and discharging management chip was used. The maximum charging current is 500mA, and this current can be adjusted by changing the resistor. During charging, pin 1 of the chip is grounded, and the LED lights up. When the battery is fully charged,
pin 1 switches to a high state, and the LED turns off. The battery charging status can be determined by the LED's on/off state. 2.5 Display
                                                   Circuit: The display circuit uses a 1.8-inch OLED screen. This screen uses an SPI interface for communication, resulting in a stable refresh rate and good display quality. 2.6 Infrared                                                                 Transmitting Circuit: According to the Espressif official manual, the ESP32S3 has infrared functionality and can transmit infrared signals through configuration functions. However, after verification, the transmitted infrared signal is only 32 bits (refer to the Espressif official API for details). However, actual measurements showed that the air conditioner remote control sends signals of over 100 bits at a time. Therefore, after multiple attempts, this solution was abandoned. Therefore, the infrared emitting circuit in this project uses a timer to output a 38kHz PWM waveform to simulate the infrared NEC protocol. The circuit is controlled by two I/O ports: one for enabling the signal and the other for transmitting the signal. All I/O ports are controlled by PNP transistors to turn on and off, and the NEC protocol is simulated through encoding.                                                                 2.7 Temperature, Humidity, and Light Detection                                 Circuit : The temperature and humidity sensor uses the cost-effective DHT11, costing less than two yuan per sensor. Light detection uses a photoresistor voltage divider, and then the voltage is read and converted by an ADC. 3. Physical Image                           of the Temperature, Humidity, and Light Detection Circuit :                                                   [Image of the physical product and its                                             display on the cloud smart APP] 4. PCB Design Notes: In the PCB design, the power supply traces should be thickened, and copper pours should be used for connections when necessary. 5. Key Program Descriptions                                       5.1                                        The Alibaba Cloud platform access project uses the MQTT protocol to connect to Alibaba Cloud. Before writing the program, you need to register an account on the Alibaba Cloud IoT platform, create products and devices, and define product functions:                        Alibaba Cloud Platform Product Creation                       Alibaba Cloud Platform Function Definition                        Alibaba Cloud Platform Device Creation After the device is created, we can obtain the MQTT connection parameters and the Topic list used for attribute subscription and publication:                                     MQTT Connection Parameters                                       Topic List Write the above information into the code as follows: After                               writing the information into the code , connect to WIFI and use the mqtt_app_start() function to initialize and connect the device to Alibaba Cloud. 5.2 Alibaba Cloud Message Subscription and Publication After writing the Topic list into the program as described in 5.1, we can create messages using cJSON and then call the esp_mqtt_client_publish function to publish the message:



 
 
 









 



 




 







 

 
 




 
 
 


 
Note that when publishing messages, the variable names on our local machine must be consistent with those set on Alibaba Cloud to ensure that Alibaba Cloud can recognize the information we publish. As for subscribing to topics,
simply add the relevant Topic list during initialization. After receiving a subscription, the relevant message will be printed to the console. Alternatively, we can use cJSON to parse the message and
obtain the content we need.
 
5.3 Infrared Signal Transmission
The infrared signal uses a PWM waveform generated by a timer to simulate NEC timing for information transmission. The relevant timing definitions are as follows:
Logic 1 and Logic 0:
Logic "0": 560µs effective pulse + 560µs idle interval, total duration 1.12ms. Logic "1": 560µs effective pulse + 1.68ms idle interval, total duration 2.24ms (twice that of Logic 0).
Start Code:
The start flag sequence for each frame is: a 9ms AGC pulse (16 times the 560µs pulse used for logic data bits) + 4.5ms idle.
Therefore, based on the above information, the NEC waveform can be simulated as follows:
 
Once the relevant code is determined, a signal can be sent through the ESP32's IO port to control the air conditioner's on/off state. The question then arises: how to determine the air conditioner control code?
If the air conditioner brand is commonly used, you can search online; you might find it. If it's less commonly used, or an older model, such as the air conditioner this project
requires control, then use an oscilloscope to measure it!
 
The image above shows the infrared receiver output waveform tested with an oscilloscope when the air conditioner is turned on. The power-on code information can be obtained through protocol analysis.
(Actually, it's not that complicated. You only need an infrared decoder, connected to a microcontroller, and an infrared receiver code ported from the internet. The oscilloscope is mainly used for convenient waveform observation during debugging.)
 
 
 
6. Assembly Instructions:
All resistors and capacitors in this project use 0603 packages. Only the chip soldering is relatively difficult; with a few attempts, you can complete the soldering. After the code is burned, install the product into the casing. Note that there are four 1.8mm diameter posts for positioning at the screen; do not break them.
 
 
 
 
 
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-25 04:21:58

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号