1. Design Requirements
(What kind of faucet do we want to create?)
1. Supports electric switch faucet
2. Supports remote control and internet connection (what’s smart home without internet?)
3. Supports overflow detection
2. Technology Stack(What technologies do we need to meet the above requirements?)
1. SolidWorks Mechanical Modeling
SolidWorks is a powerful software with numerous components. It is known for its strong functionality, ease of learning, and technical innovation, making it a leading mainstream 3D CAD solution. SolidWorks can provide different design options, reduce errors during the design process, and improve product quality. It not only offers such powerful features but is also easy to operate for every engineer and designer.
For users familiar with Windows systems, they can basically use SolidWorks for design. SolidWorks’ unique drag-and-drop feature allows users to complete large assembly designs in a relatively short time. The SolidWorks Resource Manager is similar to the Windows Resource Manager, allowing for easy management of CAD files. By using SolidWorks, users can accomplish more work in less time and bring high-quality products to market faster. Among the 3D CAD solutions available today, SolidWorks is one of the most convenient and user-friendly software for the design process. With its powerful design capabilities and easy-to-learn operations (including Windows-style drag/drop, click/cut, and paste), using SolidWorks allows for 100% editable product design, with full relevance between part design, assembly design, and engineering drawings.
2. ESP32 Development (Arduino Environment)
The ESP32 is a series of MCUs (Microcontrollers) developed by Espressif Systems.

