Zonnestroompanelen in Nederland

duurzaamheid achter de meter

(5) The BH1750 photometric light sensor: Arduino application

by Floris Wouterlood – the Netherlands –

Introduction
The amount of light available in the environment is important. We take it for granted, and when there is too little light we switch the electric light on. Light can even be of economical importance: think about solar panels that convert the energy carried by sunlight into electricity that can be used to power lights, machines and appliances. ‘Light’ as we, humans, see it with our eyes, is radiation emanated by the sun and reflected by objects around us. In physical terms we speak of a band in the electromagnetic spectrum between wavelengths 450 nanometer (blue light) and 600 nanometer (deep red). The cones and rods in our retina do not detect ultraviolet light (UV; wavelength shorter than 450 nanometer) nor infrared light (IR; wavelength longer than 600 nanometer) and beyond UV and IR. High-performance solar panels absorb all the available visible light and do not reflect much. The consequence of this behavior is that such solar panels appear to our eyes as ‘black’. A ‘black hole’ sucks up everything, including radiation, and for that matter appears pitch black by nature.
On the market are sensors that detect illuminance in approximately the same wavelength band as our eyes do. This type of light detection is commonly called ‘photometry’. One of the available photometric sensors is the BH1750. They are used, among others, in mobile phones, LCD TV’s digital cameras and the like where they measure ambient light to provide input to system software that adjusts screen illumination. For the Arduino, BH1750s can be bought mounted on a I2C breakout board (Fig.1, left panel).
On such a breakout board a light sensitive chip is mounted (indicated with the yellow arrow) equipped with a minuscule photodiode. An analog-to-digital chip and a I2C logic interface complete the breakout board. The board has five pins: Vcc (power supply; 3.3V), GND, SCL, SDA and ADDR. The ADDR pin is used only when multiple BH1750s are wired to an Arduino. As I applied one BH1750 in the current project this pin was left unconnected.

Figure 1: Left panel: enlarged picture of the BH1750 breakout board (actual dimensions 12×10 mm). Middle panel: the breakout board soldered on a 50×70 mm PCB that is mounted on a support of Meccano strips. On top of the sensor a grey filter reduces incoming light to values within the dynamic range of the sensor. Right panel: complete assembly, ready for use.

Because the BH1750 breakout board uses the I2C protocol the wiring is very easy. Vcc is connected with the 3.3V pin of the Arduino (note that all I2C sensors are 3.3V devices), GND goes to GND, while the SDA and SCL pins are connected to pins A4 and A5 of the Arduino, respectively (Fig. 2). Pull-up resistors with a value of 4.7 kΩ may be placed between SCL and 3.3V and between SDA and 3.3V (necessary only when multiple I2C devices are connected to the Arduino board). That is all, and the sensor is ready for use.

Because I wanted to measure sunlight under approximately the same angle as it hits my solar panels I mounted the BH1750 breakout board on a 50×70 mm soldering board and supported this assembly with a construction made out of Meccano strips to provide a stable platform (center frame, Fig. 1). I had to add an old grey filter of my photo camera to reduce the amount of incoming light. The final assembly of breakout board, soldering board, filter and Mecca no support is shown in the right panel of Figure 1. It is mounted behind a glass window, and its faces south-east. Location is in Leiden, The Netherlands: approximately 52 degrees north and 4 degrees east.

Electronic components needed
1x BH1750 sensor, 1x Arduino Uno or Nano, 2x 4.7 kΩ resistor, breadboard, jumper wires.

Wiring

Figure 2: Wiring a BH1750 to an Arduino Nano is quite simple: SDA is connected to pin A4 and SCL to pin A5 . 4.7 kΩ pull up resistors are necessary only when multiple I2C devices are wired to one Arduino. Note that I2C communication is stable when the distance between the sensor and the Arduino is short. The BH1750 is shown enlarged here compared with the Nano.

Sketch

