Hi
You know a way how to read the sensor data from the BH1750 sensor?
Hi
You know a way how to read the sensor data from the BH1750 sensor?
One simple way is to use an ESP8266:
I have a working BH1750 on a raspberry pi using the following:
Node node-red-contrib-i2c
35 is the address of the sensor, 16 is the command to get the lux value.
Followed by a change node:
The JSONata expression is:
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.
Thanks for sharing my output is sadly : [9,213]
i did exactly like you said. what did i do wrong ?
JSONata:
$round((payload."1" + (265 * payload."0"))/1.2,2)
my output:
you are setting msg.lux to be the value, but your debug is set to display msg.payload
Double click on the debug to change it to display the correct part of the message object or the entire message
oh lol i am just getting started with node-red and overlooked that part
Worth reading
https://nodered.org/docs/user-guide/messages for some tips on how to use debug nodes to help navigate the message object
Hello,
I hope anybody can help me.
I use node-Red over ioBroker and I want to use the BH1750 sensor connected on my raspberry. I've followed the instructions from ghayne but unfortunately I don't get any message from the sensor. Not from "I2C in" and not from "I2C Scan". The sensor works fine with a phyton script.
I connected the sensor like the description on the following site www.raspberrypi-spy.co.uk
Here is also a picture from the flow. Any tips?
You need an inject mode before the i2c node!
[{"id":"6e0dfdec.2f6c74","type":"inject","z":"9dcf23c2.6c9ca","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":false,"x":110,"y":60,"wires":[["f9655f1b.ef3c1"]]},{"id":"f9655f1b.ef3c1","type":"i2c in","z":"9dcf23c2.6c9ca","name":"Read BH1750","address":"35","command":"16","count":"2","x":300,"y":20,"wires":[["69f7be89.9e122"]]},{"id":"69f7be89.9e122","type":"change","z":"9dcf23c2.6c9ca","name":"Lux","rules":[{"t":"set","p":"lux","pt":"msg","to":"$round((payload.\"1\" + (256 * payload.\"0\"))/1.2,2)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":60,"wires":[["5714a6d3.d06238","a7aae33a.77a05"]]}]
Hello ghayne, thank you so much, now all is working fine.Have a nice day!
Really nice example of how to use i2c in node. I wish there were more like this!
Hi, can You help me with MCP9808 sensor? I found address of the sensor but I dont know where I can get this command, and then how to calculate results. I did BH1750 sam as You and its working.
There is a node for that sensor here:
I saw this but I cant install this. But the main problem is that I have 3 more sensors on I2C. I just want to know from where in documentation I can get this command address so I can connect them all through i2c node
node-red-contrib-i2c includes an i2c-scan node to find device addresses
Look at the datasheet for the MCP9808.
I looked but I don't know where to look for a "command".
I have address of the device
Here it is how it looks now:
datasheet for MCP9808:
https://botland.com.pl/index.php?controller=attachment&id_attachment=981