Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based Luminosity Sensor with Serial Output

View and Edit Project In Cirkit DesignerImage of ESP32-Based Luminosity Sensor with Serial Output

Circuit Documentation

Summary of the Circuit

This circuit consists of a photocell (LDR) connected to an ESP32 microcontroller through a voltage divider configuration with a resistor. The ESP32 reads the analog value from the LDR to measure light intensity. The circuit also includes Qwiic cables for power distribution and potential I2C communication, although the I2C lines are not utilized in the current configuration.

Component List

Photocell (LDR)

Resistor

Qwiic Cable - Breadboard Jumper (4-pin)

ESP32 (30 pin)

Wiring Details

Photocell (LDR)

Resistor

Qwiic Cable - Breadboard Jumper (4-pin)

ESP32 (30 pin)

Documented Code

// Code for ESP32 microcontroller
const int LDR_PIN = 34; // Change to your chosen pin

void setup() {
  Serial.begin(115200); // Start serial communication at 115200 baud
}

void loop() {
  int ldrValue = analogRead(LDR_PIN); // Read the value from the LDR
  Serial.print("LDR Value: ");
  Serial.println(ldrValue); // Print the LDR value to the Serial Monitor

  delay(1000); // Wait for a second before the next reading
}

Filename: sketch.ino

Description: This code is written for the ESP32 microcontroller to read the analog value from an LDR connected to pin 34. The value is then printed to the Serial Monitor every second.