Average rainfall 2001-2016, global tropics

Map: Average rainfall 2001-2016, global tropics

Sensor Module

project: Ambient light sensor project

Introduction

There is a range of breakout boards with ambient light sensors available. This post lists some of the more common. They all work on the I2C bus interface.

Identify I2C address

Note that Arduino Nano boards do not have dedicated I2C connections points. Instead A4 is used for SDA (data) and A5 as SCL (clock). The I2C connection is SDA -> SDA and SCl -> SCL.

If you do not know the I2C address of your module, first wire the component and then follow the instructions in the post on I2C scenner.

BH1750

The BH1750 module is based on the older BH1750FVI component.

I2C adress: 0x23 (from I2C scenner. )

Breadboard wiring of the BH1750 ambient light sensor to an Arduino Nano board.
Direct wiring of the BH1750 ambient light sensor to an Arduino Nano board.

Without specific library

The sketch below is not using the BH1750.h or BH1750VFI.h libraries and explicitly calls the I2C address.

With library

In the example below, the library __ form Github/claws/BH1750 has been added.

With library (not tested) as outlined in this post.

#include <Wire.h>
#include <BH1750.h>

BH1750 lightMeter;

void setup(){
  Serial.begin(9600);
  lightMeter.begin();
  Serial.println("Running...");
}

void loop() {
  uint16_t lux = lightMeter.readLightLevel();
  Serial.print("Light: ");
  Serial.print(lux);
  Serial.println(" lx");
  delay(1000);
}
Sensor Module