Difference between revisions of "BH1750"

From Let's Control It
Jump to navigation Jump to search
 
Line 1: Line 1:
 
= Introduction =
 
= Introduction =
The ESP module can read a BH1750 Lux sensor using the I2C protocol.
 
  
The BH1750 sensor needs to be connected to a the I2C pins on the ESP module. These pins can be configured on the hardware tab.
+
[[File:BH1750 2.jpg|500px]]
  
== Hardware ==
+
The BH1750 Sensor is a luminosity sensor. It's spectral sensivity approximately meets the human eye sensivity.
[[File:BH1750.jpg|320px]]
+
The sensor supports different resolutions. The settings with ESPEasy offer the possibility to
 +
set resolution to your needs.
 +
It is connected to the ESP via I²C so connecting even with several sensors and a display is easy to do.
 +
The sensor gives relative humidity and temperature as digital values.
  
The BH1750 sensor can be connected directly to an ESP module by using the two pins SDA and SCL.
+
= Precautions =
  
[http://image.dfrobot.com/image/data/SEN0097/BH1750FVI.pdf[Datasheet]]
+
The BH1750 runs well on 3,3V so no level shifter or special power supply is needed.
  
= Software =
+
The bare circuit is very small and difficult to handle and solder.
 +
Usually you will use a breakout board from the market that is much easier to handle.
  
== Custom Sketch ==
+
= Hardware =
  
== ESP Easy ==
+
Connecting the BH1750 is easy.
Use the device tab on the ESP Easy webinterface and create a new task by editing one of the available tasks. Select "BH1750 Lux Sensor" from the dropdown box.
+
Just connect it as shown in the schematic:
  
[[File:EasyConfigLUX.png]]
+
  BH1750 ESP
 +
  GND GND
 +
  VCC 3,3V
 +
  SCL D1(GPIO5)
 +
  SDA D2(GPIO4)
 +
  ADDR not connected. (For default address)
  
Enter the IDX found in the Domoticz device page. That should be all.
+
[[File:BH1750-Schematic.jpg|500px]]
  
=== Optional settings ===
+
[[File:BH1750-Breadboard Example.jpg|500px]]
  
[[ EasyFormula | Use of formulas]]
+
If you're connecting several devices to I²C and/or using longer cabling please see
 +
the "Basics: The I²C Bus" wiki for further informations. [link]
  
[[ EasyValueNames | Use of value names]]
+
= ESPEasy =
  
== ESP Connexio ==
+
First check if the BH1750 show up:
Syntax: LUXRead "var"
+
 
 +
Go to the "Advanced" Tab and click "I³C Scan"
 +
It should show this result:
 +
 
 +
[[File:BH1750 Scan-Result.jpg|400px]]
 +
 
 +
 
 +
Set up the ESPEasy task according to the screenshot.
 +
 
 +
 
 +
[[File:BH1750 Setiings.jpg|500px]]
 +
 
 +
 
 +
==Additional Settings===
 +
You may set the resolution to your needs.
 +
Lower resolution works faster with less accuracy.
 +
The "RESOLUTION_AUTO_HIGH" setting gives a reasonable compromise
 +
for usual purposes.
 +
 
 +
After some seconds the tasklist will show like this:
 +
 
 +
[[File:BH1750 Device-List.jpg|500px]]
 +
 
 +
If it shows all values as zero, don't worry.
 +
Wait a minute and refresh the browser page.
 +
 
 +
 
 +
=Calibrating=
 +
 
 +
See "Basics: Calibrating" for further information [link]
 +
 
 +
=Troubleshooting=
 +
 
 +
==Your BH1750 does not show up at I²C-scan==
 +
Usually this failure results of cabling faults.
 +
If your device does not show up, SCL and SCA might be swapped or
 +
the module does not get power or ground.
 +
If you are testing on a breadboard, the breadboard contacts might be
 +
worn out or you got some faulty cables.
 +
A digital multimeter will help with this situations.
 +
 
 +
== Your BH1750 shows all values zero==
 +
 
 +
The I²C-scan showed your BH1750 but  after submitting and returning to the task list
 +
all values are zero.
 +
First, wait a minute and then refresh the page. Depending on the "Delay" value
 +
in the settings it might take some seconds until the first measurement takes place.
 +
If that does not help, switch the ESP completely off and back on after some seconds.
 +
 
 +
== Your BH1750 shows deviating values ==
 +
This might have several reasons.
 +
 
 +
These sensors all have their own tolerances.
 +
On top the analog to digital conversion produces a deviation of
 +
about +/- 1...2 digits.
 +
 
 +
It is possible to calibrate sensors using a formula
 +
See "Basics: Calibrating" for further information [link]
 +
 
 +
Last but not least problems with the power supply are quite usual.
 +
See "Basics: Taming false positives" in the wiki for info about filtering power supply. {link]

Latest revision as of 17:45, 26 August 2017

Introduction

BH1750 2.jpg

The BH1750 Sensor is a luminosity sensor. It's spectral sensivity approximately meets the human eye sensivity. The sensor supports different resolutions. The settings with ESPEasy offer the possibility to set resolution to your needs. It is connected to the ESP via I²C so connecting even with several sensors and a display is easy to do. The sensor gives relative humidity and temperature as digital values.

Precautions

The BH1750 runs well on 3,3V so no level shifter or special power supply is needed.

The bare circuit is very small and difficult to handle and solder. Usually you will use a breakout board from the market that is much easier to handle.

Hardware

Connecting the BH1750 is easy. Just connect it as shown in the schematic:

  BH1750		ESP
  GND		GND
  VCC		3,3V
  SCL		D1(GPIO5)
  SDA		D2(GPIO4)
  ADDR		not connected. (For default address)

BH1750-Schematic.jpg

BH1750-Breadboard Example.jpg

If you're connecting several devices to I²C and/or using longer cabling please see the "Basics: The I²C Bus" wiki for further informations. [link]

ESPEasy

First check if the BH1750 show up:

Go to the "Advanced" Tab and click "I³C Scan" It should show this result:

BH1750 Scan-Result.jpg


Set up the ESPEasy task according to the screenshot.


BH1750 Setiings.jpg


Additional Settings=

You may set the resolution to your needs. Lower resolution works faster with less accuracy. The "RESOLUTION_AUTO_HIGH" setting gives a reasonable compromise for usual purposes.

After some seconds the tasklist will show like this:

BH1750 Device-List.jpg

If it shows all values as zero, don't worry. Wait a minute and refresh the browser page.


Calibrating

See "Basics: Calibrating" for further information [link]

Troubleshooting

Your BH1750 does not show up at I²C-scan

Usually this failure results of cabling faults. If your device does not show up, SCL and SCA might be swapped or the module does not get power or ground. If you are testing on a breadboard, the breadboard contacts might be worn out or you got some faulty cables. A digital multimeter will help with this situations.

Your BH1750 shows all values zero

The I²C-scan showed your BH1750 but after submitting and returning to the task list all values are zero. First, wait a minute and then refresh the page. Depending on the "Delay" value in the settings it might take some seconds until the first measurement takes place. If that does not help, switch the ESP completely off and back on after some seconds.

Your BH1750 shows deviating values

This might have several reasons.

These sensors all have their own tolerances. On top the analog to digital conversion produces a deviation of about +/- 1...2 digits.

It is possible to calibrate sensors using a formula See "Basics: Calibrating" for further information [link]

Last but not least problems with the power supply are quite usual. See "Basics: Taming false positives" in the wiki for info about filtering power supply. {link]