Lux sensor arduino

Lux sensor arduino DEFAULT

Introduction: How to Measure LUX With Arduino

In this tutorial we will use the Adafruit TSL2561 sensor to measure LUX with Arduino.

The TSL2561 luminosity sensor is an advanced digital light sensor, ideal for use in a wide range of light situations. Compared to low cost CdS cells, this sensor is more precise, allowing for exact lux calculations and can be configured for different gain/timing ranges to detect light ranges from up to 0.1 - 40,000+ Lux on the fly.

The best part of this sensor is that it contains both infrared and full spectrum diodes! That means you can separately measure infrared, full-spectrum or human-visible light. Most sensors can only detect one or the other, which does not accurately represent what human eyes see (since we cannot perceive the IR light that is detected by most photo diodes)

So, let's get started!

Step 1: What You Will Need

For this tutorial you will need:

  • Arduino uno
  • Breadboard
  • Adafruit TSL2561 module
  • some breadboard cables
  • and a flashlight

Step 2: Breadboard Circuit Schematic

The connections are pretty easy, see the above image with the breadboard circuit schematic.

Step 3: The Code

Here's the code, embedded using Codebender!

Try downloading the Codebender plugin and clicking on the "Run on Arduino" button to program your Arduino board. And that's it, you've programmed your Arduino with this sketch!

Step 4: Serial Monitor- Testing

Press the connect button to start the serial communication.

Step 5: Well Done!

You have successfully completed one more "How to" tutorial and you learned how to use the Adafruit TSL2561 Luminosity sensor with Arduino.

I hope you liked this, let me know in the comments!

Be the First to Share

Did you make this project? Share it with us!

Recommendations

  • Space Contest

    Space Contest
  • Unusual Uses Contest

    Unusual Uses Contest
  • Robots Contest

    Robots Contest
Sours: https://www.instructables.com/How-to-Measure-LUX-With-Arduino/

DIY Light Lux Meter

DIY Light Lux Meter

How to make DIY Light Lux Meter using Arduino and BH1750 Ambient Light Sensor

  • 1,495 views
  • 0 comments
  • 0 respects

Components and supplies

Apps and online services

About this project

How to make DIY Light Lux Meter using Arduino and BH1750 Ambient Light Sensor

Code

Custom parts and enclosures

Components Details
How to make light (lux) meter using arduino and bh1750 ambient light sensor bkhxrapkyf

Schematics

Comments

Sours: https://create.arduino.cc/projecthub/embeddedlab786/diy-light-lux-meter-ad3a81
  1. Pig pixel art
  2. Niner rdo stem
  3. Mack truck steering problems
  4. Oracle get date

DIY Light (Lux) Meter using BH1750 sensor, Arduino and Nokia 5110

Introduction

Hi guys, continuing on our recent path of building really cool stuffs based on the Nokia 5110 LCD display, today we will be building a DIY Lux (or light) meter using the highly sensitive BH1750 light sensor.

Illuminance (measured in LUX) is the total luminous flux incident on a surface, per unit area. It is a measure of how much the incident light illuminates the surface, it is wavelength-weighted by the luminosity function to correlate with the level of human brightness perception.

Lux is a measurement of the overall intensity of light within an environment for any given area or distance from the source or lux is the amount of light in an environment perceived by the human eye. The Lux meter is thus, a device used to measure the light intensity within an environment and its exactly what we will be building during this tutorial.

Below is a picture of the device taking outdoor readings on a bright morning.

The BH1750 sensor is a digital Light Sensor capable of measuring light intensity with a great degree of accuracy and over a large range. It communicates with microcontrollers or processors to which it is connected via the I2C bus interface. This module is the most suitable to obtain the ambient light data and it is commonly used for adjusting LCD and Keypad backlight power of Mobile phones.

Some of the features of this sensor include;

  1. I2C bus Interface ( f / s Mode Support )
  2. Spectral responsibility is approximately human eye response
  3. Illuminance to Digital Converter
  4. Wide range and High resolution. ( 1 – 65535 lx )
  5. Low Current by power down function
  6. 50Hz / 60Hz Light noise reject-function
  7. It is possible to select 2 type of I2C slave-address.
  8. Adjustable measurement result for influence of optical window ( It is possible to detect min. 0.11 lx, max. 100000 lx by using this function. )
  9.  Small measurement variation (+/- 20%)

