Aquarium Monitor: Water Temperature and pH
Watch your fish tank's temperature and pH from your phone and get warned before a heater fails or the water turns acidic.
Fish are sensitive to small changes. A waterproof DS18B20 probe reads temperature over the Pi's 1-Wire bus, and an analog pH board read through an ADS1115 tracks acidity. Together they catch problems while you are away.
Water and electricity: keep the Pi, power supply and outlets above and away from the tank, use drip loops on every cable and plug the aquarium equipment into a GFCI-protected outlet. Only the sealed probes go in the water.
Mission steps
Enable 1-Wire
Add dtoverlay=w1-gpio to /boot/firmware/config.txt and reboot; the probe's data wire goes to GPIO4 with a 4.7 kΩ resistor to 3V3.
Test the temperature
The probe appears in /sys/bus/w1/devices as a folder starting with 28-; the script reads its temperature file.
Add the pH board
Power the pH board and ADS1115 from 3.3 V and connect the board's analog output to ADS1115 input A0 (I2C to GPIO2/GPIO3).
Calibrate pH
Dip the probe in pH 7 and pH 4 buffer solutions, note both voltages and compute a straight-line conversion.
Set alerts
Warn when temperature leaves your species' range or pH moves more than 0.5 from normal.
Code
import glob, time
probe = glob.glob('/sys/bus/w1/devices/28-*/temperature')[0]
LOW_C, HIGH_C = 24.0, 28.0 # set for your fish
while True:
with open(probe) as f:
c = int(f.read()) / 1000
status = 'OK' if LOW_C <= c <= HIGH_C else 'ALERT'
print(f"{time.strftime('%H:%M')} water {c:.2f} °C {status}")
time.sleep(60)Tip: test every script on the bench before installing it in a moving machine.
Questions
Can the pH probe stay in the tank all the time?
Hobby probes drift and age when submerged constantly. Recalibrate every few weeks and expect to replace the probe eventually.