GPS speedometer and clock
A bike or car speedometer that needs no wheel sensor: satellites do the measuring.
Shop by category
Shop all componentsThe Raspberry Pi Pico W adds Wi-Fi to the RP2040 chip. With MicroPython's built-in network, dht and umqtt libraries, a complete MQTT sensor node fits in about thirty lines. This one reconnects to Wi-Fi if the router restarts, and publishes two topics that any MQTT dashboard, Node-RED flow or Home Assistant can read. The Pico W only joins 2.4 GHz Wi-Fi networks.
Do not send private data to a public broker.
Tick anything you already have and the total updates.
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB cable or a power bank.
main.pyimport network, time, machine, dht
from umqtt.simple import MQTTClient
SSID = "YOUR_WIFI"
PASSWORD = "YOUR_PASSWORD"
BROKER = "broker.hivemq.com" # public test broker: use your own for real data
BASE = b"gb-demo-5678/room"
sensor = dht.DHT22(machine.Pin(15))
wlan = network.WLAN(network.STA_IF)
def wifi():
if not wlan.isconnected():
wlan.active(True)
wlan.connect(SSID, PASSWORD)
for _ in range(30):
if wlan.isconnected():
break
time.sleep(1)
while True:
try:
wifi()
sensor.measure()
client = MQTTClient("pico-w-1", BROKER)
client.connect()
client.publish(BASE + b"/temperature", str(sensor.temperature()))
client.publish(BASE + b"/humidity", str(sensor.humidity()))
client.disconnect()
print("published", sensor.temperature(), sensor.humidity())
except Exception as e:
print("error:", e)
time.sleep(30)
The Pico W only supports 2.4 GHz networks. Check the name and password, and wait up to 30 seconds.
Check the data wire and that the DHT22 has 3.3 V. Wait two seconds after power-up before reading.
Install the 'umqtt.simple' package on the Pico first, as in step 2.
A small messaging protocol: a device publishes values to named topics and other programs subscribe to them.
Yes. Point BROKER at its MQTT broker and add MQTT sensors for the two topics.
Only the W has a Wi-Fi radio.
4 parts: Raspberry Pi Pico W Microcontroller Board, DHT22 AM2302 Digital Temperature & Humidity Sensor, Solderless Breadboard and Dupont Jumper Wires (40 pcs). 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 1.5 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (main.py).
About ₹875 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Joining Wi-Fi from MicroPython; Publishing to MQTT with umqtt.simple; Reading a DHT22 on the Pico.
Do not send private data to a public broker.
Ideas that reuse this build: ESP32 MQTT temperature dashboard. They are listed under Take it further on this page.
A bike or car speedometer that needs no wheel sensor: satellites do the measuring.
Records where you went every five seconds, ready to open on a map.
Two boards, two radios: press the button at the gate and it rings indoors.
Check temperature, humidity and pressure from any phone on your Wi-Fi.
Learning project. Check every circuit and the datasheet of each part before you power it up.