This course will guide you through building an ESP32-based automatic car wash system, where you'll learn to design and implement a complex IoT project using a microcontroller. The system will utilize various sensors and actuators to automate the car wash process, including infrared sensors to detect vehicles, DC motors to move the vehicle and rotate brushes, and water pumps to spray soap and clean water.
Throughout the course, you'll gain hands-on experience with ESP32 programming, circuit design, and system integration. You'll learn how to read sensor data, control motors and pumps, and implement a state machine to manage the washing process. You'll also understand how to use a relay module to isolate the microcontroller from high-current devices and how to implement a cooling fan to dry the vehicle after rinsing.
The skills you'll acquire in this course are highly valuable in the field of IoT and embedded systems, where automation and sensor integration are increasingly important. By the end of the course, you'll have a fully functional automatic car wash system and a deep understanding of how to design and implement complex IoT projects using the ESP32 microcontroller. Some of the key topics covered include:
This course is ideal for intermediate learners who have a basic understanding of programming and electronics, but want to take their skills to the next level by building a complex IoT project. By the end of the course, you'll have a unique project to showcase your skills and a solid foundation for further exploration in the field of IoT and embedded systems.
| Component | Connection |
|---|---|
| ESP32 VIN | 5V Power Supply |
| Infrared Sensors VCC | 5V Power Supply |
| Infrared Sensors GND | Common Ground |
| Infrared Sensors OUT | ESP32 GPIO Input |
| Motor Driver VCC | 5V Power Supply |
| Motor Driver GND | Common Ground |
| Motor Driver Control Inputs | ESP32 GPIO Outputs |
| Conveyor Motors | Motor Driver Outputs (OUT1, OUT2) |
| Brush Motors | Motor Driver Outputs (OUT3, OUT4) |
| Relay Module VCC | 5V Power Supply |
| Relay Module GND | Common Ground |
| Relay Module Control Inputs | ESP32 GPIO Outputs |
| Soap Water Pump | Relay Module Output (NO1) |
| Clean Water Pump | Relay Module Output (NO2) |
| DC Cooling Fan | ESP32 GPIO or Transistor/MOSFET Driver |
| LED Indicator and Buzzer | ESP32 GPIO Output |
To begin, ensure all the necessary hardware components are available. The ESP32 Development Board, infrared sensors, motor driver module, relay module, motors, pumps, fan, buzzer, LED, and power supplies are crucial for the project. Familiarize yourself with the specifications and pinouts of each component to facilitate a smooth assembly process.
Start by connecting the ESP32 to the infrared sensors, motor driver module, relay module, and other peripherals. The wiring should be neat and organized to prevent errors and shorts.
Before proceeding, verify that all connections are correct and secure. Double-check the wiring against the component specifications and the project's circuit diagram to ensure accuracy.
Develop the firmware for the ESP32 using a suitable development environment such as the Arduino IDE or PlatformIO. The firmware should read the infrared sensors, control the motors, pumps, fan, buzzer, and LED based on the sensor inputs and the washing cycle.
Example code snippets may include digitalRead() for sensor inputs and digitalWrite() for controlling outputs.
Upload the firmware to the ESP32 using the chosen development environment and ensure the board is properly configured for the upload process.
With the firmware uploaded, proceed to test the automatic car wash system. Place a vehicle or a mock object in the washing area and observe the system's operation.
If issues arise during testing, refer to the following troubleshooting tips:
/*
ESP32 Automatic Car Wash System
Features:
- Vehicle detection using IR sensors
- Conveyor movement
- Brush motors
- Soap spraying
- Water rinsing
- Drying fan
- LED and buzzer indicators
*/
// ---------- Sensor Pins ----------
#define IR_ENTRY 34
#define IR_WASH 35
#define IR_EXIT 32
// ---------- Motor Driver Pins ----------
#define CONVEYOR_IN1 25
#define CONVEYOR_IN2 26
#define BRUSH_IN3 27
#define BRUSH_IN4 14
// ---------- Relay Pins ----------
#define SOAP_PUMP 12
#define WATER_PUMP 13
// ---------- Output Pins ----------
#define FAN_PIN 33
#define LED_PIN 2
#define BUZZER 4
// Washing states
enum WashState {
IDLE,
MOVE_TO_WASH,
SOAP_STAGE,
RINSE_STAGE,
DRY_STAGE,
COMPLETE
};
WashState state = IDLE;
void setup() {
Serial.begin(115200);
// Sensors
pinMode(IR_ENTRY, INPUT);
pinMode(IR_WASH, INPUT);
pinMode(IR_EXIT, INPUT);
// Motor driver
pinMode(CONVEYOR_IN1, OUTPUT);
pinMode(CONVEYOR_IN2, OUTPUT);
pinMode(BRUSH_IN3, OUTPUT);
pinMode(BRUSH_IN4, OUTPUT);
// Relays
pinMode(SOAP_PUMP, OUTPUT);
pinMode(WATER_PUMP, OUTPUT);
// Outputs
pinMode(FAN_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
pinMode(BUZZER, OUTPUT);
stopAll();
Serial.println("Automatic Car Wash Ready");
}
void loop() {
switch(state)
{
// -------------------------
// Waiting for car
// -------------------------
case IDLE:
if(digitalRead(IR_ENTRY)==LOW)
{
Serial.println("Vehicle detected");
beep();
state = MOVE_TO_WASH;
}
break;
// -------------------------
// Move vehicle into tunnel
// -------------------------
case MOVE_TO_WASH:
conveyorForward();
if(digitalRead(IR_WASH)==LOW)
{
stopConveyor();
Serial.println("Car in washing position");
state = SOAP_STAGE;
}
break;
// -------------------------
// Soap washing
// -------------------------
case SOAP_STAGE:
Serial.println("Applying soap");
brushOn();
digitalWrite(SOAP_PUMP,HIGH);
delay(5000);
digitalWrite(SOAP_PUMP,LOW);
state = RINSE_STAGE;
break;
// -------------------------
// Clean water rinse
// -------------------------
case RINSE_STAGE:
Serial.println("Rinsing");
digitalWrite(WATER_PUMP,HIGH);
delay(5000);
digitalWrite(WATER_PUMP,LOW);
state = DRY_STAGE;
break;
// -------------------------
// Drying stage
// -------------------------
case DRY_STAGE:
Serial.println("Drying vehicle");
brushOff();
digitalWrite(FAN_PIN,HIGH);
delay(7000);
digitalWrite(FAN_PIN,LOW);
state = COMPLETE;
break;
// -------------------------
// Move car out
// -------------------------
case COMPLETE:
Serial.println("Complete");
beep();
conveyorForward();
if(digitalRead(IR_EXIT)==LOW)
{
stopConveyor();
Serial.println("Vehicle exited");
state = IDLE;
}
break;
}
}
// =================================================
// MOTOR FUNCTIONS
// =================================================
void conveyorForward()
{
digitalWrite(CONVEYOR_IN1,HIGH);
digitalWrite(CONVEYOR_IN2,LOW);
}
void stopConveyor()
{
digitalWrite(CONVEYOR_IN1,LOW);
digitalWrite(CONVEYOR_IN2,LOW);
}
void brushOn()
{
digitalWrite(BRUSH_IN3,HIGH);
digitalWrite(BRUSH_IN4,LOW);
}
void brushOff()
{
digitalWrite(BRUSH_IN3,LOW);
digitalWrite(BRUSH_IN4,LOW);
}
// =================================================
// SYSTEM CONTROL
// =================================================
void stopAll()
{
stopConveyor();
brushOff();
digitalWrite(SOAP_PUMP,LOW);
digitalWrite(WATER_PUMP,LOW);
digitalWrite(FAN_PIN,LOW);
digitalWrite(LED_PIN,LOW);
}
void beep()
{
digitalWrite(BUZZER,HIGH);
digitalWrite(LED_PIN,HIGH);
delay(500);
digitalWrite(BUZZER,LOW);
digitalWrite(LED_PIN,LOW);
}
1. What is the main function of the ESP32 in the automatic car wash system? A. To supply power to all motors B. To act as the main controller that reads sensors and controls devices C. To clean the vehicle manually D. To replace the water pump Answer: B Explanation: The ESP32 works as the brain of the system. It processes sensor inputs and controls motors, pumps, relays, LEDs, and other actuators. 2. Which sensor is used to detect the vehicle position inside the car wash system? A. Temperature sensor B. Infrared obstacle sensor C. Gas sensor D. Pressure sensor Answer: B Explanation: Infrared sensors detect the presence and position of the vehicle at different stages, such as entry, washing position, and exit. 3. Why is a relay module used to control the water pumps? A. To increase the ESP32 processing speed B. To protect the ESP32 from high current loads C. To measure water temperature D. To provide internet connectivity Answer: B Explanation: Relays electrically isolate the ESP32 from high-power devices like pumps, allowing safe switching of higher voltage and current loads. 4. What programming concept is used to manage different washing stages such as soap, rinse, and drying? A. Random number generation B. State machine implementation C. Image processing D. Database management Answer: B Explanation: A state machine organizes the washing process into different states, allowing the ESP32 to execute each stage in the correct order. 5. Which component is responsible for drying the vehicle after rinsing? A. Cooling fan B. Soap pump C. Infrared sensor D. Motor driver Answer: A Explanation: The cooling fan blows air onto the vehicle after the rinse stage to remove water and complete the drying process.
If you don't already have the parts listed above, you can buy genuine Arduino, ESP32, Raspberry Pi, sensors, and other electronic components from SoftTech Supply Shop, with fast delivery across Kigali and Rwanda.
← Browse more IoT & Embedded Systems courses