ESP32 and IR Line tracking sensor example

This is another example using a sensor from the 37 sensor kit, this time we use the one called the KY-033 Hunt sensor module.

A more correct name would be a IR Line tracking sensor
The sensor has IR light emitter and detector. The sensor returns the status of the IR light reflected from a surface as ON or OFF. The on board LED shows the status of the sensor. You need to calibrate the sensor first, basically block the sensor and adjust the pot until the led goes on. Then remove the object and the on board LED should go off.

This is a picture of the module

here are the connections I used

Sensor Wemos Lolin32
V+ 3v3



Not overly complex this example, I noticed that using the serial monitor that the value was 559 when no object was present and around 29 when I blocked the sensor so I decided that if the value was under 100 I would switch the built in wemos led off, default being on in this example

int sensorPin = A0; // select the input pin
int sensorValue = 0; // variable to store the value coming from the sensor

void setup ()
pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output
Serial.begin (9600);

void loop ()
sensorValue = analogRead (sensorPin);
Serial.println (sensorValue, DEC); //debug
if(sensorValue <= 100)
digitalWrite (BUILTIN_LED, HIGH); //led off
digitalWrite (BUILTIN_LED, LOW); //led on - default



Diy KY-033 One Channel 3 pin Tracking Path Tracing Module Intelligent Vehicle Probe Infrared Detection Sensor

Previous articleESP32 and AM2301 sensor example
Next articleESP32 TCS3200 Color Sensor Module example