Raspberry Pi Pico

Raspberry Pi Pico LDR sensor for Day and Night Detection

Raspberry Pi Pico LDR Sensor:


Raspberry Pi Pico LDR sensor for Day and Night Detection– In this article, I will show you how to make the day and night detection system. This is really an important example as I will be explaining how to use an LDR Light sensor and a relay module for controlling a 110/220Vac Light Bulb. This Light sensor is designed in a way that it only gives 1 or 0 as the output signal which makes it really easy to use. The light intensity level can be adjusted using this blue color potentiometer. Now, let’s go ahead and take a look at the circuit diagram.

Previous Articles:

Raspberry Pi Pico Vs Arduino.

Raspberry Pi Pico Pinout & Specs

Raspberry Pi Pico MicroPython and Thonny IDE Installation.

Raspberry Pi Pico Led examples.

Raspberry Pi Pico Digital Input.

Raspberry Pi Pico Oled Display Module SSD1306

Raspberry Pi Pico ADC Analog Sensor

Raspberry Pi Pico Temperature Sensor.

Raspberry Pi Pico Ultrasonic Sensor.

Raspberry Pi Pico PIR Motion Sensor.

Amazon Links:

Raspberry Pi Pico

Digital LDR module

12V Relay Module

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Raspberry Pi Pico Day and Night Detection Circuit:

Raspberry Pi Pico

The VCC and GND pins of the LDR module are connected with 3.3Volts and GND pins of the Raspberry Pi Pico while the D0 pin of the LDR module is connected with the GP14. This LDR module is slightly different from the one I will be using. This LDR module also gives analog output. While the one I am using gives only digital output.

The one channel relay module is controlled using the GP28 pin of the Raspberry Pi Pico. You can follow these connections if you want to make your own Relay module or you can use a readymade relay module. The 2n2222 NPN transistor and a10k ohm resistor makes the driver. I have a very detailed video on how to design your own driver circuit for different types of relays. I will add a link in the description.

Anyway, the Neutral wire from the 110/220Vac is directly connected with the light and the live wire from the supply is connected with the other contact of the light through this relay. So, that’s all about the connections.

Raspberry Pi Pico Day and Night Detection Code:

I defined two pins and I am going to call these as relay and ldr. As relay is an output device so that’s why I set it as output and as you know LDR sensor is an input device so that’s why I set it as input. Finally, we use an if condition to check if the output on the LDR sensor module is high or Low. So, if the Pico board detects a high signal then the Relay is turned ON, else the relay is turned OFF. Now, let’s go ahead and run this code.

Raspberry Pi Pico

When there is light falling on the LDR sensor then the light remains OFF.

Raspberry Pi Pico

When the light on the LDR sensor falls below a preset value then the light turns ON. Using these few electronic components you can make yourself a fully automatic street lights control system or Lawn lights control system, etc.

Watch Video:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button