ESP32 TOF050C Time-of-Flight Sensor
Overview
The TOF050C is a short-range laser-ranging sensor using the VL6180 chip, offering highly accurate distance measurements up to 50 cm. It is optimized for applications such as gesture recognition, proximity detection, and short-distance object tracking.
Choose Your Platform
About TOF050C Time-of-Flight Sensor
📏 TOF050C Sensor Overview
- Range: 0cm to 50cm (Max)
- Interface: I²C digital communication
- Resolution: 1mm accuracy
- Field of View: 25°
- Operating Voltage: 3.0V to 5.0V
- Typical Current: ~40mA
- Infrared Wavelength: 850nm
Check Other sensors modules based on VL6180X Time of Flight Sensor:
Where to Buy
Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
Technical Specifications
Pinout Configuration
The VCC
pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND
pin is the ground connection and must be connected to the ground of your ESP32.
- VIN: Power supply (3.0V – 5.0V)
- GND: Ground
- SDA: I²C Data
- SCL: I²C Clock
- INT: Interrupt output
- SHUT: Shutdown (active low)
Troubleshooting Guide
Common Issues
📉 Stuck at Zero Distance
Issue: Always reads 0 mm.
Solution: Make sure object is more than 2 cm away. This is a known blind zone of the VL6180 chip.
🚫 Sensor Not Detected
Issue: Sensor not found on I²C bus.
Solution: Check wiring and I²C pull-ups. Ensure SHUT pin is high.
⚡ Power Issues
Issue: Sensor unstable or resets frequently.
Solution: Use stable 3.3V/5V power supply capable of handling 40mA or more.
Debugging Tips
🔍 Serial Monitor
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
⚡ Voltage Checks
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
Code Examples
Arduino Example
#include <Wire.h>
#include <Adafruit_VL6180X.h>
Adafruit_VL6180X vl = Adafruit_VL6180X();
void setup() {
Serial.begin(115200);
Wire.begin();
if (!vl.begin()) {
Serial.println("Failed to find TOF050C sensor!");
while (1);
}
Serial.println("TOF050C ready!");
}
void loop() {
uint8_t range = vl.readRange();
Serial.print("Distance: ");
Serial.print(range);
Serial.println(" mm");
delay(500);
}
ESPHome Example
i2c:
sda: 21
scl: 22
sensor:
- platform: vl6180x
name: "TOF050C Distance"
update_interval: 1s
vl6180x
component to read distance from the TOF050C sensor over I²C, updating once per second.MicroPython Example
from machine import I2C, Pin
import time
from vl6180x import VL6180X
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
tof = VL6180X(i2c)
while True:
distance = tof.read()
print("Distance: {} mm".format(distance))
time.sleep(0.5)
vl6180x.py
driver, which should be uploaded to your board.Conclusion
The ESP32 TOF050C Time-of-Flight Sensor is a powerful distance sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.