Automatic Night Light using LDR Relay Arduino Quickly in 10 Minutes

You will learn how to make Automatic Night Light using LDR Relay Arduino UNO. We are nowadays want everything automated. Automatic Night Light is a very popular device. The light will glow in the night or when the area is dark. In the day time or bright condition light will be off.

Components Used:(Click to Buy)

Connection Setup for LDR Relay Arduino

How to connect 220V Ac with Relay

To Connect with AC line we need a small wire. The neutral line will be connected directly to the bulb. Live wire first go to COM port of Relay. Then one small wire will be connected to the bulb from Normally Open(NO) Port. In the following diagram, we have shown a battery instead of the AC line for your understanding.

How to connect Arduino with Relay

Connection with Arduino UNO is a very simple one. Just we have to connect 5V to the VCC and Ground to the GND. Then we have to connect the data line. Here we are using D4 pin.


If you want to control Light via WiFi in NodeMCU, see this post.

Home Automation Using ESP8266 NodeMCU with Relay

Connection Diagram for LDR Relay Arduino

You can connect seeing the following diagram. Just replace the LED with your 220V bulb & Battery with 220V AC line.

LDR Relay Arduino

I have connected 10K Ohm register with the LDR as a voltage divider. If you connect 3V led then use 220 Ohm register with the LED. If you use AC line, then no registor needed.

Code Explain of LDR Relay Arduino

The important thing in this code lies in line no 17. After determining the analogue value in dark condition on line no 24, set that value in the place of 650 on line 17.

The bulb will be on if outside area is dark as the code written on line no 18.

Arduino Sketch for LDR Relay Arduino

Output LDR Relay Arduino

Automatic Night Light using LDR and Relay in Arduino UNO

After all the connection done, you will notice the 220V Bulb will switch on/off depending upon present light condition.

Share with Friends
0 0 votes
Rating
guest
0 Comments
Inline Feedbacks
View all comments