Build it step by step
0 of 6 doneWire and read
Connect the module and watch the voltage on the Serial Monitor.
Measure clear water
Put the probe in a glass of bottled water and note the voltage.
Measure cloudy water
Add a pinch of clay to a second glass and note it again.
Measure muddy water
Add more clay and note it.
Set the thresholds
Put values between your three readings into the code.
Test samples
Check tap and stored water and compare with how they look.
How do you build a tap water turbidity checker?
A turbidity sensor shines light through a sample and tells clear, slightly cloudy and muddy water apart. It does not say whether water is safe to drink. You need Arduino Nano, Turbidity sensor module and SSD1306 OLED Display. It takes 6 steps and about 45 minutes.
- Level
- Beginner
- Time
- About 45 min
- Parts
- 3
Parts list
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- DisplaysBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Turbidity module VCC, GND | Nano 5V, GND | Power |
| Turbidity module signal (A) | Nano A0 | Analog output |
| OLED SDA, SCL | Nano A4, A5 | I2C |
| OLED VCC, GND | Nano 5V, GND | Power |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "U8g2". A higher voltage means clearer water for most turbidity modules. Only the probe end goes in water; keep the electronics box dry. Use the same glass, depth and lighting for every test, and rinse the probe after each sample. Clear water can still contain germs and chemicals: this tells you only how cloudy it is, so never use it to judge whether water is safe to drink.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <U8x8lib.h>
U8X8_SSD1306_128X64_NONAME_HW_I2C oled(U8X8_PIN_NONE);
const byte SENSOR = A0;
// Edit these after you have measured your own reference glasses (volts):
const float CLEAR_V = 4.0; // above this reads Clear
const float CLOUDY_V = 3.3; // above this reads Slightly cloudy, below it Muddy
void setup() {
Serial.begin(9600);
oled.begin();
oled.setFont(u8x8_font_chroma48medium8_r);
}
void loop() {
long s = 0;
for (byte i = 0; i < 32; i++) { s += analogRead(SENSOR); delay(5); }
float v = (s / 32.0) * 5.0 / 1023.0;
Serial.println(v, 2);
const char* label = v > CLEAR_V ? "Clear " : (v > CLOUDY_V ? "Slightly cloudy" : "Muddy ");
char b[17], t[8];
dtostrf(v, 4, 2, t); snprintf(b, sizeof b, "Sensor %s V", t);
oled.drawString(0, 1, b);
oled.drawString(0, 4, label);
oled.drawString(0, 7, "Not a safety test");
delay(500);
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
2.50
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Bottled water | Clear |
| Light clay in water | Slightly cloudy |
| Heavy clay | Muddy |
| Probe in air | A different, fixed reading; not meaningful |
If it does not work
Reading always the same
Check the signal wire and that the probe is in water.
Values drift
Keep the same depth and let it settle for a few seconds.
Thresholds do not match
Re-measure your own glasses and edit the constants.
Screen blank
Check the I2C connection.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the tap water turbidity checker?
Arduino Nano, Turbidity sensor module and SSD1306 OLED Display.
How long does the tap water turbidity checker take to build?
About 45 minutes for a beginner maker, in 6 steps.
How do I know the tap water turbidity checker works?
Bottled water: Clear. Light clay in water: Slightly cloudy. Heavy clay: Muddy.
Reading always the same: what should I check?
Check the signal wire and that the probe is in water.
Values drift: what should I check?
Keep the same depth and let it settle for a few seconds.
Thresholds do not match: what should I check?
Re-measure your own glasses and edit the constants.
Screen blank: what should I check?
Check the I2C connection.
