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

ESP-8266 Controlled LDR Sensor Array with Serial Output

View and Edit Project In Cirkit DesignerImage of ESP-8266 Controlled LDR Sensor Array with Serial Output

Circuit Documentation

Summary

This circuit is designed around the ESP-8266 microcontroller and includes multiple sensors and indicators. The primary function of the circuit is to monitor light levels using six LDR sensors (LM393) and to provide visual feedback through LED indicators. The ESP-8266 reads the digital outputs from the LDR sensors and, upon detecting a change in light, prints a corresponding number to the console. The LEDs are controlled by the ESP-8266 to indicate various states or events as programmed.

Component List

Microcontroller

Sensors

Indicators

Communication Modules

Wiring Details

ESP-8266 Controller

Sensor LDR LM393

LED: Two Pin (red)

RFID-RC522

Documented Code

/*
 * This Arduino Sketch is designed for an ESP-8266 microcontroller. It reads the
 * digital output from six LDR sensors (LM393) connected to pins D0 to D5. When
 * any sensor detects a change in light, it prints a corresponding number (1-6)
 * to the console.
 */

void setup() {
  // Initialize serial communication at 115200 baud rate
  Serial.begin(115200);
  
  // Define pin modes for LDR sensors
  pinMode(D0, INPUT);
  pinMode(D1, INPUT);
  pinMode(D2, INPUT);
  pinMode(D3, INPUT);
  pinMode(D4, INPUT);
  pinMode(D5, INPUT);
}

void loop() {
  // Read the state of each LDR sensor
  if (digitalRead(D0) == HIGH) {
    Serial.println(1);
  }
  if (digitalRead(D1) == HIGH) {
    Serial.println(2);
  }
  if (digitalRead(D2) == HIGH) {
    Serial.println(3);
  }
  if (digitalRead(D3) == HIGH) {
    Serial.println(4);
  }
  if (digitalRead(D4) == HIGH) {
    Serial.println(5);
  }
  if (digitalRead(D5) == HIGH) {
    Serial.println(6);
  }
  
  // Small delay to avoid flooding the serial console
  delay(100);
}

The code is written for the Arduino platform and is intended to be uploaded to the ESP-8266 microcontroller. It sets up the serial communication and configures the digital pins connected to the LDR sensors as inputs. In the main loop, the code continuously checks the state of each LDR sensor and prints out a number corresponding to the sensor that detects a high signal, indicating a change in light levels. A short delay is included to prevent overwhelming the serial output.