Thursday, February 2, 2023

Raspberry Pi Pico DIY Light Meter Micropython sensor BH1750 (GY-302)

Raspberry Pico project light meter Thonny Micropython

Light sensor BH1750 (GY-302) and OLED display SSD1306
I2C communication

Video link Thonny IDE
Test code: from machine import I2C, Pin from BH1750 import BH1750 from ssd1306 import SSD1306_I2C from time import sleep i2c = I2C(0,sda=Pin(16), scl=Pin(17), freq=400000) oled = SSD1306_I2C(128,64,i2c) ## Oled Display pixel size 128x64 oled.fill(0) light = BH1750(i2c) while True: lux=light.luminance(BH1750.ONCE_HIRES_1) ## Sample luminance in lux lux = str(round(lux, 1)) oled.fill(0) oled.text("LUX",20,0) oled.text(lux, 20,15) oled.show() sleep(0.5)


No comments:

Post a Comment