The 4-pin TCRT5000 module is significantly more versatile than the 3-pin version because it provides both a Digital Output (D0) and an Analog Output (A0).
The Digital pin is perfect for "Yes/No" detection (like staying on a line), while the Analog pin allows you to see the intensity of the reflection, which is useful for measuring varying shades of gray or very small changes in distance.
Features
- Compatibility: Perfectly designed for Arduino projects, ensuring seamless integration and operation.
- Advanced Sensing: Utilizes IR technology with TCRT5000 sensors for accurate detection of reflective materials or barriers.
- Easy to Use: Simplified setup, suitable for beginners and professionals alike.
- Versatility: Ideal for a wide range of applications including line tracking robots, object detection, and automatic control systems.
- Optimized Design: Compact form factor for efficient performance.
Specifications
- Colour: Blue
- Material: ABS
Due to different batches, there may be differences in product printed text, which will not affect use.
What's in the box?
1 x Infrared Reflective Sensor
The 4-pin TCRT5000 module is significantly more versatile than the 3-pin version because it provides both a Digital Output (D0) and an Analog Output (A0).
The Digital pin is perfect for "Yes/No" detection (like staying on a line), while the Analog pin allows you to see the intensity of the reflection, which is useful for measuring varying shades of gray or very small changes in distance.
1. Hardware Connections (4-Pin Module)
| Module Pin | Raspberry Pi Pin | Physical Pin # | Function |
| VCC | 3.3V Power | Pin 1 | Power for the IR LED and comparator. |
| GND | Ground | Pin 6 | Common ground. |
| D0 | GPIO 17 | Pin 11 | Goes LOW when a reflection is detected. |
| A0 | See Note Below | — | Provides a voltage (0V to 3.3V) based on reflection. |
Important: The Raspberry Pi does not have a built-in Analog-to-Digital Converter (ADC). You cannot plug the A0 pin directly into a Pi GPIO and read its value. You have two choices:
- Ignore A0: Use only D0 for simple line following.
- Use an ADC Chip: Connect A0 to an MCP3008 chip if you need precise reflection data.
Python Code (gpiozero):
from gpiozero import DigitalInputDevice
from signal import pause
# TCRT5000 D0 is connected to GPIO 17
# pull_up=True because the sensor output is Active Low
sensor = DigitalInputDevice(17, pull_up=True)
def detected():
print("Reflection Detected! (LED on module should be lit)")
def cleared():
print("Reflection Lost.")
sensor.when_activated = detected
sensor.when_deactivated = cleared
print("Starting TCRT5000 Digital Test...")
pause()Wiring A0 through an ADC:
Connect A0 from the sensor to CH0 on the MCP3008.
Connect the MCP3008 to the Pi via the SPI pins (GPIO 8, 9, 10, 11).
Python Code (gpiozero with MCP3008):
from gpiozero import MCP3008
import time
# Create a reference to the Analog sensor on Channel 0 of the ADC
reflectivity = MCP3008(channel=0)
while True:
# Value will be between 0.0 (no reflection) and 1.0 (max reflection)
print(f"Reflection Intensity: {reflectivity.value:.2f}")
time.sleep(0.1)
Sensitivity Tuning: You can use the D0 pin for a fast interrupt-based response (like emergency stops) while simultaneously using A0 to log data or calibrate your robot's speed based on how well it sees the line.
Dual Monitoring: The onboard LED on the 4-pin module typically follows the D0 state. This makes it much easier to "sight in" your sensor by eye before you even write a single line of code.