Water Monitor

Live level and temperature readings from my water container.

Loading…

Project

Water Level & Temperature Sensor

A MicroPython project built on the Raspberry Pi Pico W that monitors water-container level and three temperature sensors (air, inlet, water), shows live readings on a 128×64 OLED, and uploads data to ThingSpeak over WiFi. The pump itself runs on its own automatic controller — this is a safety net: a ThingSpeak action pings me on Telegram if the container stays empty, meaning something has gone wrong and the pump isn't recovering on its own. The temperatures are mostly for curiosity, and for deciding when to add heating to the container over winter. Configuration can be changed from any browser on the local network — no re-flashing required.

Pipeline

Pico W

MicroPython

ThingSpeak

HTTP · channels

This page

live dashboard

Telegram

pump-failure alert

Hardware

  • Raspberry Pi Pico W — WiFi-enabled microcontroller
  • 3 × DS18B20 on a shared OneWire bus (4.7 kΩ pull-up)
  • 2 × contact water-level sensors — HIGH when water present
  • SSD1306 128×64 I²C OLED display
  • Momentary push-button to toggle the OLED on/off

Pin map

GPIOFunctionDirection
5Water level sensor 1 (lower)Input, pull-down
6Water level sensor 2 (upper)Input, pull-down
9DS18B20 OneWire data
10Mode pin 1Output
11Mode pin 2Output
13OLED toggle buttonInput, pull-up
26OLED SDA (I²C1)
27OLED SCL (I²C1)

How it works

Main loop

Runs every 100 ms. Feeds a 15-second hardware watchdog, reads temperatures and water level on separate intervals, uploads to ThingSpeak, checks the OLED button, and handles web-config requests.

OLED display

SSD1306 over I²C. Updates are batched into a single flush to minimise bus traffic and keep the main loop responsive.

Web config

A non-blocking HTTP server on port 80 exposes a form for WiFi credentials, API keys, and intervals. Submissions are written to config.json and the device reboots.

ThingSpeak + Telegram

Temperature values upload every cycle; water-level uploads only fire on state change. The pump runs on its own automatic controller — a ThingSpeak action pings Telegram only as a safety net when the container stays empty, i.e. the pump failed to recover on its own.

Reliability features

File structure

.
├── main.py           # Entry point — main loop, watchdog, button, scheduling
├── config.py         # Defaults + config.json override loader
├── networking.py     # WiFi connect + ThingSpeak HTTP uploads
├── sensors.py        # DS18B20 temperature + water-level sensors
├── oled_display.py   # SSD1306 rendering helpers
├── web_config.py     # HTTP server for browser-based configuration
└── README.md