Required Components

The following components are needed to build this project;

  1. Arduino Uno
  2. BH1750 
  3. Nokia 5110 LCD
  4. Breadboard
  5. wires

Schematics

Connect all components as shown in the Fritzing schematics below;

The BH1750 light intensity sensor module has a 16-bit analog to digital converter built-in that can directly output a digital signal over I2C communication protocol, thus the device is connected to the Arduino I2C pins which are located on analog pin 4(SDA) and 5(SCL). The connection is further detailed below.

BH1750 – Arduino

vcc - 5v GND - GND SCL - A5 SDA - A4

For the Nokia 5110 LCD module, a detailed tutorial has been made before on how to use the module with the Arduino and can be found here. It will help you better understand how the Nokia 5110 connection with the Arduino works. For this project, however, the pin connection of the Nokia 5110 LCD to the Arduino (as shown in the schematics) is given below;

LCD – ARDUINO

Pin 1(RST) – D12 Pin 2(CE) – D11 Pin 3(DC) – D10 Pin 4(DIN) – D9 Pin 5(CLK) – D8 Pin 6(VCC) - VCC Pin 7(LIGHT) - GND Pin 8(GND) - GND

Double check your connections to be sure you got everything right before proceeding to the code.

Code

Like most of our projects, In order to easily program our arduino to work with the BH1750 light sensor, we need the BH1750 arduino library. For this tutorial we will be using the library which can be found here. Download the library, and install in your arduino IDE by unzipping and copying it to the arduino library folder.

Since we are using the Nokia 5110 LCD display, we will also need the library which can be downloaded from here and installed in the same way as the BH1750 library. To know more about the Nokia 5110 LCD, check out the tutorial on it which can be found above.

With our libraries all installed, we are ready to launch the Arduino IDE and get to work.

The code file for this project, attached in the zip file at the end of this tutorial, contains three files; the Arduino code, the hex file for the graphics displayed on the screen when the device is powered and the UI design for the display. A detailed tutorial on how to prepare graphics and load them on to the Nokia 5110 LCD is found here, It will be of immense help when it comes to understanding how to load graphics to the display.

The first thing we do in our code includes the libraries that we will be using, which are the BH1750 library, the Nokia 5110 LCD library and the Arduino Wire LIbrary which is needed for the I2C communication.

//Written by Nick Koumaris //info@educ8s.tv //educ8s.tv #include <LCD5110_Graph.h> #include <Wire.h> #include <BH1750.h>

Next we declare the pins to which the lcd is connected to, and also specify the font tupe and the name of the graphics and ui files.

LCD5110 lcd(8,9,10,12,11); extern unsigned char BigNumbers[]; extern uint8_t splash[]; extern uint8_t ui[];

Next, we create an object of BH1750 and also declare the string variable which will hole all the light information from the sensor.

BH1750 lightSensor; String light;

With this done, we are then ready to move to the setup function, the commands under this section seem quite easy to grab to me. I2C communication system is started, followed by initializing the LCD, font settings, and the display of the splash screen icon. The system waits for a couple of seconds before proceeding to the loop section to give the splash screen enough time on the display.

void setup() { lightSensor.begin(); lcd.InitLCD(); lcd.setFont(BigNumbers); lcd.clrScr(); lcd.drawBitmap(0, 0, splash, 84, 48); lcd.update(); delay(3000); }

With the setup function all done, we are now ready to proceed to the loop function.

The loop function is pretty basic. the first command initializes the string length setting it to 0. The next command reads the light intensity reading from the sensor then the screen is cleared, the UI uploaded to the screen and the sensor data is printed to the screen after conversion.
A delay is set to allow the function to take some time in between readings.

void loop() { int stringLength=0; uint16_t lux = lightSensor.readLightLevel(); light = String(lux); stringLength = light.length(); lcd.clrScr(); lcd.drawBitmap(0, 0, ui, 84, 48); printLight(stringLength); lcd.update(); delay(150); }

The Last block of code is the function which was used to print the string data.

void printLight(int length) { switch(length) { case 1: lcd.print(light,68,22); break; case 2: lcd.print(light,54,22); break; case 3: lcd.print(light,40,22); break; case 4: lcd.print(light,26,22); break; case 5: lcd.print(light,12,22); break; default: lcd.print(light,0,22); break; } }

The full code is available below and also in the attached zip file.

