Introduction

Water quality monitoring is essential for environmental research, aquaculture, drinking water safety, and industrial process control. Traditionally, this required expensive commercial equipment, but the rise of open-source hardware and software has democratized access to water quality data collection.

This article explores three complementary approaches to building a self-hosted water quality monitoring system: EnviroDIY ModularSensors (an Arduino-compatible library for environmental sensors), Mycodo (a full-featured environmental monitoring platform for Raspberry Pi), and openHAB (a universal home automation platform with powerful sensor integration). Together, they cover the spectrum from DIY sensor programming to turnkey monitoring dashboards.

Comparison Table

FeatureEnviroDIY ModularSensorsMycodoopenHAB
Stars902,600+4,300+
PlatformArduino/ESP32Raspberry Pi / LinuxCross-platform (Java)
Primary UseData logging from sensorsEnvironmental control & monitoringHome/building automation
Water SensorsTurbidity, pH, DO, EC, temperature, depthpH, EC, temperature, humidity, DOpH, temperature, conductivity via add-ons
Web DashboardVia MQTT to external platformsBuilt-inBuilt-in (highly customizable)
Data StorageSD card / MQTT / ThingSpeakInfluxDBInfluxDB / PostgreSQL / RRD4j
AlertingProgrammaticBuilt-in (email, GPIO)Built-in (email, push, MQTT)
APIArduino librariesREST APIREST API + MQTT
DockerN/A (embedded)YesYes
Last Updated2026 (active)2026 (active)2026 (active)

Self-Hosted Water Quality Platforms

1. EnviroDIY ModularSensors

EnviroDIY ModularSensors is an Arduino library that simplifies connecting water quality sensors to microcontroller boards. Developed by the Stroud Water Research Center, it supports dozens of sensors from manufacturers like Atlas Scientific, Yosemitech, and MaxBotix. It’s the most flexible option for custom sensor deployments where you need precise control over sampling intervals and power management.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Example: Logging water temperature and turbidity to SD card
#include <ModularSensors.h>

// Define sensor pins
const int8_t turbidityPin = A0;
const int8_t tempPowerPin = 22;

// Create sensor objects
YosemitechY511 turbidity(turbidityPin, tempPowerPin);
MaximDS18 temp(tempPowerPin);

// Create data logger
Logger dataLogger;

void setup() {
    Serial.begin(115200);
    
    // Initialize sensors
    turbidity.setup();
    temp.setup();
    
    // Configure logger
    dataLogger.init("/water_data.csv", 15);  // Log every 15 minutes
    dataLogger.registerSensor(turbidity);
    dataLogger.registerSensor(temp);
}

void loop() {
    dataLogger.log();
    dataLogger.sleep();
}

For cloud integration, ModularSensors supports MQTT publishing to platforms like ThingSpeak or your own MQTT broker:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
// Publish readings to MQTT
#include <PubSubClient.h>
#include <WiFi.h>

WiFiClient wifiClient;
PubSubClient mqtt(wifiClient);

void publishToMQTT(float tempC, float turbidityNTU) {
    if (mqtt.connect("water-monitor-01")) {
        mqtt.publish("water/station1/temperature", String(tempC).c_str());
        mqtt.publish("water/station1/turbidity", String(turbidityNTU).c_str());
        mqtt.disconnect();
    }
}

2. Mycodo

Mycodo is a comprehensive environmental monitoring and control platform that runs on Raspberry Pi. It provides a web-based interface for configuring sensors, setting up data visualization, and creating automation rules. While originally designed for mushroom cultivation and indoor farming, Mycodo’s sensor library includes many water quality sensors:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Install Mycodo on Raspberry Pi
curl -L https://raw.githubusercontent.com/kizniche/Mycodo/master/install/setup.sh | bash

# Or use Docker
docker run -d \
  --name mycodo \
  --privileged \
  -v /opt/mycodo:/opt/mycodo \
  -p 8080:80 \
  kizniche/mycodo:latest

