Water Quality Monitoring with EC and pH Sensors Connected to Odoo

Maintaining proper water quality is essential for healthy crop irrigation and livestock care. By combining EC and pH sensors with a Raspberry Pi and Odoo, farmers can automatically track key water parameters, detect threshold violations, and visualize data in real time.

Required Hardware

  • Raspberry Pi 4
  • Analog EC module (e.g., Gravity EC Sensor)
  • Analog pH module
  • ADS1115 analog-to-digital converter
  • Wi-Fi connection to Odoo

How It Works

The analog outputs of the EC and pH sensors are digitized using the ADS1115 converter. The Raspberry Pi reads these values at defined intervals, converts them into pH and EC units, and checks against preset thresholds. If either value is outside the safe range, an alert is triggered in Odoo. All measurements are logged with timestamps and displayed on the Odoo dashboard for continuous monitoring.

Example Python Script

import time
import requests
import Adafruit_ADS1x15

adc = Adafruit_ADS1x15.ADS1115()
GAIN = 1

PH_CHANNEL = 0
EC_CHANNEL = 1

PH_MIN, PH_MAX = 6.0, 7.5
EC_MIN, EC_MAX = 1.0, 2.5

def read_voltage(channel):
    return adc.read_adc(channel, gain=GAIN) * 4.096 / 32767.0

def upload_to_odoo(ph, ec, alert):
    url = "http://your-odoo-instance.com/api/water_quality"
    data = {"ph": ph, "ec": ec, "alert": alert}
    headers = {"Authorization": "Bearer your_token"}
    requests.post(url, json=data, headers=headers)

while True:
    ph_voltage = read_voltage(PH_CHANNEL)
    ec_voltage = read_voltage(EC_CHANNEL)

    ph_value = (ph_voltage - 2.5) * 3.0 + 7.0
    ec_value = ec_voltage * 2.0

    alert = not (PH_MIN <= ph_value <= PH_MAX and EC_MIN <= ec_value <= EC_MAX)

    upload_to_odoo(ph_value, ec_value, alert)

    print(f"pH: {ph_value:.2f} | EC: {ec_value:.2f} | Alarm: {alert}")
    time.sleep(600)

Wiring EC and pH Sensors via ADS1115

  • pH Sensor VCC → 5V (Pin 2)
  • pH Sensor GND → GND (Pin 6)
  • pH Sensor OUT → ADS1115 A0
  • EC Sensor VCC → 5V (Pin 4)
  • EC Sensor GND → GND (Pin 9)
  • EC Sensor OUT → ADS1115 A1
  • ADS1115 SDA → GPIO2 (Pin 3)
  • ADS1115 SCL → GPIO3 (Pin 5)

Benefits and Recommendations

This setup enables precise monitoring of water quality with minimal manual effort. By integrating directly with Odoo, farmers gain centralized data storage, automatic alarms, and easy visualization through dashboards. Proper calibration of both EC and pH sensors is crucial for accuracy.

Conclusion

With EC and pH sensors connected to Raspberry Pi and Odoo, water quality monitoring becomes automated, reliable, and directly linked to farm management tools. This ensures better irrigation control, improved plant health, and sustainable resource use.