Photoresistor Sensor

A photoresistor (also known as a light-dependent resistor or LDR) is a type of resistor whose resistance decreases as the intensity of light hitting the device increases. It is made of a semiconductor material that allows it to change resistance based on the amount of light it receives.

The working principle of a photoresistor is based on the photoelectric effect, which causes the resistance of the material to decrease when it absorbs photons from light. When light falls on the photoresistor, the energy from the light excites the electrons in the material, allowing them to flow more easily, which decreases the resistance.

  • Dark condition: High resistance (usually in the megaohms range, sometimes even higher).
  • Light condition: Low resistance (usually in the hundreds of ohms to kilo-ohms range, depending on the light intensity)

Photoresistor 5516

The Photoresistor 5516 is a common type of light-dependent resistor. It has a high resistance in the dark (in the megaohm range) and its resistance significantly drops when exposed to light.

  • Resistance in the dark: 1 MΩ to 10 MΩ.
  • Resistance in bright light: 10 KΩ to 100 KΩ.

These values can vary based on the intensity of the light source and the specifications of the specific photoresistor.

Using a Photoresistor with MCU

You cannot directly connect the photoresistor to a GPIO pin, and the other end to either VCC or GND. By driving the GPIO pin Low or High, you complete the circuit. The resistance of the photoresistor will change depending on the light intensity, which causes the current to vary since the voltage is fixed at 3.3V. However, the GPIO pin cannot measure the current directly. Instead, the analog input pin of the ESP32 can measure voltage. Therefore, to accurately detect changes, we need to use a voltage divider circuit.

In this case, a voltage divider circuit is used to measure the changing resistance of the photoresistor. The voltage divider consists of the photoresistor (LDR) and a fixed resistor (10K) connected in series. One end of the series combination is connected to the 3.3V supply, and the other end is connected to GND, with the junction between the two resistors connected to an analog input pin of the ESP32 (GPIO 34).

The process of measuring the voltage using the analog input pin of the ESP32 is called ADC (Analog-to-Digital Conversion).

As the light intensity changes, the resistance of the photoresistor changes, which in turn alters the voltage at the junction. The analog input pin can measure this voltage, allowing the ESP32 to sense the light level without directly measuring the current.

RELATED ARTICLES