Raspberry Pi Aquarium Monitor DIY Guide: Sensors and Code
A $35 Raspberry Pi Zero W running Python on 5 watts of power has replaced Neptune Apex modules worth ten times as much in more than one Singapore fish room. A well-built raspberry pi aquarium monitor diy rig reads temperature, pH, water level and flow, logs data to a local database and emails you when parameters drift, all without subscription fees or cloud dependencies. This guide from Gensou Aquascaping at 5 Everton Park summarises the parts, wiring and code patterns we have seen work reliably in tropical humidity over multiple years.
Why Bother Building Your Own
Commercial controllers like Neptune Apex or GHL ProfiLux are excellent but expensive, and locked into their own ecosystems. A Pi build lets you pick exactly the sensors you need, add more over time, and own the data. The downside is time; expect a weekend of soldering, configuration and debugging for a basic build. If your time is more valuable than $400, buy the commercial unit. If you enjoy tinkering, the Pi route is genuinely better. Our smart controllers compared piece benchmarks commercial options.
Hardware Shopping List
Start with a Raspberry Pi Zero 2 W ($25 at Hachi Hobbyist or SG Bots), a 16GB microSD card ($8), and a 5V 2A USB power supply ($10). Add a DS18B20 waterproof temperature probe ($6), an Atlas Scientific pH kit ($110 ex-shipping) and an HC-SR04 ultrasonic sensor for water level ($5). Total bill for a capable build sits around $170 to $200 depending on sensor choice. Hachi at Marsiling and SG Bots online stock most parts; Adafruit-branded sensors from Shopee work well if you pay attention to seller reviews.
Basic Wiring Layout
The DS18B20 temperature probe uses a single-wire protocol on GPIO pin 4 with a 4.7kΩ pull-up resistor. The HC-SR04 takes two GPIO pins for trigger and echo. Atlas Scientific pH modules use I2C on pins 2 and 3. Keep all wiring out of direct contact with saltwater spray; use hot glue and silicone sealant liberally around probe entry points. Singapore humidity punishes unsealed connections within weeks.
Operating System and Initial Setup
Flash Raspberry Pi OS Lite to the microSD using the official Imager tool. Enable SSH and configure WiFi credentials during imaging. Boot the Pi, SSH in, run raspi-config to enable I2C and one-wire interfaces. Install Python 3 (preinstalled on recent OS releases), and install the required libraries: `pip install w1thermsensor smbus2 RPi.GPIO`. Keep the Pi on wired ethernet during setup; WiFi can be re-enabled once the sensors are working.
Reading Temperature and pH
The DS18B20 library abstracts most complexity. A five-line Python script reads the probe every 60 seconds and writes the value to an SQLite database with a timestamp. Accuracy is ±0.5°C out of the box, sufficient for an aquarium. Calibrate against a known reference thermometer if you want tighter accuracy. Our digital thermometer comparison covers reference options. For pH, Atlas Scientific probes are the hobbyist standard because they include calibration solutions and a proper circuit board with I2C output. Cheaper Chinese probes from Shopee often drift within weeks. Calibrate on fresh installation using pH 4.0 and pH 7.0 reference solutions; recalibrate every three months. Store the probe wet when not in use. For the full calibration procedure see our digital pH meter comparison.
Water Level Monitoring
The HC-SR04 ultrasonic sensor mounted above the sump measures distance to the water surface. Trigger a reading every 10 seconds, average over three readings to reject noise, and compare against calibrated empty and full distances. A sudden drop indicates evaporation for top-off logic; a sudden rise flags an auto-top-off overflow. Wrap the sensor in a 3D-printed hood to avoid condensation accumulation.
Alerting Logic
Use the smtplib module to email you when any reading crosses a threshold. For temperature, alert outside 24 to 30°C. For pH, alert outside 6.5 to 8.5 for freshwater or 7.9 to 8.5 for marine. Include a debouncer; require three consecutive out-of-range readings before firing, or a single brief probe wobble will spam your inbox. Integrate with Telegram or Discord for faster notifications; most Singapore hobbyists prefer Telegram on local phones.
Data Logging and Visualisation
SQLite is sufficient for up to a year of minute-resolution readings from five sensors. For visualisation install Grafana and point it at the database; you get a web dashboard accessible from any device on your home network. Our parameter log template covers the data structure to aim for. Exported CSVs make troubleshooting over weeks far easier than eyeballing trends from memory.
Adding Automation
Once monitoring works, adding switched outputs is a small step. A relay HAT like the Waveshare 4-channel relay lets the Pi control mains devices: lights, pumps, CO2 solenoids. This effectively replicates the Apex EB8 energy bar at under 10 percent of the cost. Safety-critical loads like heaters should run off a separate safety thermostat, not just your Pi script; a software bug or SD card corruption should never be able to cook fish.
Long-Term Reliability and Commercial Alternatives
Raspberry Pi SD cards degrade faster when constantly written to; mount your database on a USB SSD after the build is stable. Singapore humidity enters ventilation slots on the Pi’s case; use a sealed project box with silica gel packs replaced quarterly. Back up your SD card image and your code to GitHub every time you make significant changes. Our holiday preparation guide covers remote monitoring setup before you travel. A Neptune Apex with comparable sensors runs $1,200 to $1,600 delivered to Singapore, and a GHL Mini runs around $900. Both offer polished apps, solid support and faster troubleshooting. The Pi approach wins on flexibility, cost and data ownership, and loses on plug-and-play convenience. For a single display tank where reliability trumps tinkering, buy commercial; for a fish room with multiple systems, build your own and reuse patterns across tanks. See our Neptune Apex programming guide.
Where to Ask for Help
Local Singapore hobbyist Discord servers and the reef community Facebook groups have active channels for DIY electronics questions. Hachi at Marsiling runs informal Saturday workshops occasionally for Pi and Arduino beginners; dropping by with your half-built project is accepted practice. Overseas, the reef2reef controller forum and Adafruit’s forums handle niche sensor problems.
Related Reading
emilynakatani
Still Have Questions About Your Tank?
Drop by Gensou Aquascaping — most walk-in questions get answered in under 10 minutes by someone who has set up hundreds of tanks.
5 Everton Park #01-34B, Singapore 080005 · Open daily 11am – 8pm
