Integrating the Phantom YoYo High‑Sensitivity Water Sensor with the MCP3008 ADC on Raspberry Pi
In this guide we walk through connecting the Phantom YoYo high‑sensitivity water sensor to the MCP3008 8‑channel 10‑bit ADC, then reading the data with a Raspberry Pi 2 running Windows 10 IoT Core and C#. The MCP3008 converts analog signals to 10‑bit digital values (0–1023) that can be scaled to any reference voltage.
Why Use the MCP3008?
The MCP3008 is a compact, low‑cost ADC with SPI interface. Its 10‑bit resolution gives 1024 discrete levels, allowing fine voltage discrimination. With a 3.3 V reference, the sensor output can be converted to voltage using:
voltage = (reading / 1023.0) * Vref
For example, a raw reading of 523 corresponds to:
523 / 1023 * 3.3 ≈ 1.687 V
Always measure the actual supply voltage (e.g., 3.301 V on my Pi) and use that value for Vref to improve accuracy.
Hardware Overview
- Sensor: Phantom YoYo Water Sensor – 3 pins (–, +, s). Connect – to Pi ground, + to 3.3 V (or 5 V), s to MCP3008 channel 1.
- MCP3008: 8 input channels, SPI pins, Vref, Vdd, and AGND. Connect Vref to 3.3 V, AGND to Pi ground, Vdd to 3.3 V, and ground to Pi ground.
- Potentiometer: Optional – used to demonstrate ADC conversion on channel 0.
Wiring Diagram
Refer to the included schematic for pin mapping. Key connections:
- MCP3008 Vref (Pin 15) → Pi 3.3 V
- MCP3008 AGND (Pin 14) → Pi GND
- MCP3008 Vdd (Pin 16) → Pi 3.3 V
- MCP3008 CH0 (Pin 1) → Potentiometer output
- MCP3008 CH1 (Pin 2) → Water sensor s‑pin
- SPI lines (CS, CLK, DO, DI) → Pi SPI pins
Software Setup
Project type: Universal Windows Platform. Two gauges display:
- Raw voltage from the potentiometer (channel 0).
- Normalized water level (0–100) from the sensor (channel 1).
Initializing the MCP3008
private Mcp3008 _mcp3008;
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
_mcp3008 = new Mcp3008(0); // SPI bus 0
await _mcp3008.InitializeAsync();
}
Reading a Channel
float voltage = _mcp3008.Read(Mcp3008.Channels.Single0).AsScaledValue(3.3f);
For differential measurement, replace Single0 with Differential0. Dispose the object on navigation away:
_mcp3008.Dispose();
_mcp3008 = null;
Calibration & Measurement
Use a multimeter to verify the potentiometer voltage against the MCP3008 reading. Set the meter to DC voltage; compare the two values to validate accuracy.
Running the App
- Build in ARM configuration, choose Remote Machine.
- Set the Pi’s IP address in the project properties and disable authentication.
- Press F5 to deploy and launch.
The app displays a 360° gauge for water level. Note: the sensor’s output is not strictly linear; higher values correspond to more water but the relationship is empirical. The gauge is for illustrative purposes.
Source code and additional documentation are available on the project page.
Manufacturing process
- How Water Flow Sensors Work and Their Key Applications
- How to Connect a DS18B20 One‑Wire Digital Thermometer to a Raspberry Pi – A Step‑by‑Step Guide
- Integrating the Phantom YoYo High‑Sensitivity Water Sensor with the MCP3008 ADC on Raspberry Pi
- Smart Motion-Activated Water Gun Built with Arduino Nano
- Smart IR-Activated Water Tap Controlled by Arduino UNO – Efficient & Eco-Friendly
- WaterPi: Intelligent Remote Watering & Monitoring for Houseplants
- IoT Water Quality Sensor System - Arduino Based Real-Time Monitoring
- Getting Started with a 6‑DOF IMU Motion Sensor (MPU‑6050)
- Industrial-Grade High-Pressure Pumps for Reliable Irrigation Systems
- Automatic Water Pumps: How They Operate & Why They Matter