The main features of the ESP32 include:
○ Stable performance, with a working temperature range of -40°C to +125°C. The integrated self-calibration circuit enables dynamic voltage adjustment, eliminating defects in external circuits and adapting to changes in external conditions.
○ Highly integrated, the ESP32 combines functions such as antenna switch, RF balun, power amplifier, low-noise receiver amplifier, filter, and power management module. The ESP32 requires very few peripheral devices to achieve powerful processing performance, reliable security features, and Wi-Fi & Bluetooth functionality.
○ Ultra-low power consumption, the ESP32 is designed for mobile devices, wearable electronics, and IoT applications, with industry-leading low power performance, including fine-grained clock gating, power-saving modes, and dynamic voltage adjustment.
○ Wi-Fi & Bluetooth solutions, the ESP32 can run applications as an independent system or as a slave device to a host MCU, providing Wi-Fi and Bluetooth functionality through SPI/SDIO or I2C/UART interfaces.
For more detailed information, click here -> Gateway
(https://www.espressif.com.cn/zh-hans/products/devkits/esp32-devkitc)
Most importantly, the ESP32 supports Arduino development, greatly increasing productivity and lowering the development threshold.
3. MQTT Communication Protocol

MQTT (Message Queuing Telemetry Transport) is an ISO standard (ISO/IEC PRF 20922) based on the publish/subscribe messaging protocol. It operates over the TCP/IP protocol suite and is designed for remote devices with low hardware performance and poor network conditions.
The MQTT protocol is designed for communication between remote sensors and control devices that have limited computing power and operate in low bandwidth, unreliable networks. It has several key features:
1. Uses the publish/subscribe messaging model, providing one-to-many message publishing, decoupling applications;
2. Message transmission with payload content masking;
3. Uses TCP/IP for network connectivity;
4. Offers three levels of message delivery quality;
5. Small transmission with minimal overhead (fixed-length header is 2 bytes), minimizing protocol exchanges to reduce network traffic;
6. Uses Last Will and Testament features to notify relevant parties of client abnormal disconnections.
The greatest advantage of MQTT is that it provides real-time reliable messaging services for connecting remote devices with minimal code and limited bandwidth.
As a low-overhead, low-bandwidth instant messaging protocol, it has a wide range of applications in IoT, small devices, and mobile applications.
It is the most suitable communication protocol for our design needs.
In this design, we will set up an MQTT server on Ubuntu and subscribe to and publish topics in ESP32S3, even connecting to the ROS system, allowing ESP32 to act as a “physical node” integrated into ROS.
4. Circuit Design
Thanks to the development of e-commerce, we can now easily purchase most “electronic modules,” allowing us to complete a small invention like building blocks.
Thus, we do not need to start from scratch to build a complete functional circuit; we only need to add corresponding modules based on design requirements.
3. System Structure Design (What systems do we need, and how should these systems cooperate?)
1. Faucet Selection
First, we need to buy a faucet, and based on this faucet, determine the type of motor needed, the design of the driving mechanical structure, and the power circuit based on the motor model…
So I found a great faucet in my bathroom!
• The lower part of the rotary cap is smooth and cylindrical, allowing for the installation of a driven gear ring.
• The position between the water pipe interface and the main body can accommodate the motor’s bracket.
• The resistance of the faucet switch is moderate, allowing a small motor to drive it.

2. Motor and Power Supply System Selection
Considering the above features:
The motor is selected as the MG310 motor with a reduction ratio of 1:20.

The motor driver is selected as the TB6612 module.

The power supply system uses a 1000mAh lithium battery as the power source.

The TP4056 charging module is used as the charge and discharge board for the lithium battery.

Using a DC-DC boost module, the battery voltage is boosted to 5V.

3. Main Control System and Sensor Selection
For the main control selection, there is no need to think too much; just go for the S3 (the price difference between S3 and the “basic version” is only four or five yuan).
ESP32S3 DevKitC

For the sensor, we choose a thin film pressure sensor to analyze the pressure change curve to determine if the water storage container is overflowing.
Additionally, we will use a resistor voltage conversion module with the thin film pressure sensor to convert the resistance change into a voltage change for the microcontroller to collect signals.
• FSR402 thin film pressure sensor
• Voltage conversion module

4. Mechanical Structure Design
To put an elephant in a refrigerator requires three steps; mechanical design also requires three steps: open SolidWorks, take a caliper, and measure frantically.
1. Design of the Driven Gear Ring of the Faucet
How should the gear ring be designed? How many teeth are appropriate? What tooth shape is suitable? How should they mesh? How wide and thick should it be? Every detail needs careful consideration.
If the gear ring is too thin, it is not conducive to fixing; if too thick, it may interfere with the motor and driving wheel. However, after comparing the sizes of the faucet and the motor, the value of 8mm is very appropriate (specific tests are still required).
If the tooth shape is too large, it will lead to inability to mesh, increasing the size of the driving wheel. Because the gear ring and the gear are made via 3D printing, if too small, the teeth will be directly worn down… Therefore, let’s tentatively set it to 1mm; this size should meet the requirements based on experience (specific tests are still required).
Due to the complexity of the structure, it is unwise to install limit switches on both sides of the faucet. Instead, let the motor rotate for a certain period to ensure the faucet is “tightened.” However, the motor is prone to burning out due to overcurrent when stalled; how should we resolve this? A good solution is to print the gear ring with TPU material, which has the advantages of high strength, high toughness, and wear resistance. This way, the driving gear can slide against the gear ring at the end of the faucet’s rotation.

2. Design of the Driving Gear
The driving gear is mounted on the motor shaft and needs to mesh with the gear ring, so the radius of the driving gear determines the motor installation position and the transmission ratio between the motor and the faucet. After comparing and calculating the measurement data, the diameter is set to 10mm.
However, we cannot open our phones to remotely control the faucet while using it, so we need to consider the manual use of the faucet. What happens when we turn the faucet by hand?
The driven gear ring will drive the driving gear and the motor to rotate. It is important to note that these are two effort levers! This will increase the resistance to turning the faucet and also increase wear; the motor may also generate electricity in reverse, potentially damaging the circuit.
So how do we solve this problem?
It’s simple; we just need to leave a few teeth missing on the driving wheel. This way, when the gear ring moves the driving wheel in reverse, it will not be able to turn the driving wheel when it reaches the missing tooth section!

3. Design of the Motor Bracket
The design of the motor bracket needs to consider the meshing between the driving and driven gears, as well as the interference with the main body of the faucet, and how to fix the motor bracket.
As always, measure and calculate the dimensions of each structure, and after considering issues such as 3D printing:

The upper part of the bracket is the slot for placing the motor, and the motor can be fixed with two screws. The lower part of the bracket has a frame that can be glued to the faucet.
After assembling and debugging the parts via 3D printing, the next step is to design the circuit and software. Students who need the model files can log in to Guyueju to view the original text for interaction.
Original article link: http://www.guyuehome.com/45338

↑ Hot course, limited time coupon! 🎉 Grab it now ↑