Water Quality EC and TDS Meter application with 16x2 I2C LCD support, physical buttons, and persistent flash calibration on Raspberry Pi Pico/Pico 2 C SDK.
  • C 88.5%
  • CMake 11.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-04 12:58:40 -07:00
.gitignore Initial commit of standalone-ec-meter using decoupled drivers 2026-08-04 11:44:34 -07:00
CMakeLists.txt Initial commit of standalone-ec-meter using decoupled drivers 2026-08-04 11:44:34 -07:00
main.c Update LCD layout to show Temp on Row 0 and EC with uS/cm on Row 1, removing TDS 2026-08-04 12:58:40 -07:00
pico_sdk_import.cmake Initial commit of standalone-ec-meter using decoupled drivers 2026-08-04 11:44:34 -07:00
README.md Initial commit of standalone-ec-meter using decoupled drivers 2026-08-04 11:44:34 -07:00

standalone-ec-meter

A complete, standalone water quality EC (Electrical Conductivity) and TDS (Total Dissolved Solids) meter application for the Raspberry Pi Pico / Pico 2 (RP2040/RP2350) using the Pico C SDK.

This project integrates three decoupled Lost + Found driver packages:

  • lf-ds18b20: For temperature measurement and compensation.
  • lf-tds-ec: For voltage-to-EC conversions and persistent flash calibration storage.
  • lf-hd44780: For writing values to a standard 16x2 I2C character LCD.

🔌 Hardware Wiring Guide

All components are wired to a contiguous block of pins on the left side of the Raspberry Pi Pico/Pico 2 (GP2 through GP6, plus nearby ground).

Important

Power Supply: The active TDS transmitter board and the DS18B20 should be powered from the Pico's 3V3 OUT (Pin 36). The I2C LCD backpack typically operates on 5V, so its VCC should connect to the Pico's VBUS pin (Pin 40), while its SDA/SCL logic remains compatible with the Pico's 3.3V lines.

DS18B20 Pull-up Resistor: Connect a 4.7\text{k}\Omega pull-up resistor between the DS18B20 Data (DQ) pin and the 3V3 line.

Connection Map

Component Board Pin Function Pico GP Pin Pico Physical Pin Wiring Description
DS18B20 DQ / OUT Data Line GP2 Pin 4 1-Wire Data line
CAL Button NO Active Low Trigger GP3 Pin 5 Connect switch between GP3 and GND
I2C LCD SDA I2C Data GP4 Pin 6 LCD Serial Data line
I2C LCD SCL I2C Clock GP5 Pin 7 LCD Serial Clock line
GND GND Common Ground GND Pin 8 Power & Signal Ground (0V)
RESET Button NO Active Low Trigger GP6 Pin 9 Connect switch between GP6 and GND
TDS Board A Analog Output GP26 (ADC0) Pin 31 Analog voltage representing EC

🛠️ How to Build

Configure your environment with the standard Raspberry Pi Pico C SDK (PICO_SDK_PATH set in your env) and run:

mkdir build
cd build
cmake -DPICO_PLATFORM=rp2350 -DPICO_BOARD=pico2 ..
make

Flash the generated standalone_ec_meter.uf2 binary to your Pico 2.


🧪 Calibration & Usage

  1. Power up the device. The 16x2 LCD should print TDS-EC Meter Booting... and then transition to show live T:xx.xC EC:xxxx and TDS: xxxx ppm readings.
  2. Place both the TDS probe and the DS18B20 temperature probe in a standard 1,413 $\mu\text{S/cm}$ calibration solution.
  3. Allow the readings to stabilize.
  4. Press the GP3 CAL button (or type CAL in the USB serial terminal). The screen will display Calibrating... Please wait....
  5. Upon successful calibration, it will display Calib Success! K-Factor: x.xxxx and save the new constant persistently to the Pico's external QSPI flash.
  6. To clear calibration and return to default uncalibrated state (K = 1.0), press the GP6 RESET button (or type RESET in the terminal). The screen will display Calibration Reset to 1.0000.