BH1745 RGB Color Sensor
The bh1745 component allows you to use your BH1745 (BH1745NUC) RGB color sensor
(datasheet,
Pimoroni) with ESPHome.
It reports the red, green, blue and clear channel readings and calculates the illuminance and the
color temperature of the light.
The I²C Bus is required to be set up in your configuration for this sensor to work.
The component has three parts: a bh1745 hub that talks to the chip, a sensor platform for
the readings and an optional output platform that drives the chip’s INT pin.
# Example configuration entrybh1745:
sensor: - platform: bh1745 red_channel: name: "Red Channel" green_channel: name: "Green Channel" blue_channel: name: "Blue Channel" clear_channel: name: "Clear Channel" illuminance: name: "Illuminance" color_temperature: name: "Color Temperature"
output: - platform: bh1745 id: bh1745_outputConfiguration variables
Section titled “Configuration variables”-
id (Optional, ID): Manually specify the ID for this hub. Use this if you want to use more than one BH1745 sensor.
-
gain (Optional, string): The gain of the internal ADC. Higher values work better in low light. One of
1X,2Xor16X. Defaults to1X. -
integration_time (Optional, Time): How long the sensor collects light for each measurement. Longer times work better in low light. One of
160ms,320ms,640ms,1280ms,2560msor5120ms. Defaults to160ms. -
glass_attenuation_factor (Optional, float): Use this when the sensor sits behind glass or another cover that blocks some of the light. The illuminance is multiplied by this value to make up for the lost light:
1.0means all light passes through,2.0means half of it does. Must be at least1.0. Defaults to1.0. -
address (Optional, int): Manually specify the I²C address of the sensor. Defaults to
0x38. -
update_interval (Optional, Time): The interval to read the sensor. Defaults to
60s. -
All other options for I²C devices described at I²C Bus.
The sensor measures continuously. Each update reads the latest finished measurement, so an
update_interval shorter than the integration_time does not give fresher readings.
Sensor
Section titled “Sensor”Each configured sensor is reported on every update_interval of the hub.
Configuration variables
Section titled “Configuration variables”-
bh1745_id (Optional, ID): The ID of the
bh1745hub. Only needed when you have more than one hub. -
red_channel (Optional): Raw reading of the red color channel, in counts. All options from Sensor.
-
green_channel (Optional): Raw reading of the green color channel, in counts. All options from Sensor.
-
blue_channel (Optional): Raw reading of the blue color channel, in counts. All options from Sensor.
-
clear_channel (Optional): Raw reading of the clear channel (no color filter), in counts. All options from Sensor.
-
illuminance (Optional): Calculated illuminance, in lx. All options from Sensor.
-
color_temperature (Optional): Calculated color temperature of the light, in K. All options from Sensor.
Output
Section titled “Output”The Pimoroni breakout board has two white LEDs that light up the object in front of the sensor. They are
connected to the INT pin of the BH1745, so they can not be switched with a GPIO of your board. The
bh1745 output platform is a binary output that switches the INT pin, and with
it the LEDs. The component does not use the interrupt feature of the chip for anything else.
The chip only updates the INT pin at the end of a measurement, so the LEDs turn on or off up to one
integration_time after the output changes.
Configuration variables
Section titled “Configuration variables”-
id (Required, ID): The ID of the output, used to control it.
-
bh1745_id (Optional, ID): The ID of the
bh1745hub. Only needed when you have more than one hub. -
All other options from Output.
To control the LEDs from Home Assistant, use the output in a Binary Light:
light: - platform: binary name: "Sensor LEDs" output: bh1745_output