There is a need to read some light, I’ll use this to automate the light routine inside the Node-red. But for now let’s connect our sensor. Connection is preety straight forward. My sensor model is GY-302,
First you need to connect the device to the I2C ports.
Honestly always refer to the pinout to avoid any troubles.
To find pinout screech in google ( node mcu v3 pinout ).
But if you are unsure what to do please processed with caution.
You can even damage your computer.
In my case connect:
+VCC – 3v or VV ( 5v )
GND – G
SDA – D2
SCL – D1
To find your i2c address you could use this scanner:
Now download and throw an library into /lib folder on your micro python device. Preferably with Thony.
The repository that worked for me was found under:
I just modified the final code so it will work on esp8266.
bh1750 micropython on esp8266
from machine import Pin, I2C from utime import sleep import math from bh1750 import BH1750 i2c0 = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4)) bh1750 = BH1750(0x23, i2c0) while True: data = bh1750.measurement data = math.ceil(data) print(data) sleep(1)