Mycodo’s Docker Compose configuration for persistent deployment:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# docker-compose.yml for Mycodo water monitoring stack
version: '3.8'
services:
  mycodo:
    image: kizniche/mycodo:latest
    container_name: mycodo
    privileged: true
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - /opt/mycodo:/opt/mycodo
      - /dev:/dev  # Sensor access
    environment:
      - TZ=UTC
  
  influxdb:
    image: influxdb:2.7
    container_name: mycodo-influxdb
    restart: unless-stopped
    ports:
      - "8086:8086"
    volumes:
      - /opt/influxdb:/var/lib/influxdb2
    environment:
      - INFLUXDB_DB=mycodo_db
      - INFLUXDB_ADMIN_USER=admin
      - INFLUXDB_ADMIN_PASSWORD=changeme

3. openHAB with Water Quality Add-ons

openHAB is a universal home and building automation platform that supports thousands of devices and protocols. While not purpose-built for water quality, its extensive binding ecosystem and MQTT integration make it a powerful choice for integrating water sensors into a broader monitoring and alerting infrastructure:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Docker Compose for openHAB water monitoring
version: '3.8'
services:
  openhab:
    image: openhab/openhab:4.2.0
    container_name: openhab
    restart: unless-stopped
    network_mode: host
    volumes:
      - /opt/openhab/addons:/openhab/addons
      - /opt/openhab/conf:/openhab/conf
      - /opt/openhab/userdata:/openhab/userdata
    environment:
      - OPENHAB_HTTP_PORT=8080
      - OPENHAB_HTTPS_PORT=8443
      - USER_ID=9001
      - GROUP_ID=9001

Configure openHAB to receive water quality data via MQTT:

1
2
3
4
// /opt/openhab/conf/items/water.items
Number Water_Temperature "Temperature [%.1f °C]" <temperature> {mqtt="<[mosquitto:water/station1/temperature:state:default]"}
Number Water_Turbidity "Turbidity [%.1f NTU]" <water> {mqtt="<[mosquitto:water/station1/turbidity:state:default]"}
Number Water_pH "pH Level [%.1f]" <ph> {mqtt="<[mosquitto:water/station1/ph:state:default]"}

With alerting rules for abnormal readings:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// /opt/openhab/conf/rules/water-alert.rules
rule "High Turbidity Alert"
when
    Item Water_Turbidity received update
then
    if (Water_Turbidity.state > 5.0) {
        sendMail("admin@example.com", "Water Alert",
            "Turbidity is " + Water_Turbidity.state + " NTU")
    }
end

Why Self-Host Water Quality Monitoring?

Own Your Environmental Data. Commercial water monitoring services store your data on their servers, often with usage restrictions or fees for data export. Self-hosting puts you in complete control — you decide how long to retain data, who can access it, and how it’s analyzed. For complementary environmental monitoring, see our air quality monitoring guide.

Cost-Effective Research Infrastructure. Commercial water quality sondes cost $2,000-$15,000 each. A DIY setup with ModularSensors on an ESP32 board with Atlas Scientific sensors costs $200-$500 — enabling citizen scientists, small labs, and schools to deploy sensor networks at a fraction of the cost. Combined with self-hosted MQTT infrastructure, you can build a distributed monitoring network covering multiple locations.

Integration with Existing Systems. Self-hosted platforms integrate easily with other services in your infrastructure. Route water quality alerts through your self-hosted notification system, store historical data alongside your smart home sensor data, and create unified dashboards that combine water metrics with weather, soil moisture, and energy data.

Hardware Selection and Sensor Integration

Building a reliable water quality monitoring station starts with hardware selection. The choice of microcontroller, sensors, and communication method determines what parameters you can measure and how reliably your station operates in the field.

