ESP32 YL-99 Limit Switch Safety System
The ESP32 YL-99 Limit Switch Safety System is a reliable solution for detecting mechanical limits in machines. The YL-99 module is a compact limit switch board that includes a mechanical switch and interface pins, making it easy to connect with microcontrollers like the ESP32.
This project helps prevent motor overtravel, machine damage, and mechanical failure in automation systems.
What is YL-99 Limit Switch?
The YL-99 Limit Switch Module is a mechanical micro-switch mounted on a PCB with 3 pins:
- VCC
- GND
- OUT
It works as a digital sensor and changes output state when the switch lever is pressed.
It is commonly used in:
- CNC machines
- 3D printers
- Elevators
- Conveyor systems
- Industrial automation
How ESP32 YL-99 Limit Switch Safety System Works
The ESP32 YL-99 Limit Switch Safety System works like this:
- The YL-99 is installed at the mechanical end position.
- When the moving part touches the switch, it presses the lever.
- The module output changes state.
- The ESP32 reads the signal.
- The ESP32 stops the motor or activates an alert.
This prevents over-movement and protects machinery.
ESP32 YL-99 Limit Switch Wiring Diagram
| YL-99 Pin | Connection to ESP32 |
|---|---|
| VCC | 3.3V |
| GND | GND |
| OUT | GPIO 26 |

ESP32 YL-99 Limit Switch Code
#define LIMIT_SWITCH 26
#define LED 2
void setup() {
Serial.begin(115200);
pinMode(LIMIT_SWITCH, INPUT);
pinMode(LED, OUTPUT);
Serial.println("ESP32 YL-99 Limit Switch Safety System Started");
}
void loop() {
int switchState = digitalRead(LIMIT_SWITCH);
if(switchState == LOW) {
Serial.println("Limit Reached! Stopping System.");
digitalWrite(LED, HIGH);
} else {
Serial.println("System Running Normally");
digitalWrite(LED, LOW);
}
delay(300);
}
How to Use It for Motor Safety
If you are using:
- L298N Motor Driver
- Relay Module
You can connect the motor control logic inside the if(switchState == LOW) condition to stop the motor immediately.
Example:
digitalWrite(MOTOR_PIN, LOW); // Stop motor
Applications of ESP32 YL-99 Limit Switch Safety System
- Lift end position detection
- Automatic gate stop system
- CNC axis protection
- Conveyor belt limit detection
- Robotic arm travel restriction
Advantages of YL-99 Limit Switch Module
✔ Easy to interface with ESP32
✔ Cheap and reliable
✔ Durable mechanical switch
✔ Ideal for industrial automation projects
✔ Suitable for engineering students
Conclusion
The ESP32 YL-99 Limit Switch Safety System is an essential project for automation and industrial safety. By using the YL-99 module with ESP32, you can easily build a reliable protection system for motors and machines.
FAQ – ESP32 YL-99 Limit Switch Safety System
Q1. Can YL-99 work with 3.3V ESP32?
Yes, the YL-99 module works perfectly with ESP32 3.3V logic.
Q2. Can I use YL-99 to stop a motor?
Yes, you can use a relay or motor driver with ESP32.
Q3. Is YL-99 normally open or normally closed?
It supports both configurations depending on wiring.

Leave a Reply
You must be logged in to post a comment.