#include <LCD5110_Graph.h> #include <Wire.h> #include <BH1750.h> LCD5110 lcd(8,9,10,12,11); extern unsigned char BigNumbers[]; extern uint8_t splash[]; extern uint8_t ui[]; BH1750 lightSensor; String light; void setup() { lightSensor.begin(); lcd.InitLCD(); lcd.setFont(BigNumbers); lcd.clrScr(); lcd.drawBitmap(0, 0, splash, 84, 48); lcd.update(); delay(3000); } void loop() { int stringLength=0; uint16_t lux = lightSensor.readLightLevel(); light = String(lux); stringLength = light.length(); lcd.clrScr(); lcd.drawBitmap(0, 0, ui, 84, 48); printLight(stringLength); lcd.update(); delay(150); } void printLight(int length) { switch(length) { case 1: lcd.print(light,68,22); break; case 2: lcd.print(light,54,22); break; case 3: lcd.print(light,40,22); break; case 4: lcd.print(light,26,22); break; case 5: lcd.print(light,12,22); break; default: lcd.print(light,0,22); break; } }

Feel free to copy and paste in the Arduino IDE once setups like library installation etc are done.

Demo

Copy the code, paste in the Arduino IDE, and upload to your arduino board, you should get an output like the image below on your screen. Don’t forget to include the icon file in the Arduino sketch folder.

 

That’s it for this tutorial guys. As usual, let me know if you have any questions via the comments section.

The youtube video of this tutorial is available here.

Sours: https://www.electronics-lab.com/project/diy-light-lux-meter-using-bh1750-sensor-arduino-nokia-5110/
#322 12 Light Sensors Tested: Measuring Light with Microcontrollers (Arduino or ESP8266, ESP32)

Table of Contents

Overview

In this project, we will make a Light Meter or Lux Meter using BH1750 Ambient Light Sensor & Arduino & display the Illuminance value in 16×2 LCD Display. Using this sensor we can calculate the amount of light in lux units. This sensor has a wide range of applications & is most suitable to obtain the ambient light data for adjusting the LCD and Keypad backlight power of the Mobile phone.

Earlier, we made Illuminance Meter using TEMT6000 Ambient Light Sensorand measured the Light Intensity. But the TEMT6000 is an analog sensor and hence slight fluctuation in voltage parameter can significantly affect the lux value. Hence BH1750 along with Arduino is a better sensor for Light Sensor application project. You can also use BH1750 with ESP8266 or ESP32 Controllers.


Bill of Materials

The components required for this project are as follows. All the components can be easily purchased from Amazon.


BH1750 Ambient Light Sensor

BH1750

This is a BH1750 light intensity sensor breakout board that is a digital Ambient Light Sensor IC with an I2C bus interface. This IC is best suited to get the ambient light data in mobile phones to manipulate the screen brightness based on the environment lighting. This sensor can accurately measure the LUX value of light up to 65535. It consumes a very low amount of current & uses a photodiode to sense the light.

Working of BH1750 Ambient Light Sensor

The BH1750 can be easily interfaced with Arduino or any other microcontroller. The photodiode on BH1750 detects the light intensity, which is converted as a voltage output with the help of an integration OP-AMP.

The built-in ADC finally gives out the 16-bit digital data. The internal logic of BH1750 avoids the need for any complicated calculations, as it directly outputs meaningful digital data in Lux (Lx).

BH1750 Circuit & Construction

BH1750 works with a supply voltage of 2.4V to 3.6V. BH1750FVI is the main module of the sensor which requires 3.3V for working. So, a voltage regulator is used in the circuit. SDA and SCL are the pins used for I2C communication. 4.7kΩ of pullup resistors are used with these pins.

BH1750 Circuit

The address of the device depends on the logic state of the address pin. There is an onboard pull down on the address pin, so with no connection, it defaults to the low address (0x23). PCB jumper (J1) allows easy configuration of the address pin; if J1 is closed the address pin will be pulled high, and the address will be 0x5C. The address of the module can also be controlled over the input signal on the ADD pin, keeping the jumper(J1) open. The DVI pin has an RC delay on it, delaying it enough to allow a proper power-on reset. The I2C interface, address, and DVI pins are brought out on a breadboard compatible berg strip, which makes it easy to use with your Arduino or any other microcontroller.

Measurement Modes

