Darkness Sensor Relay - Turn The 12v Light Bulb On/off

About the project

In this tutorial we will learn how to turn the 12V Light Bulb ON, when darkness is detected, using a relay module and a BH1750 Light sensor.

Project info

Difficulty: Easy

Platforms: ArduinoVisuino

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

Jumper wires (generic) Jumper wires (generic) x 1
Bench Power Supply, DC Bench Power Supply, DC x 1
Light bulb 12V Light bulb 12V x 1
Arduino Relay Module Arduino Relay Module x 1
BH1750 Light sensor I2C BH1750 Light sensor I2C x 1
Arduino UNO Arduino UNO x 1

Software apps and online services

Visuino Visuino
Arduino IDE Arduino IDE

Story

In this tutorial we will learn how to turn the 12V Light Bulb ON, when darkness is detected, using a relay module and a BH1750 Light sensor.

Watch the Video!

Step 1: What You Will Need

1 / 5

  • Arduino UNO or any other Arduino board
  • 12V Light Bulb
  • 12V Power supply / Battery for the Light Bulb
  • Relay module
  • BH1750 Ambient Light Sensor (I2C)
  • Jumper wires
  • Visuino software: Download here

Step 2: Circuit

  • Connect Light Sensor pin [SCL] to Arduino pin [SCL]
  • Connect Light Sensor pin [SDA] to Arduino pin [SDA]
  • Connect Light Sensor pin [VCC] to Arduino pin [5v]
  • Connect Light Sensor pin [GND] to Arduino pin [GND]
  • Connect Relay VCC pin(+) to Arduino 5V pin
  • Connect Relay GND pin(-) to Arduino GND pin
  • Connect Relay signal pin(S) to Arduino Digital pin [2]
  • Connect power supply 12V (+) to the Lamp positive (+)
  • Connect power supply 12V (-) to the relay pin (NO)
  • Connect Lamp negative (-) to relay pin(com)

Step 3: Start Visuino, and Select the Arduino UNO Board Type

1 / 2

The Visuino: https://www.visuino.eu also needs to be installed. Download Free version or register for a Free Trial.

Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2

Step 4: In Visuino Add, Set & Connect Components

1 / 4

  • Add "ROHM BH1750 Ambient Light Sensor (I2C)" component
  • Add "Compare Analog Value" component
  • Select CompareValue1 and in the properties window set Compare Type to ctSmallerOrEqual and Value to 20Note: the Value 20 is for darkness sensitivity, you can adjust this value
  • Connect "LightSensor1" pin I2C Control to Arduino I2C In
  • Connect "LightSensor1" pin Out to "CompareValue1" pin In
  • Connect "CompareValue1" pin Out to Arduino digital pin [2]

Step 5: Generate, Compile, and Upload the Arduino Code

In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Step 6: Play

If you power the Arduino module, the Lamp will start to shine if you cover the sensor so that it can detect darkness.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this tutorial, you can download it and open it in Visuino: https://www.visuino.eu

Schematics, diagrams and documents

Visuino File

Code

Visuino File

Credits

Photo of Ron

Ron

Arduino Developer

   

Leave your feedback...