Read BH1750 Sensor

I have a working BH1750 on a raspberry pi using the following:
Node node-red-contrib-i2c

Screenshot_2018-09-23_17-33-24
35 is the address of the sensor, 16 is the command to get the lux value.

Followed by a change node:
Screenshot_2018-09-23_17-34-40

The JSONata expression is:
Screenshot_2018-09-23_17-35-39

Which is converting the two byte value returned by the i2c node to a decimal value and dividing the result by 1.2 as described in the datasheet (the sensor returns values that are typically 20% too high), and rounding to 2 decimal places.

msg.lux contains the result.

4 Likes