Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsIndoor plants need enough light, not constant light. The BH1750 measures the lux on the shelf; when it falls under the limit the Pico switches on a small LED strip through a MOSFET module. A total on-time limit stops it running all day and night.
Tick anything you already have and the total updates.
Digital light sensor that reports brightness in lux, the same unit used for room and street lighting.
Logic-level MOSFET used as a fast electronic switch, so a PWM pin can control a motor's speed.
Follow the colours: red is power, dark grey is ground, blue is a signal.
main.py# Pico automatic grow light: LEDs on only when the plant shelf is dim, within a daytime window (MicroPython)
from machine import Pin, I2C
import time
i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=400000)
BH1750 = 0x23
i2c.writeto(BH1750, b"\x01")
i2c.writeto(BH1750, b"\x10")
light = Pin(15, Pin.OUT) # drives a MOSFET module for the LED strip
DIM_BELOW = 3000 # lux under which the plant is short of light
HOURS_ON = 12 # at most this many hours of LED light per run (the Pico has no clock, so it counts from power-up)
def lux():
d = i2c.readfrom(BH1750, 2)
return ((d[0] << 8) | d[1]) / 1.2
on_seconds = 0
while True:
value = lux()
if value < DIM_BELOW and on_seconds < HOURS_ON * 3600:
light.value(1)
on_seconds += 10
else:
light.value(0)
print("%d lux LEDs %s on for %d min" % (value, "ON" if light.value() else "off", on_seconds // 60))
time.sleep(10)
Check SDA and SCL are not swapped. An I²C scanner should show 0x23 (0x5C if the ADDR pin is tied high).
Check the wiring and power, then try again. A reading of 0 in a dark room is normal.
Gate and drain swapped, or the 10 kΩ gate pull-down is missing.
7 parts: GY-302 BH1750 Light Intensity Module – I2C Interface, Power MOSFET (TO-220, IRLZ44N), Diodes (Pack of 10, 1N4007), Resistor Assortment Kit (30 Values), Raspberry Pi Pico, Solderless Breadboard (830 points) and Dupont Jumper Wires (40 pcs). Tools: Digital Multimeter and Wire Stripper and Cutter. On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 45 minutes. The build on this page has 4 steps.
No. This page has the complete, tested code (main.py).
About ₹672 for the parts at the prices on this page, plus tools if you do not have them. Quantity price breaks lower the cost when you build several.
Lux, lumens and the I²C bus; MOSFET switching and flyback diodes.
Ideas that reuse this build: Pico lux meter and Wi-Fi plant light meter. They are listed under Take it further on this page.
Your first MicroPython project: temperature and humidity on an OLED.
A web page with ON and OFF buttons that switches a relay over Wi-Fi.
A warm ring light that fades up at dusk and down at dawn.
Turn a Pi and a touchscreen into a home command centre with a clock and to-do list.
Learning project. Check every circuit and the datasheet of each part before you power it up.