- C 88.5%
- CMake 11.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .gitignore | ||
| CMakeLists.txt | ||
| main.c | ||
| pico_sdk_import.cmake | ||
| README.md | ||
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}\Omegapull-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
- Power up the device. The 16x2 LCD should print
TDS-EC Meter Booting...and then transition to show liveT:xx.xC EC:xxxxandTDS: xxxx ppmreadings. - Place both the TDS probe and the DS18B20 temperature probe in a standard 1,413 $\mu\text{S/cm}$ calibration solution.
- Allow the readings to stabilize.
- Press the GP3 CAL button (or type
CALin the USB serial terminal). The screen will displayCalibrating... Please wait.... - Upon successful calibration, it will display
Calib Success! K-Factor: x.xxxxand save the new constant persistently to the Pico's external QSPI flash. - To clear calibration and return to default uncalibrated state (
K = 1.0), press the GP6 RESET button (or typeRESETin the terminal). The screen will displayCalibration Reset to 1.0000.