A simple temperature and humidity monitoring system using a Raspberry Pi Pico W and DHT22 sensor that exposes metrics for Prometheus monitoring.
- Measures temperature and humidity using a DHT22 sensor
- Exposes metrics in Prometheus format for monitoring dashboards
- Web interface for device status and configuration
- Over-the-air updates for easy firmware management
- WiFi connectivity for remote monitoring
- Connect DHT22 sensor to GPIO pin 15 on your Pico W
- Power the Pico W via USB
- Flash MicroPython to your Pico W
- Copy all files from the
firmware/
folder to your Pico W - Create
secrets.py
with your WiFi credentials:secrets = { "ssid": "YourWiFiName", "pw": "YourWiFiPassword" }
- Reset the device - it will connect to WiFi and start serving metrics
Once connected, visit your device's IP address in a web browser:
- Dashboard (
/
) - Overview of sensor status and system info - Health Check (
/health
) - Detailed system status - Configuration (
/config
) - Change device settings - Logs (
/logs
) - View system logs - Updates (
/update
) - Update firmware over-the-air
Add your device to Prometheus configuration:
scrape_configs:
- job_name: "pico-sensors"
static_configs:
- targets: ["<device-ip>:80"] # Replace <device-ip> with your device IP
Metrics available at /metrics
:
temperature_celsius
- Temperature readinghumidity_percent
- Humidity readingpico_sensor_status
- Sensor health (1=OK, 0=FAIL)pico_uptime_seconds
- Device uptimepico_version_info
- Firmware version
Use the web interface (/config
) to configure:
- Device name and location - For metric labels
- OTA update settings - Enable/disable automatic updates
- Update repository - GitHub repo for firmware updates
Edit secrets.py
to change WiFi credentials, then restart the device.
Import the included dashboard from configs/grafana-dashboard.json
for:
- Temperature and humidity graphs
- Device status monitoring
- System health metrics
Use the sample config in configs/prometheus.yml
as a starting point.
- Enable in device configuration (
/config
) - Device checks for updates periodically
- Updates happen automatically when available
- Visit
/update
on your device - Confirm the update
- Device will restart with new firmware
- Check
/health
to confirm new version
- Check WiFi credentials in
secrets.py
- Ensure WiFi network is 2.4GHz (Pico W doesn't support 5GHz)
- Check device logs at
/logs
- Verify DHT22 is connected to GPIO pin 15
- Check sensor wiring (VCC, GND, Data)
- View sensor status at
/health
- Ensure device has internet access
- Check logs at
/logs
for error details - Updates require ~150KB free memory
- Raspberry Pi Pico W - WiFi-enabled microcontroller
- DHT22 sensor - Temperature and humidity sensor
- Jumper wires - For connections
- Breadboard (optional) - For prototyping
DHT22 Sensor Pico W
VCC → 3V3 (Pin 36)
GND → GND (Pin 38)
Data → GPIO 15 (Pin 20)
For issues or questions:
- Check the logs at
/logs
on your device - Review the troubleshooting section above
- Check the GitHub issues page
This project is licensed under the MIT License.