Here is a bare sketch found on the Domotix website

// basic BH1750_sketch
// found at Domotix – http://domoticx.com/arduino-lichtintensiteit-sensor-bh1750-gy-302/

#include <Wire.h> //BH1750 IIC Mode
#include <math.h>

int BH1750_Device = 0x23; // I2C address for light sensor
unsigned int Lux, Scaled_FtCd;
float FtCd, Wattsm2;

void setup() {
Wire.begin();
Serial.begin (9600);

Wire.beginTransmission (BH1750_Device);
Wire.write(0x10); // Set resolution to 1 Lux
Wire.endTransmission ();

delay(200);
}

void loop () {
int i;
Lux = BH1750_Read();
FtCd = Lux/10.764;
Wattsm2 = Lux/683.0;
Serial.print (Lux,DEC);
Serial.println (“[lx]”);
Serial.print (FtCd,2);
Serial.println (“[FC]”);
Serial.print (Wattsm2,4);
Serial.println(“[Watts/m^2]”);
delay (1000);
}

unsigned int BH1750_Read() {
unsigned int i=0;
Wire.beginTransmission (BH1750_Device);
Wire.requestFrom (BH1750_Device, 2);
while (Wire.available())
{
i <<=8;
i|= Wire.read();
}
Wire.endTransmission();
return i/1.2; // Convert to Lux
}

Results

The primary output of the sensor is in Lux. Lux is expressed in lumen per square meter. Lumen is the measure for luminous energy per unit of time. If you divide the luminous energy by 683.0 an approximation is obtained of the amount of energy (expressed in Watts) per surface unit (square meter). This is an approximation as well because it holds only for light with a wavelength of 555 nm. Yet the W/m2 unit it is a valuable unit because the goal of the current project is to compare general illuminance seen by the human eye on the one hand with the output of my solar panels. The latter produce a certain amount of Watts for each square meter of panel surface, depending of the amount of sunshine they receive.

In this bare sketch, output is to Serial Monitor. When a logging shield is added to the Arduino, a log file can be generated wherein the measurements are listed per time unit. One of the log files is graphically presented in Figure 3. I took the August 28, 2017 log file because that day was one of the rare days in the Low Countries that the sun was shining all day, uninterrupted by clouds. In the morning the illumination values were ramping up, reached a maximum around 12:30 (sample point #178), and in the afternoon they decreased, exactly as experienced by the human eye.

Figure 3. Plot of a 24 h logging period (one sample every 5 minutes) with the BH1750 light intensity sensor. Note that the Y-axis values are proportional to each other, yet these numbers are no absolute light flux numbers because of the lack of calibration..

With such a nice photometric graph it is exciting to compare the data from the BH1750 with the production, on the same day, of my solar panels. This is done in Figure 4 by combining the log file of the BH1750 measurements (dark blue graph) and the log file of the production of the solar panels (pink graph). These are quite different entities that are compared: the BH1750 data are momentous readings of a sensor that receives sunlight through a glass window and a grey filter, while the solar panel production is the accumulated output of the solar inverters measured by a kWh meter over periods of 5 minutes. Furthermore the solar panel logging covers all solar panels, that is also panels that are oriented in a different direction than south-east. This is expressed by the slower ramping down in the afternoon. Because of its position the BH1720 does not receive direct sunlight any more after, say, 15:00 pm while the solar panels directed towards west continue production until sunset.

igure 4. Plot of a 24 h photometric logging period (pink) in overlay with the solar panels production curve on the same day (August 28, 2017; one sample every 5 minutes). The graphs have been slightly manipulated in the Y diirection to provide nice overlap.

Conclusion
The BH1720 is a sensor that is easy to implement in the Arduino environment. It measures light approximately the same way as the human eye does. For that matter this sensor can be used as a nice, yet qualitative indicator for the amount of light available, in my case sunshine, the feedstock for my solar panels.