Skip to content

A comprehensive IoT solution for line detection and proximity sensing using ESP32 and TCRT5000 infrared reflective sensor, featuring a modern web interface for real-time monitoring and data logging.

Notifications You must be signed in to change notification settings

SimedruF/ESP32_TCRT5000_Tracking_Module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32 TCRT5000 Tracking Module

A comprehensive IoT solution for line detection and proximity sensing using ESP32 and TCRT5000 infrared reflective sensor, featuring a modern web interface for real-time monitoring and data logging.

ESP32 PlatformIO License

🎯 Features

Core Functionality

  • Real-time Line Detection: Detects black lines or nearby objects using infrared reflection
  • Dual Output Reading:
    • Digital output (HIGH/LOW detection)
    • Analog output (0-4095 intensity value)
  • Visual LED Indicator: Built-in LED responds to detection events
  • Detection Counter: Tracks total number of detection events

Web Interface

  • Modern Responsive UI: Clean, mobile-friendly design
  • Real-time Monitoring: Live sensor data updates every 500ms via AJAX
  • Data Visualization:
    • Current sensor status (Active/Standby)
    • Detection type indicator
    • Analog and digital values
    • Time since last detection
  • Data Logging:
    • Save individual readings with timestamps
    • Auto-save mode for continuous logging
    • Download all readings as text file
    • Clear saved data
  • Remote Access: Access from any device on the network

WiFi Capabilities

  • Dual WiFi Modes:
    • Station Mode: Connect to existing WiFi network
    • Access Point Mode: Creates own WiFi hotspot (fallback)
  • WiFi Configuration:
    • Web-based WiFi setup interface
    • Credentials stored in EEPROM (persistent)
    • Automatic reconnection on boot
    • Easy network switching
  • Status Monitoring: Real-time WiFi connection status and IP display

Future-Ready

  • Grid scanner system prepared (currently disabled)
  • Ready for integration with distance sensors (VL53L0X, VL53L1X, HC-SR04)
  • 2D heatmap visualization infrastructure in place

🔧 Hardware Requirements

Components

  • ESP32 Development Board (ESP32-WROOM recommended)
  • TCRT5000 Tracking Sensor Module
    • Digital output (D0)
    • Analog output (A0)
    • Adjustable sensitivity potentiometer
  • USB Cable for programming and power
  • Jumper Wires

Pin Configuration

TCRT5000 ESP32 Pin Description
VCC 3.3V or 5V Power supply
GND GND Ground
D0 GPIO 14 Digital output
A0 GPIO 34 Analog output

Note: GPIO 34 is input-only and ADC-capable (perfect for analog readings)

Wiring Diagram

ESP32                TCRT5000
┌──────────┐        ┌──────────┐
│          │        │          │
│      3.3V├────────┤VCC       │
│          │        │          │
│       GND├────────┤GND       │
│          │        │          │
│   GPIO 14├────────┤D0        │
│          │        │          │
│   GPIO 34├────────┤A0        │
│          │        │          │
│    GPIO 2├─LED    │          │
└──────────┘        └──────────┘

📦 Software Requirements

  • PlatformIO IDE (VS Code extension recommended)
  • Platform: Espressif 32
  • Framework: Arduino
  • Board: ESP32 Dev Module

🚀 Installation & Setup

1. Clone the Repository

git clone https://github.com/SimedruF/ESP32_TCRT5000_Tracking_Module.git
cd ESP32_TCRT5000_Tracking_Module

2. Open in PlatformIO

  • Open VS Code
  • Install PlatformIO extension if not already installed
  • File → Open Folder → Select project directory

3. Configure (Optional)

Edit src/main.cpp if you need to change:

  • Pin assignments
  • WiFi AP credentials (default: ESP32_IR_Receiver / 12345678)
  • Sensor threshold values
  • Update intervals

4. Build & Upload

# Build the project
platformio run

# Upload to ESP32
platformio run --target upload

# Monitor serial output
platformio device monitor

Or use PlatformIO buttons in VS Code toolbar.

📱 Usage

First Time Setup

  1. Power on ESP32: After upload, the device will start in Access Point mode
  2. Connect to WiFi:
    • SSID: ESP32_IR_Receiver
    • Password: 12345678
  3. Open Web Interface:
    • Navigate to: http://192.168.4.1
  4. (Optional) Configure Local WiFi:
    • Go to "📡 WiFi Configuration" tab
    • Enter your WiFi credentials
    • Click "Save and Connect"
    • Device will restart and connect to your network

Normal Operation

