ESP32 TOF400C Time-of-Flight Sensor
Overview
The TOF400C is a long-range laser-based time-of-flight (ToF) sensor based on the VL53L1X chip from STMicroelectronics. It measures distances up to 4 meters with high accuracy and is ideal for robotics, navigation, and presence detection applications.
Choose Your Platform
About TOF400C Time-of-Flight Sensor
📏 TOF400C Sensor Overview
- Range: 0cm to 400cm (Max)
- Interface: I²C digital communication
- Resolution: 1mm accuracy
- Field of View: 27°
- Operating Voltage: 3.0V to 5.0V
- Typical Current: ~40mA
- Infrared Wavelength: 940nm
- Advanced Filtering and Timing Budget Control
Check Other sensors modules based on VL53L1X 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
📡 Sensor Not Responding
Issue: Sensor not detected via I²C.
Solution: Check pull-up resistors, wiring, and ensure SHUT pin is high or tied to VIN. Try scanning I²C address.
📉 Distance Readings Unstable
Issue: Inconsistent or flickering values.
Solution: Increase timing budget in code, shield from ambient light, or use reflective target surfaces.
⚠️ Reads Max Distance Constantly
Issue: Always shows max range (e.g. 4000 mm).
Solution: Ensure target is within FOV and reflective enough. Use long-range mode and increase integration time.
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_VL53L1X.h>
Adafruit_VL53L1X vl = Adafruit_VL53L1X();
void setup() {
Serial.begin(115200);
Wire.begin();
if (!vl.begin()) {
Serial.println("Failed to find TOF400C sensor!");
while (1);
}
vl.setDistanceMode(VL53L1X::Long);
vl.setTimingBudget(50);
vl.startRanging();
Serial.println("TOF400C ready!");
}
void loop() {
if (vl.dataReady()) {
int distance = vl.read();
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" mm");
}
delay(100);
}
ESPHome Example
i2c:
sda: 21
scl: 22
sensor:
- platform: vl53l1x
name: "TOF400C Distance"
long_range: true
update_interval: 1s
vl53l1x
component. It enables long-range mode and measures distance once per second.MicroPython Example
from machine import I2C, Pin
import time
from vl53l1x import VL53L1X
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
tof = VL53L1X(i2c)
tof.start()
while True:
distance = tof.read()
print("Distance: {} mm".format(distance))
time.sleep(0.5)
vl53l1x.py
driver.Conclusion
The ESP32 TOF400C 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.