Introduction: NodeMCU With LDR

Picture of NodeMCU With LDR

Wassup Makers!

I'm with another simple Instructable. In this Instructable we will learn how to interface LDR called as Light Dependent Resistor with NodeMCU.

What is a Light Dependent Resistor or a Photo Resistor?

A Light Dependent Resistor (LDR) or a photo resistor is a device whose resistivity is a function of the incident electromagnetic radiation. Hence, they are light sensitive devices. They are also called as photo conductors, photo conductive cells or simply photocells. They are made up of semiconductor materials having high resistance.

Step 1: What You Need

Picture of What You Need

List of parts required:

Hardware Required

  • NodeMCU
  • LDR / photoresistor
  • 10k ohm resistor
  • Breadboard
  • Micro USB cable
  • Connecting Wires

Software Required

  • Arduino IDE (with ESP8266 Library installed)

Step 2: Circuit Connections

Picture of Circuit Connections

The LDR output is actually analog in nature, so it gets connected to the A0 pin of the NodeMCU.

Really quite simple right, just wire your prototype up like the schematic.

Before you get started with coding you need Arduino IDE.To download Arduino IDE and for NodeMCU setup, you can check my previous instructacle.

"Interfacing Servo Motor With NodeMCU"

Step 3: Coding Time

Picture of Coding Time
void setup() {
	Serial.begin(9600);   // initialize serial communication at 9600 BPS
void loop() {

	int sensorValue = analogRead(A0);   // read the input on analog pin 0

	float voltage = sensorValue * (5.0 / 1023.0);   // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V)

	Serial.println(voltage);   // print out the value you read


Download the "LDR.ino" file and open it up in the Arduino IDE.

Then Create a new sketch and paste the code below in the Arduino IDE and hit Upload.

You can tinker with it if you like based on the application, or just use it as it is.

Step 4: Output

Picture of Output

That's all makers!

It takes less time to create this instructable, and its fun too.
Thank you for taking your time to read my instructable. I hope you enjoy it as I enjoy making it and documenting it to show and tell to other fellow makers here.

CIAO!! with another interesting Instructables!


About This Instructable




Bio: Work until you no longer have to introduce yourself.
More by TheCircuit:Carrot Almond MilkshakeDIY - Flower VasePotato Stuffing - Who's Hungry
Add instructable to: