Skip to content

Commit 2094220

Browse files
azoguefabaff
authored andcommitted
add BH1750 light sensor platform doc (home-assistant#2821)
* add BH1750 light sensor platform doc * don't repeat errors! * review fixes * add `multiplier` parameter
1 parent 3881bff commit 2094220

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
layout: page
3+
title: "BH1750 Light sensor"
4+
description: "Instructions how to integrate a BH1750 light sensor in a Raspberry PI into Home Assistant."
5+
date: 2017-06-10 00:00
6+
sidebar: true
7+
comments: false
8+
sharing: true
9+
footer: true
10+
logo: raspberry-pi.png
11+
ha_category: Sensor
12+
ha_release: 0.47
13+
ha_iot_class: "Local Push"
14+
---
15+
16+
17+
The `bh1750` sensor platform allows you to read the ambient light level in lux from a [BH1750FVI sensor](http://cpre.kmutnb.ac.th/esl/learning/bh1750-light-sensor/bh1750fvi-e_datasheet.pdf) connected via [I2c](https://en.wikipedia.org/wiki/I²C) bus (SDA, SCL pins) to your [Raspberry Pi](https://www.raspberrypi.org/). It allows you to use all the resolution modes of the sensor described in its datasheet.
18+
19+
To use your BH1750 sensor in your installation, add the following to your `configuration.yaml` file:
20+
21+
```yaml
22+
# Example configuration.yaml entry
23+
sensor:
24+
- platform: BH1750
25+
```
26+
27+
Or, if you want to specify the resolution mode of the digital sensor or need to change the default I2c address (which is 0x23), add more details to the yaml config.
28+
29+
The sensor can work with resolutions of 0.5 lx (high res mode 1), 1 lx (high res mode 2) or 4 lx (low res mode), and make measurements continuously or one time each call. To set any of these operation modes, select one of these combinations: `continuous_low_res_mode`, `continuous_high_res_mode_2`, `continuous_high_res_mode_1`, `one_time_high_res_mode_1`, `one_time_high_res_mode_2`, `one_time_low_res_mode`.
30+
31+
```yaml
32+
# Example of customized configuration.yaml entry
33+
sensor:
34+
- platform: bh1750
35+
name: Ambient light
36+
i2c_address: 0x5C
37+
operation_mode: one_time_high_res_mode_1
38+
measurement_delay_ms: 200
39+
scan_interval: 25
40+
```
41+
42+
Configuration variables:
43+
44+
- **name** (*Optional*): The name of the sensor
45+
- **i2c_address** (*Optional*): I2c address of the sensor. It is 0x23 or 0x5C.
46+
- **i2c_bus** (*Optional*): I2c bus where the sensor is. Defaults to 1, for Raspberry Pi 2 and 3.
47+
- **operation_mode** (*Optional*): Working mode for the sensor. Defaults to `continuous_high_res_mode_1` for continuous measurement and 1 lx resolution.
48+
- **measurement_delay_ms** (*Optional*): Delay time in ms for waiting the sensor to get the measure. Defaults to 120 ms.
49+
- **multiplier** (*Optional*): Correction coefficient to multiply the measured light level. Value between 0.1 and 10. Default is 1.
50+
51+
52+
### Directions for installing smbus support on Raspberry Pi:
53+
54+
Enable I2c interface with the Raspberry Pi config utility:
55+
```bash
56+
# pi user environment: Enable i2c interface
57+
sudo raspi-config
58+
```
59+
Select `Interfacing options->I2C` choose `<Yes>` and hit `Enter`, then go to `Finish` and you'll be prompted to reboot.
60+
61+
Install dependencies for use the `smbus-cffi` module and enable your _homeassistant_ user to join the _i2c_ group:
62+
```bash
63+
# pi user environment: Install i2c dependencies and utilities
64+
sudo apt-get install build-essential libi2c-dev i2c-tools python-dev libffi-dev
65+
66+
# pi user environment: Add homeassistant user to the i2c group
67+
sudo addgroup homeassistant i2c
68+
69+
# pi user environment: Reboot Raspberry Pi to apply changes
70+
sudo reboot
71+
```
72+
73+
###### Check the i2c address of the sensor
74+
75+
After installing `i2c-tools`, a new utility is available to scan the addresses of the connected sensors:
76+
77+
```bash
78+
/usr/sbin/i2cdetect -y 1
79+
```
80+
81+
It will output a table like this:
82+
83+
```text
84+
0 1 2 3 4 5 6 7 8 9 a b c d e f
85+
00: -- -- -- -- -- -- -- -- -- -- -- -- --
86+
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
87+
20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- --
88+
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
89+
40: 40 -- -- -- -- -- UU -- -- -- -- -- -- -- -- --
90+
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
91+
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
92+
70: -- -- -- -- -- -- -- 77
93+
```
94+
95+
So you can see the sensor address what you are looking for is **0x23** (there are more i2c sensors in that Raspberry Pi).

0 commit comments

Comments
 (0)