BH1705 has 3 measurement modes corresponding to different sensitivity levels (0.5lx, 1lx, and 4lx). The H-Resolution Mode is recommended as it provides the best noise rejection. The output logic level of the IIC bus can be switched between 3V3 and 5V levels with the help of a PCB jumper(J2).

Finally, with the level conversion circuitry, 3V3 regulation, and the well-calibrated BH1705, this breakout board would make a good basis for a light meter projects, especially as they give an output in lux directly, with acceptable accuracy and with a response that looks to be a better match to that of the human eye.

Features & Specifications

• I2C bus Interface
• SCL Clock Frequency: 400kHz max
• Select between 2 types of I2C slave-address
• Photo diode with approximate human eye response
• Internal logic for ambient light calculation
• Digital Output data in Lux
• Wide range and High resolution. ( 1 – 65535 lx )
• Small measurement variation (+/- 20%)
• Fastest data output @ 16ms per reading
• Low Current Consumption by power down function
• 50Hz / 60Hz Light Noise reject-function
• Very little light source dependency
• Influence of infrared is very small
• Power supply voltage: 3V3~5V DC

Applications of BH1750

• Used in pulse sensors to measure the light intensity of the LED
• Cell phones contain BH1750 to adjust the brightness of the screen according to the external light conditions
• Used in vehicles to turn ON/OFF the headlights according to the darkness
• Control the turning ON/OFF of the automatic street lights
• Used to adjust the keyboard backlight in smartphones

To learn more about this sensor, you can go through the Sensor Datasheet: BH1750 Datasheet


Light (Lux) Meter using BH1750 Ambient Light Sensor & Arduino

Now let us interface the BH1750 Ambient Light Sensor with Arduino & make a Simple Light Meter. The connection diagram is given below.

The BH1750 works on the I2C protocol. So, connect its SCL & SDA pins to A5 & A4 of Arduino respectively. The Sensor VCC pin can be connected to a 3.3V or 5V Pin. Connect the GND pin to GND.

The 16X2 LCD pins 1,5,16 is connected to GND. The pin 2 & 15 is connected to 5V of Arduino. Similarly, the pin 4, 6, 11, 12, 13, 14 is connected to Arduino 12, 11, 5, 4, 3, 2 pins.


Project PCB Gerber File & PCB Ordering Online

If you don’t want to assemble the circuit on breadboard and you want PCB for the project, then here is the PCB for you. The PCB Board for the Light Meter is designed using EasyEDA online Circuit Schematics & PCB designing tool. The front side and back side of the PCB is given below.

The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from https://www.nextpcb.com/

Download Gerber File: Light Meter PCB

Now you can visit the NextPCB official website by clicking here: https://www.nextpcb.com/. So you will be directed to NextPCB website.

You can now upload the Gerber File to the Website and place an order. The PCB quality are clean and brilliant. That is why most of the people trust NextPCB for PCB & PCBA Services.


Source Code/Program

Before uploading the code to the Arduino Board, we need BH1750 Library added to the Library folder. Download the BH1750 Arduino library from the following link below.

BH1750 Library

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

#include <Wire.h>         // adds I2C library

#include <BH1750.h>       // adds BH1750 library file

#include<LiquidCrystal.h> // include LCD library function

 

LiquidCrystal lcd(12,11,5,4,3,2);       //RS, E, D4, D5, D6, D7

 

BH1750 lightMeter;

 

// Initialization of library functions and codes

voidsetup()

{

 

  Serial.begin(9600);         // set serial buad rate of 9600

  Wire.begin();               // Enable I2C pins of Arduino

  lcd.begin(16,2);           // Defines LCD size to 16x2

  lcd.print("Illuminance");   //Print "Intensity in LUX" message on first line LCD    

  lightMeter.begin();

  delay(2000);

 

}

 

voidloop()

{

  floatlux=lightMeter.readLightLevel();

  lcd.setCursor(0,1);

  lcd.print(lux);

  lcd.print(" lx");

  delay(1000);

 

}


Testing BH1750 Sensor

Once the code is uploaded, the LCD will start displaying the light intensity in Lux. You can bring the Torchlight or Mobile phone light in front of the sensor to read the Illuminance value. Or you can take the device outside the room to measure the sunshine value in lux.

Light Meter Arduino

Sours: https://how2electronics.com/lux-meter-using-bh1750-ambient-light-sensor-arduino/

