Darkness Sensor and LED Using BH1750 & Arduino

by RonFrtek in Circuits > Arduino

1315 Views, 2 Favorites, 0 Comments

Darkness Sensor and LED Using BH1750 & Arduino

Darkness Sensor and LED Using BH1750 & Arduino

In this tutorial we will learn how to turn the LED ON when darkness is detected.

Watch the Video!

What You Will Need

GY-30 BH1750.jpg
FZEK4WBK3XGYAP0.LARGE.jpg
redled.png
jumper-wires.jpg
VisuinoAdvrtisementVersion8.jpg
  • Arduino UNO or any other Arduino board
  • LED
  • BH1750 Ambient Light Sensor (I2C)
  • Jumper wires
  • Visuino software: Download here

Circuit

2021-02-01_16-10-22.jpg
  • 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 LED positive pin {Long leg} to Arduino Digital pin 3
  • Connect LED negative pin {Short leg} to Arduino pin [GND]

Start Visuino, and Select the Arduino UNO Board Type

FRWQB80K1RVKKV9.LARGE.jpg
F311FBVK5AHN5HJ.LARGE.jpg

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

In Visuino ADD Components

2021-01-22_12-59-39.jpg
2021-01-22_13-00-47.jpg
2021-01-22_13-00-25.jpg
2021-01-22_13-00-06.jpg
  • Add "ROHM BH1750 Ambient Light Sensor (I2C)" component
  • Add "Limit Analog between Min and Max" component
  • Add "Map Range Analog" component
  • Add "Subtract From Analog Value" component

In Visuino Set & Connect Components

2021-01-22_13-01-53.jpg
2021-01-22_13-02-14.jpg
2021-01-22_13-03-18.jpg
2021-01-22_13-09-05.jpg
  • Select "Limit1" and in the properties window set Max to 20
  • Select "MapRange1" and in the properties window set Input Range > Max to 20
  • Select "SubtractFromValue1"and in the properties window set Value to 1
  • Connect "LightSensor1" pin I2C Control to Arduino I2C In
  • Connect "LightSensor1" pin Out to "Limit1" pin In
  • Connect "Limit1" pin Out to "MapRange1" pin In
  • Connect "MapRange1" pin Out to "SubtractFromValue1" pin In
  • Connect "SubtractFromValue1" pin Out to Arduino digital pin 3 >> Analog (PWM)

Generate, Compile, and Upload the Arduino Code

2020-10-30_13-20-50.jpg

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.

Play

If you power the Arduino module the LED will start to shine if you cover the sensor so that it can detect darkness. /the LED will shine more if there is more darkness.

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