Microcontroller Selection. For battery-powered remote deployments, ESP32 boards offer the best balance of processing power, WiFi/Bluetooth connectivity, and deep-sleep current draw (under 10µA). For stations with wired Ethernet, the ESP32-POE or a Raspberry Pi with PoE HAT eliminates separate power cabling. The Arduino MKR series provides industrial-temperature-range operation for extreme environments. If your station needs to run complex analysis locally (FFT for vibration analysis, machine learning for anomaly detection), a Raspberry Pi 4 or 5 provides sufficient compute while still running on 5-15W.

Sensor Wiring and Signal Conditioning. Water quality sensors typically use one of three interfaces: analog voltage (0-5V, needs ADC), I2C (digital, easy to chain), or RS-485/Modbus (industrial, long cable runs). Atlas Scientific sensors use I2C and include onboard signal processing, making them plug-and-play with most microcontrollers. For analog sensors, use a dedicated ADC module (ADS1115, 16-bit) rather than the built-in ADC for better resolution. Always include electrical isolation (optocouplers or isolation amplifiers) between submerged sensors and your controller to prevent ground loops and electrolysis damage.

Enclosure and Power Design. Use an IP67 or IP68 rated enclosure with cable glands for all wire penetrations. Place desiccant packs inside to manage condensation. For solar-powered stations, size your panel and battery using the formula: Panel Watts = (Daily Power Draw in Wh) / (Peak Sun Hours × 0.7 efficiency factor). A typical water monitoring station drawing 500mW needs a 10-20W solar panel with a 50-100Wh LiFePO4 battery for 24/7 operation with 3 days of autonomy during cloudy weather.

Communication Backhaul. Choose your data transmission method based on site conditions. WiFi works for stations within range of existing infrastructure. LoRa/LoRaWAN provides kilometers of range with very low power draw — pair an ESP32 with an RFM95 module and connect to a self-hosted ChirpStack network server. For truly remote sites, Iridium satellite modems (RockBLOCK) provide global coverage at ~$0.10 per 340-byte message, suitable for daily summary transmissions rather than real-time data.

FAQ

What water quality parameters can I measure with DIY sensors?

Temperature, turbidity (water clarity), pH (acidity/alkalinity), electrical conductivity (EC, a proxy for total dissolved solids), dissolved oxygen (DO), oxidation-reduction potential (ORP), and water depth/level are all measurable with open-source platforms. Atlas Scientific and DFRobot offer affordable sensor probes compatible with Arduino and Raspberry Pi.

How do I power a remote water quality monitoring station?

Solar panels with battery backup are the standard approach for remote deployments. ModularSensors includes power management features for deep sleep between readings, allowing a small solar panel and LiPo battery to run for weeks. For grid-connected sites, PoE (Power over Ethernet) with an ESP32-POE board simplifies installation.

Can I get accurate readings from DIY water quality sensors?

Yes, with proper calibration. All sensor types require regular calibration using standard solutions. Atlas Scientific sensors achieve laboratory-grade accuracy when properly maintained. The key is consistent calibration schedules and following manufacturer procedures. DIY platforms match commercial accuracy at a fraction of the cost.

How do I protect sensors in outdoor deployments?

Use waterproof enclosures (IP67 or higher) for electronics, and anti-fouling measures for submerged sensors — copper tape, wiper mechanisms, or regular manual cleaning. ModularSensors supports biofouling mitigation through configurable cleaning intervals if using automated wipers.

What’s the best platform for a beginner?

Start with Mycodo on a Raspberry Pi. It provides a web UI for configuration without requiring programming knowledge, and its sensor library handles most common water quality sensors out of the box. As your needs grow more complex, migrate to ModularSensors for custom deployments, using openHAB for unified dashboards across multiple monitoring stations.


💰 想测试你的市场判断力?我用 Polymarket 做预测市场交易——这是全球最大的预测市场平台,从大选结果到技术监管时间线,什么都可以押注。和赌博不同,这是真正的信息市场:你懂的信息越多,胜率越高。我靠预测技术相关事件的走向已经赚了不少。用我的邀请链接注册:Polymarket.com