Sensor arduino lux

How to make a Luxmeter with Arduino and BH1750 Module © GPL3+

In the area of electrical projects, there is a specific area that develops lighting projects. This area is called Luminotécnica.

Once the lighting is dimensioned, it is necessary to execute the project and then carry out the luminosity measurement to check if it meets the criteria established in the lighting project.

To perform this measurement, a device called Luximetro is used.

Therefore, in this article, you will learn how to develop a Luximetro using the BH 1750 light sensor with the Arduino Nano and a 16x2 LCD display.

Therefore, through this article you will learn:

  • 1 - Perform the circuit assembly on the protoboard;
  • 2 - Understand how the BH1750 sensor works;
  • 3 - Perform the communication of the Arduino Nano / Arduino Nano the BH1750 light sensor;
  • 4 - Display of measured values on the LCD display;
  • 5 - Develop your NEXTPCB Printed Circuit Board.

The project will be developed in partner with NEXTPCB and you can access the printed circuit board files and earn 10 FREE PCBs through the link: NEXTPCB Printed Circuit Board.

Now, we will start the complete presentation of the development of the Luximetro project with BH1750 sensor.

Developing the Luximetro Project with the BH 1750 Sensor

As previously mentioned, the project consists of creating a system to perform the luminosity measurement using the BH1750 luminosity sensor.

The BH1750 I2C Brightness Sensor

With the BH1750 light sensor, it is possible to measure the light intensity in the range from 1 to 65, 535 Lux.

This sensor has I2C communication, which facilitates communication with microcontrollers, since it uses only 2 pins, an SDA data pin (serial data) and SCL clock pin (serial clock line), in addition to the VCC and GND power pins.

I2C communication uses the concept of master/slave, in which the microcontroller is the master and the peripherals as sensors, displays are the slaves.

The microcontroller is responsible for sending the clock signal to the I2C bus so that data is sent by the peripheral.

The SDA pin is a pin that has bidirectional communication, because sometimes it sends information, sometimes it can receive information.

The advantage of using I2C communication is that it is possible to connect several devices on a single bus to read and send information, each device occupies a different address on the I2C bus.

The sensor its the following characteristics:

  • Power Supply of 3.3V ~ 5V;
  • Digital Output Signal;
  • Measuring range of 1 lux ~ 65535 lux

The sensor image is presented below.

In figure 2 we have the schematic circuit with the necessary connections for assembling the project.

After assembling the electronic circuit, we will program the Arduino Nano to communicate with the sensor and display the values on the LCD display.

Development of the Luxmeter Programming

To program the Arduino Nano to communicate with the BH1750 sensor, we will need the Wire.h library (performs I2C communication) and the BH1750 library.

The BH1750 library can be downloaded through the Arduino IDE, in Sketch and added libraries.

The Wire library comes with the Arduino IDE by default, we will need to add the BH1750 library responsible for communicating the sensor with the Arduino Nano.

Inclusion of the Wire, BH1750, and LiquidCrystal_I2C libraries, libraries responsible for carrying out I2C communication with I2C devices, and libraries that have specific functions to communicate with the BH1750 sensor (BH1750) and to write on the 16 x 2 LCD display (LiquidCrystal_I2C).

After defining the objects of the LCD display and the BH1750 sensor, we go to the void setup function.

In this function, the I2C bus, sensor, and display are initialized, configure the Arduino serial communication speed

Configure the display model with 16 columns and 2 lines, write the message on the display.

Now, let's go to the void loop function.

In the void loop function, we read the sensor and display the measured values on the LCD display.

With the functioning sensor.readLightLevel () we read the BH1750 sensor and store it in the lux variable.

After programming the Arduino Nano, we can view the measurements shown on the display as shown in figure 3.

Now, you'll learn how to create a NEXTPCB printed circuit board for this project.

This printed Circuit Board was developed from of electronic schematic presented below.

After this, was developed a layout of the Printed Circuit Board. Finally, we'll develop an enclosure to put a printed circuit board, install the sensor, and buttons for future new projects.

Developing an enclosure for the Project

An enclosure was developed to put the circuit. You can use a laser cutting machine to cut your plywood and assembly your project through screws.

You can use a screw of M2.5 with a length of 12 mm. Below is presented the enclosure in 3D View.

Next, you can access the structure of the enclosure in a laser-cut file. Below are present each part of the project of an enclosure.

The file presented above is available in PDF file in this project.

With the parts you assembly and run your project.

Acknowlegment

We appreciate the support of NEXTPCB for supporting, developing and offering 10 free units to all readers of this article through the link: Obtain NEXTPCB Printed Circuit Board.

We would also like to thank the Robô Lúdico School in Brazil.

Sours: https://create.arduino.cc/projecthub/moreiranextpcb/how-to-make-a-luxmeter-with-arduino-and-bh1750-module-4959fc
how to use LDR as a sensor ( Light intensity sensor with arduino tutorial )

Arduino DIY Light Meter With BH1750 Sensor © GPL3+

In this tutorial I am going to show you how to build a Light meter with a big Nokia 5110 LCD display using Arduino.

Building a Light Meter is a great learning experience. When you finish building this project you will have a better understanding of how light meters work and you are going to see in action how powerful the Arduino platform can be. With this project as a base and the experience gained, you will be able to easily build more complex projects in the future. You can use this project to monitor the lighting conditions of your work enviroment, of your plants and so on. Without any further delay, let's get started!

Step 1: Get All the Parts

The parts needed in order to build this project are these:

The cost of the project is around $12.

Step 2: The BH1750 Light Sensor

The BH1750 light intensity sensor is great and very easy sensor to use. This breakout board comes with a 16 bit AD converter built-in which can directly output a digital signal, there is no need for complicated calculations.

This board is better than an LDR which only outputs a voltage. With the BH1750 Light Sensor intensity can be directly measured by the luxmeter, without needing to make calculations. The data which is output by this sensor is directly output in Lux (Lx).

The sensor uses the I2C interface so it is very easy to use with Arduino. You only need to connect 2 wires.

Also the price of the sensor is very low, it is around 2$.

You can get it here: ▶ http://bit.ly/BH1750_Sensor

Step 3: Nokia 5110 LCD

The Nokia 5110 is my favorite display for my Arduino Projects.

The Nokia 5110 is a basic graphic LCD screen which was originally intended for as a cell phone screen. It uses the PCD8544 controller which is a low power CMOS LCD controller/driver. Because of this this display has an impressive power consumption. It uses only 0.4mA when it is on but the backlight is disable. It uses less than 0.06mA when in sleep mode! That's one of the reasons that make this display my favorite. The PCD8544 interfaces to microcontrollers through a serial bus interface. That makes the display very easy to use with Arduino.

You only need to connect 8 wires and use the following library: http://www.rinkydinkelectronics.com/library.php?i...

This impressive library is developed by Henning Karlsen who has put a huge amount of effort to help the Arduino community move forward with his libraries.

I have prepared a detailed tutorial on how to use the Nokia 5110 LCD display with Arduino. I have attached that video in this tutorial, it will provide may useful information about the display, so I encourage you to watch it carefully.

The cost of the display is around $4.

You can get it here: ▶ http://bit.ly/NOKIA5110

Step 4: Building the Light Meter

Let's now connect all the parts together.

At first we connect the BH1750 Light sensor module. It only has 5 pins but we will connect 4 of them.

Connecting the Voltage Sensor

  • Vcc Pin goes to Arduino's 5V
  • GND Pin goes to Arduino's GND
  • SCL Pin goes to Analog Pin 5 of the Arduino Uno
  • SDA Pin goes to Analog Pin 4 of the Arduino Uno
  • Address pin stay unconnected

The next step is to connect the Nokia 5110 LCD display.

Connecting the Nokia 5110 LCD Display

  • RST goes to Digital Pin 12 of the Arduino
  • CE goes to Digital Pin 11 of the Arduino
  • DC goes to Digital Pin 10 of the Arduino
  • DIN goes to Digital Pin 9 of the Arduino
  • CLK goes to Digital Pin 8 of the Arduino
  • VCC goes to Arduino 3.3V LIGHT goes to Arduino GND (backlight on)

Now that we have connected all the parts together, all we have to do is to load the code. A Splash screen is displayed for a couple of seconds and then we can start measuring Light Intensity in Real Time!

Step 5: The Code of the Project

The code of the project consists of 3 files.

Code - Splash Screen Image

In the first file splash.c, there are the binary values of the splash screen that is displayed on the Nokia 5110 LCD display when the project boots up. Please watch the attached video I have prepared in order to see how to load your custom graphics to your Arduino Project.