After WiFi configuration, the device will:

  1. Automatically connect to your WiFi on boot
  2. Display its IP address in Serial Monitor
  3. Be accessible at the assigned IP address (e.g., http://192.168.1.100)

Web Interface Tabs

📊 Sensor Monitoring

  • Status: Shows current sensor state (🟢 Active / ⚪ Standby)
  • Detection Type: LINE DETECTED / No detection
  • Analog Value: Raw sensor reading (0-4095)
  • Digital Value: Binary state (0=detected, 1=clear)
  • Detections Counter: Total detection events
  • Last Detection: Time elapsed since last event
  • Controls:
    • 💾 Save reading
    • 📥 Download all readings
    • 🗑️ Delete all data
    • 🔄 Auto-save toggle

📡 WiFi Configuration

  • View current WiFi status and IP address
  • Configure or change WiFi network
  • Clear saved WiFi credentials
  • Reset to Access Point mode

🔍 Sensor Calibration

The TCRT5000 module has an onboard potentiometer for sensitivity adjustment:

  1. Place sensor over the target surface
  2. Adjust potentiometer until the onboard LED indicator responds correctly
  3. Fine-tune for optimal detection range (typically 2-10mm)
  4. Test with different surfaces:
    • Black line → Digital output goes LOW
    • White surface → Digital output stays HIGH

Detection Behavior

Surface Distance Digital Output Analog Value Status
Black line Close LOW (0) High (>2000) 🟢 Active
White surface Close HIGH (1) Low (<1000) ⚪ Standby
No object Far HIGH (1) Very Low (<500) ⚪ Standby

📊 Data Format

Saved Readings File

Downloaded readings are saved in text format:

========================================
ESP32 TCRT5000 SENSOR - SAVED READINGS
========================================
Total readings: 10
Export date: 1234 seconds since boot
========================================

--- Reading #1 ---
Timestamp: 45s
Status: 🟢 Active
Detection Type: LINE DETECTED
Analog Value: 3245
Digital Value: 0

--- Reading #2 ---
...

🛠️ Project Structure

ESP32_TCRT5000_Tracking_Module/
├── src/
│   └── main.cpp              # Main application code
├── include/
│   └── README                # Include folder info
├── lib/
│   └── README                # Library folder info
├── test/
│   └── README                # Test folder info
├── platformio.ini            # PlatformIO configuration
└── README.md                 # This file

🔬 Technical Details

Memory Usage

  • Saved Readings: Maximum 50 readings stored in RAM
  • WiFi Credentials: Stored in ESP32 EEPROM (Preferences library)
  • Web Page: Stored in program memory (PROGMEM)

Networking

  • Web Server: Runs on port 80
  • Updates: AJAX polling every 500ms
  • AP Mode IP: 192.168.4.1
  • Station Mode IP: Assigned by DHCP

Performance

  • Detection Response: ~50ms
  • Web Update Rate: 500ms
  • WiFi Reconnection: Automatic with 20 retry attempts
  • Maximum Saved Readings: 50 entries

🔮 Future Enhancements

The following features are prepared but currently disabled:

Grid Scanner (Requires Distance Sensor)

  • 2D Heatmap Visualization: Canvas-based grid display
  • 256-cell Grid: 16×16 automatic scanning
  • Color-coded Intensity: Visual representation of readings
  • Export Capability: Download scan data

To Enable: Uncomment the grid scanner sections in main.cpp and add a distance sensor module (VL53L0X, VL53L1X, or HC-SR04).

🐛 Troubleshooting

Device Not Connecting to WiFi

  • Check SSID and password are correct
  • Ensure WiFi is 2.4GHz (ESP32 doesn't support 5GHz)
  • Clear WiFi credentials and reconfigure
  • Check serial monitor for error messages

Sensor Not Detecting

  • Verify wiring connections
  • Adjust sensitivity potentiometer
  • Check sensor distance (optimal: 2-10mm)
  • Test with high-contrast surfaces (black/white)

Cannot Access Web Interface

  • Verify device IP address from serial monitor
  • Ensure device and client are on same network
  • Try Access Point mode if station mode fails
  • Check firewall settings

LED Not Blinking

  • Verify GPIO 2 connection (built-in LED)
  • Check sensor is actually detecting
  • View serial monitor for detection events

📝 Serial Monitor Output

Expected output during operation:

TCRT5000 + ESP32: Sensor ready.
Digital Pin: 14
Analog Pin: 34

=== WIFI CONFIGURATION ===
WiFi credentials loaded from EEPROM
SSID: MyHomeWiFi

✅ Connected to WiFi!
IP Address: 192.168.1.100

✅ Web server started!
Functions: TCRT5000 sensor monitoring, save readings, WiFi configuration
========================

=== DETECTION EVENT ===
Status: LINE/OBJECT DETECTED
Digital: LOW (detected)
Analog: 3245

=== CLEAR ===
Status: No detection
Digital: HIGH (clear)
Analog: 542

🤝 Contributing

Contributions are welcome! Feel free to:

  • Report bugs
  • Suggest new features
  • Submit pull requests
  • Improve documentation

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

👤 Author

SimedruF

🙏 Acknowledgments

  • ESP32 Arduino Core Community
  • PlatformIO Development Team
  • TCRT5000 sensor documentation and community

📚 Additional Resources


If you find this project useful, please consider giving it a star!

About

A comprehensive IoT solution for line detection and proximity sensing using ESP32 and TCRT5000 infrared reflective sensor, featuring a modern web interface for real-time monitoring and data logging.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages