Molemi IoT
  • Space farming using food computers for sustainable farming
  • Introduction to Arduino
    • Introduction to Electronics
    • The Breadboard
  • Controlling LEDs with an Arduino
    • The Code
    • Adding a button to control the LEDs
      • The Code
  • Introducing Sensors
    • The CO2 and air quality sensor
    • The Code
      • Explaining the Code
    • Light Intensity Sensor
  • Introducing the NodeMCU
    • Getting Started
      • A simple test for ESP8266
        • The Code
    • A light bulb switch using NodeMCU and the Blynk app
      • Setup Blynk on your Smartphone
      • The Code
    • Controlling a Centurion gate Motor with NodeMCU a 2-channel relay
      • Installing Blynk in Arduino IDE
    • Read and display the water flow sensor on Blynk
      • Setting up Blynk
      • The Code
        • Explaining the code
    • Read and Display temperature sensor readings with NodeMCU.
      • Installing libraries for DS18B20 temperature sensor.
      • Displaying the sensor readings on the serial port
        • Getting temperature readings from different DS18B20 sensors.
          • The Code
            • Display sensor readings on a web server
              • Build the web server
                • Designing and building the web page
                • The Code
    • Display the DHT11 sensor reading on a web server using NodeMCU.
      • Monitoring Room Temp & Humidity using Blynk
      • Installing DHT library on the ESP8266
        • Installing the Asynchronous Web Server library
          • The Code
          • Designing and building the web page
  • Data Science for Farming
    • Getting Started with Colaboratory
    • Introduction to Python for DS using Colab
  • Machine Learning for Farming
  • Molemi Personal Food Computer
    • Bill of Materials
  • Setting up WaziGate on a Raspberry Pi
  • Setting up DHT11 on Raspberry Pi
  • Using Telegram To Control Outputs
Powered by GitBook
On this page

Was this helpful?

  1. Introducing Sensors

Light Intensity Sensor

in this activity we will be working with the BH1750FVI sensor module to measure the light intensity.

PreviousExplaining the CodeNextIntroducing the NodeMCU

Last updated 5 years ago

Was this helpful?

BH1750FVI digital light intensity module is a digital light intensity sensor integrated circuit used for two-wire serial bus interface. It uses the light intensity data collected by module to adjust the brightness of LCD and keyboard backlight. The module resolution can detect a wide range of light intensity changes.

Objectives:

  • Setup the circuit to allow the Arduino Uno to communicate with the BH1750FVI sensor.

  • Setup the Arduino IDE to be able to upload the code to the Arduino IDE.

  • Write the code to be able to serial print the light intensity readings.

Setup the Circuit:

  1. Connect the GND pin of the sensor to the GND pin of the Arduino Uno.

  2. Connect the V pin of the sensor to the 5v PIN of the Uno.

  3. Connect the SDA pin of the sensor to the analog pin (A4) of the Uno.

  4. Connect the SCL pin of the sensor to the analog pin (A5) of the Uno.

Configuring the Arduino IDE

  • Open the Arduino IDE on your desktop/laptop computer and open Sketch > Include Library > Add .Zip Library.

The Code:

Include the following code to your Arduino IDE:

//
  /*
 Measurement of illuminance using the BH1750FVI sensor module
 Connection:
  Module      UNO
G <----->   GND
V  <----->  5V
SDA  <----->  A4
  SCL  <----->  A5
   */
#include <Wire.h>

#define ADDRESS_BH1750FVI 0x23    //ADDR="L" for this module
#define ONE_TIME_H_RESOLUTION_MODE 0x20
//One Time H-Resolution Mode:
//Resolution = 1 lux
//Measurement time (max.) = 180ms
//Power down after each measurement
 byte highByte = 0;
 byte lowByte = 0;
 unsigned int sensorOut = 0;
 unsigned int illuminance = 0;

 void setup()
 {
     Wire.begin();
     Serial.begin(115200);
 }

 void loop()
 {
     Wire.beginTransmission(ADDRESS_BH1750FVI); //"notify" the matching device
     Wire.write(ONE_TIME_H_RESOLUTION_MODE);     //set operation mode
     Wire.endTransmission();

     delay(180);

     Wire.requestFrom(ADDRESS_BH1750FVI, 2); //ask Arduino to read back 2 bytes from the sensor
     highByte = Wire.read();  // get the high byte
     lowByte = Wire.read(); // get the low byte

     sensorOut = (highByte<<8)|lowByte;
     illuminance = sensorOut/1.2;
     Serial.print(illuminance);    Serial.println(" lux");

     delay(1000);

Download the following library that will be used with

BH1750FVI