ui.c Code - The User Interface

In the file ui.c, there are the binary values of user interface that appears after the the project shows the splash screen. Please watch the attached video I have prepared in order to see how to load your custom graphics to your Arduino Project.

UVMeter.ino Code - Main Program

The main code of the project is very simple. We need to include the Nokia 5110 library. Next we declare some variables. We initialize the display and we display the splash screen for 3 seconds. After that, we print the ui icon once, and we read the value from the sensor 150 milisseconds. All the magic happens in the loop function:

I have attached the code to this tutorial. In order to download the latest version of the code you can visit the project's webpage: http://educ8s.tv/arduino-light-meter/

Step 6: Testing the Project

Now that the code is loaded we can test the Light Meter indoors and outdoors. I test it in a sunny spring day here in Greece. The result if fantastic. We can accurately measure the light intensity with easy to build project.

As you can see in the attached photos, the Light Meter works fine. This project is a great demonstration of what open source hardware and software is capable of. Within a few minutes one can build such an impressive project! This project is ideal for beginners and as I said in the beginning, this project is a great learning experience. I would love to hear your opinion on this project. Do you find it useful? Are there any improvements that can be implemented to this project? Please post your comments or ideas in the comments section below!

Sours: https://create.arduino.cc/projecthub/nickthegreek82/arduino-diy-light-meter-with-bh1750-sensor-038d2e

You will also be interested:

Arduino - Light Sensor

The light sensor used in this tutorial is a photoresistor, which is also called light-dependent resistor or photocell.

It is used not only to detect light but also to measure the brightness/illuminance level of the ambient light.

A photoresistor has two pins. Since it is a kind of resistor, we do NOT need to distinguish these pins. They are symmetric.

Light Sensor Pinout

The more light the photoresistor's face is exposed, the smaller its resistance is. Therefore, by measuring the photoresistor's resistance, we can know how bright the ambient light is.

How Light Sensor Works

WARNING

The light sensor value only reflects the approximated trend of the intensity of light, it does NOT represent the exact luminous flux. Therefore, it should be used only in an application that does NOT require high accuracy.

Arduino Uno's pin A0 to A5 can work as the analog input. The analog input pin converts the voltage (between 0v and VCC) into integer values (between 0 and 1023), called ADC value or analog value.

By connecting a pin of the photoresistor to an analog input pin, we can read the analog value from the pin by using analogRead() function, and then we can know the light levels relatively.

Arduino Light Sensor Wiring Diagram

Image is developed using Fritzing. Click to enlarge image

The below code reads the value from photocell and determine the light level qualitatively

voidsetup() {Serial.begin(9600);}voidloop() {int analogValue = analogRead(A0);Serial.print("Analog reading = ");Serial.print(analogValue); if (analogValue < 10) {Serial.println(" - Dark"); } elseif (analogValue < 200) {Serial.println(" - Dim"); } elseif (analogValue < 500) {Serial.println(" - Light"); } elseif (analogValue < 800) {Serial.println(" - Bright"); } else {Serial.println(" - Very bright"); }delay(500);}

  • Copy the above code and open with Arduino IDE

  • Click Upload button on Arduino IDE to upload code to Arduino

  • Open Serial Monitor

  • Radiates light to sensor

  • See the result on Serial Monitor:

  • - Dim - Dim - Dim - Dim - Very bright - Very bright - Very bright

The below code turns ON the LED when it is dark, otherwise turns OFF the LED

voidsetup() {Serial.begin(9600);}voidloop() {int analogValue = analogRead(A0);Serial.print("Analog reading = ");Serial.print(analogValue); if (analogValue < 10) {Serial.println(" - Dark"); } elseif (analogValue < 200) {Serial.println(" - Dim"); } elseif (analogValue < 500) {Serial.println(" - Light"); } elseif (analogValue < 800) {Serial.println(" - Bright"); } else {Serial.println(" - Very bright"); }delay(500);}

We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.

  • Automatically turn on the light when your room is dark. Hint: Refer to Arduino - Relay.

The above code also works with the following light sensors:

※ OUR MESSAGES

Follow Us

Share with your friends to help us spread the tutorial!

Sours: https://arduinogetstarted.com/tutorials/arduino-light-sensor


1531 1532 1533 1534 1535