This automatic water filtration system monitors water quality and flow while controlling a motorized filter mechanism via Arduino. The build combines turbidity and flow sensors with a 6-axis IMU to track filter tilt angle, enabling automated cleaning cycles when sediment levels rise or flow rate drops. The system uses a 12V gearmotor with logic-level MOSFET control and a reversing driver to manage filter position, with safety interlocks and timed operation modes.
This guide provides a complete wiring diagram, parts list, and step-by-step assembly instructions for integrating all five sensors with the Arduino Uno, configuring the motor control circuits, and uploading the provided firmware. Builders will learn sensor calibration, PWM motor control, I2C communication with the IMU, and how to commission the system safely before running filtration experiments.
Wiring diagram
Gather all the parts
Assemble it in 9 steps
1. Identify the five measurement sensors
S1, S2 and S3 are three separate SEN0189 turbidity sensor kits, each with its probe, adapter board and cable. S4 is the SEN0550 flow sensor. S6 is the MPU6050 tilt sensor. A linear actuator is shown as an unconnected planning part; powered tilt remains disabled. Keep adapter boards and the Arduino dry and above any possible spill. These electronics measure and control an existing water path; they do not purify water themselves.
- This is a sediment-removal experiment, not a drinking-water purifier. Nylon valves are not approved for potable water.
2. Connect every sensor to the UNO
With all power unplugged, connect each SEN0189 adapter VCC to UNO 5V and GND to UNO GND. Connect S1 SIG to A0 (inlet), S2 SIG to A1 (after settling), and S3 SIG to A2 (final outlet); set all three adapter switches to A for analog readings. Connect flow VCC to 5V, GND to GND, and OUT to D2 (pulse signal). Connect MPU6050 VIN to 5V, GND to GND, SDA to A4/SDA (data), and SCL to A5/SCL (clock); leave INT unused. Use this specified SEN0142 breakout, not a bare 3.3V-only MPU6050. Secure the angle board with X along the tube and Z upward. Place flow sensor after the filter with its arrow toward collection. Keep flow sensor water-filled and turbidity probe tops dry.
- A0, A1, A2, A4 and A5 are the printed UNO pin labels; the circuit view may also show GPIO14, GPIO15, GPIO16, GPIO18 and GPIO19 respectively.
- Turbidity is raw volts, not calibrated NTU. Calibrate each probe against a reference meter before reporting turbidity removal percentages. Avoid bubbles and grit on optical windows.
- Flow calibration starts at 150 pulses per litre. Check against collected volume and a stopwatch. Below 0.5 L/min is outside the sensor specified range.
- Compare displayed tilt with a protractor; reverse the mounting direction if positive tube tilt displays negative.
3. Plan actuator placement; keep tilt manual
Support the tube on a stable adjustable support and set its angle manually with load power off. Check it with a protractor and the angle sensor, then select the matching target on the dashboard. The 12V linear actuator is shown for visual planning only, with no electrical connections or reversing controller yet. Leave both motor leads insulated and disconnected. Confirm the actual stroke, force, lead layout and maximum current before selecting a reversing controller, fused supply and travel protection. Do not assume the existing 12V 2A adapter can power it. Mount the cleaning motor outside the wet tube with a sealed shaft and guarded coupling.
- Secure the tube against falling or moving under the wet load. Do not connect a linear actuator directly to Arduino pins or the existing one-direction motor driver.
4. Wire the upgraded helical motor circuit
The diagram now selects the StepperOnline F4D60-12GN-18S/4GN20K 12V brushed gearmotor with 20:1 gearbox, rated 90 RPM and 5.15 Nm torque. Leave both motor leads insulated and disconnected. The existing DRI0042 driver, 12V 8.5A supply and 7.5A fuse are provisional until motor startup/stall current is verified. Firmware disables motor commands. Existing control wiring stays D7 to IN1, IN2 to GND, PWM to UNO 5V, COM to GND, with 10k IN1 pulldown; leave 5VO unused. Do not energize the motor branch until ratings and cooling are reviewed.
- Guard the rotating helix and coupling. Support the helix with independent bearings and a coupling matched to the verified motor shaft dimensions; do not let its weight or axial thrust load the motor shaft.
- Actual helix torque is unverified. Test uncoupled first, then briefly with an empty helix. Stop immediately on a jam; the fuse is wiring protection, not motor overload protection.
- Rated 90 RPM is not guaranteed under every load; overload reduces speed and causes heating. Verify actual helix load before operation.
5. Connect USB and load power
USB powers UNO and sensors. The enclosed 12V 2A adapter powers only the two valves. Connect its negative to common ground; never connect its positive to Arduino 5V. Use the listed USB-C 5V supply through the UNO USB-C socket for standalone operation, not through header wires. The diagram 5V connection represents USB delivery. Disconnect the wall USB cable when connecting the computer for Deploy. No servo is used. Keep adapters above spills and unplug before touching wiring.
- Use factory-enclosed low-voltage adapters; never wire exposed mains. Wrong polarity can destroy electronics.
6. Test before the sediment experiment
With empty plumbing and loads safely supported, verify both valves close and motor stops at startup and STOP. Confirm the 5-second drain pulse; motor command must remain off while commissioning is locked. Set and secure the tube angle manually, verify the measured tilt, and select the matching target. Run with clear water first; RUN stops after 6 minutes, invalid angle, angle error, or sustained no outlet flow. Browser disconnection does not immediately stop RUN: use STOP or disconnect load power. Keep collection capacity at least 30 L. Collect paired meter readings, stopwatch flow, protractor angles and dry sediment mass for all trials; save CSV while the dashboard is open.
- Dashboard is a simple live digital counterpart, not a validated hydraulic simulation. Stokes/regression and ANOVA require measured calibration data and are not fabricated by firmware.
7. Wire the separate tilt supply and reversing controller
Put the separate 10A blade fuse in its inline holder. Connect the enclosed 12V 8.5A adapter labelled positive output to holder IN; holder OUT goes to DRI0042 VIN (9-36V terminal). CONTACT1 and CONTACT2 in the diagram represent the internal fuse contacts, not additional external wires. Connect adapter negative directly to PGND. Connect COM to UNO GND; join the supply negatives at a common terminal point. D9 goes to PWM (speed), D8 to IN1 and D10 to IN2 (direction). Each control input has its own 10k pulldown to ground. Leave 5VO unused. Use factory-rated matching output leads; do not guess the DIN plug pinout.
- The tilt adapter and fuse are provisional. Verify actuator maximum/startup/stall current before energizing. This supply cannot run an actuator requiring more than 8.5A.
- Use short 16 AWG copper power wires and suitably rated connectors, not breadboards. Route heavy-current negative wires directly to the common terminal, not through the UNO.
8. Keep actuator disconnected until commissioning
No servo or temperature sensor is used. Your actuator remains represented with insulated disconnected motor leads because its lead arrangement, current, internal limits and travel are unverified. After those are confirmed, its two motor leads would connect to controller OUT1 and OUT2, never directly to Arduino pins. This firmware deliberately holds all three tilt controls LOW; dashboard angles remain manual targets. Support and balance the tube on a pivot, verify mounting travel for 0 to 35 degrees and prevent pinch access before implementing powered motion.
- Do not attach an ordinary single flyback diode across a reversing actuator. The existing three diodes belong only to the valves and one-direction cleaning motor.
9. Turn the system on together
Plug the four factory-enclosed adapters into one switched power strip kept dry above the water system. USB-C 5V powers UNO and five sensors; 12V 2A powers the valves; dedicated 12V 8.5A powers the helical motor; separate 12V 8.5A is reserved for the tilt controller. Keep all positive rails separate; share low-voltage ground only. Unplug the tilt adapter during initial testing. A switched strip is not a certified emergency stop; disconnect load power immediately if motion or switching is unexpected.
- Never wire exposed mains or connect 12V to UNO 5V. Keep outlets and adapters away from spills and use an RCD/GFCI-protected outlet.
Review all connections
1. Connections between "s1" and "Arduino"
2. Connections between "s2" and "Arduino"
3. Connections between "s3" and "Arduino"
4. Connections between "flow" and "Arduino"
5. Connections between "imu" and "Arduino"
6. Connections between "supply12" and "Arduino"
7. Connections between "feed" and "Arduino"
8. Connections between "feedq" and "Arduino"
9. Connections between "feedrg" and "Arduino"
10. Connections between "feedpd" and "Arduino"
11. Connections between "feeddiode" and "Arduino"
12. Connections between "drain" and "Arduino"
13. Connections between "drainq" and "Arduino"
14. Connections between "drainrg" and "Arduino"
15. Connections between "drainpd" and "Arduino"
16. Connections between "draindiode" and "Arduino"
17. Connections between "usbpower" and "Arduino"
18. Connections between "tiltpower" and "Arduino"
19. Connections between "tiltfuseholder" and "Arduino"
20. Connections between "tiltfuse" and "Arduino"
21. Connections between "tiltdriver" and "Arduino"
22. Connections between "tiltpwm_pd" and "Arduino"
23. Connections between "tilt1_pd" and "Arduino"
24. Connections between "tilt2_pd" and "Arduino"
25. Connections between "motorpower" and "Arduino"
26. Connections between "motorfuseholder" and "Arduino"
27. Connections between "motorfuse" and "Arduino"
28. Connections between "motordriver" and "Arduino"
29. Connections between "motorinputpd" and "Arduino"
Deploy the firmware
#include <Arduino.h>
#include <Wire.h>
#include <WiFiS3.h>
#include <math.h>
WiFiServer server(80);
volatile uint32_t pulses=0; uint32_t lastPulses=0, sampleAt=0, runAt=0, actionAt=0;
float volts[3]={0}, angle=NAN, flowRate=0; bool imuOK=false;
enum State {IDLE,RUN,CLEAN,DRAIN}; State state=IDLE; int target=15;
void pulse(){pulses++;}
void stop(){digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);state=IDLE;}
void imuWrite(uint8_t r,uint8_t v){Wire.beginTransmission(0x68);Wire.write(r);Wire.write(v);Wire.endTransmission();}
void tick(){
uint32_t now=millis();
if(state==RUN && now-runAt>360000UL) stop();
if(state==CLEAN && now-actionAt>10000UL)stop();
if(state==DRAIN && now-actionAt>5000UL)stop();
if(now-sampleAt<1000)return;
float dt=(now-sampleAt)/1000.0f; sampleAt=now;
noInterrupts();uint32_t n=pulses;interrupts();flowRate=(n-lastPulses)*60.0f/(150.0f*dt);lastPulses=n;
for(int i=0;i<3;i++){long sum=0;for(int j=0;j<16;j++)sum+=analogRead(A0+i);volts[i]=sum/16.0f*5.0f/4095.0f;}
Wire.beginTransmission(0x68);Wire.write(0x3B);imuOK=Wire.endTransmission(false)==0;
if(imuOK && Wire.requestFrom(0x68,6)==6){int16_t x=(Wire.read()<<8)|Wire.read();int16_t y=(Wire.read()<<8)|Wire.read();int16_t z=(Wire.read()<<8)|Wire.read();angle=atan2(-float(x),sqrt(float(y)*y+float(z)*z))*180/PI;}else{imuOK=false;angle=NAN;}
if(state==RUN && (!imuOK || fabs(angle-target)>8 || (now-runAt>30000 && flowRate<0.05)))stop();
}
const char page[]=R"HTML(<!doctype html><meta name="viewport" content="width=device-width"><title>Water filter prototype</title><h2>Water filter research prototype</h2><p>Not drinking water. Turbidity shown as raw volts until calibrated.</p><pre id="live"></pre><button onclick="cmd('run')">Run (max 6 min)</button> <button onclick="cmd('stop')">STOP</button><p><button onclick="cmd('clean')">90 RPM helix (locked)</button> <button onclick="cmd('drain')">Drain 5 s</button></p><p>Manual angle target: <button onclick="cmd('tilt0')">0°</button> <button onclick="cmd('tilt15')">15°</button> <button onclick="cmd('tilt25')">25°</button> <button onclick="cmd('tilt35')">35°</button></p><button onclick="save()">Save browser readings CSV</button><p>Set feed restriction by collected volume and stopwatch. Flow sensor may under-read below 0.5 L/min. New 90 RPM motor is disconnected and locked off until electrical ratings are verified. Drain requires idle state. Guard moving parts; settling RUN keeps helix stationary. Set the tube angle manually while idle, then select its target here. 12V linear actuator provision shown in circuit; commissioning lock keeps tilt outputs off.</p><script>let rows=['seconds,inlet_V,settled_V,outlet_V,L_min,total_L,tilt_deg,state'];async function cmd(c){await fetch('/cmd?'+c,{method:'POST'});}async function poll(){try{let s=await(await fetch('/data')).text();document.getElementById('live').textContent=s; rows.push(s.trim());}catch(e){}setTimeout(poll,1000)}poll();function save(){let a=document.createElement('a');a.href=URL.createObjectURL(new Blob([rows.join('\n')],{type:'text/csv'}));a.download='filter-readings.csv';a.click();}</script>)HTML";
void setup(){
// Tilt commissioning lock: keep reversing driver off until actuator ratings and travel are verified.
for(int pin : {8,9,10}){digitalWrite(pin,LOW);pinMode(pin,OUTPUT);}
digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);pinMode(5,OUTPUT);pinMode(6,OUTPUT);pinMode(7,OUTPUT);
Serial.begin(115200);analogReadResolution(12);pinMode(2,INPUT_PULLUP);attachInterrupt(digitalPinToInterrupt(2),pulse,RISING);
Wire.begin();imuWrite(0x6B,0);imuWrite(0x1C,0);
if(WiFi.beginAP("FilterPrototype","FilterLab2026")!=WL_AP_LISTENING){Serial.println("WiFi failed; outputs stay off.");return;}server.begin();Serial.println(WiFi.localIP());
}
void loop(){
tick();WiFiClient c=server.available();if(!c)return;
String req="";uint32_t start=millis();while(c.connected() && millis()-start<300){tick();if(c.available()){char ch=c.read();if(ch=='\n')break;if(ch!='\r' && req.length()<160)req+=ch;}}
if(req.startsWith("POST /cmd?")){
if(req.indexOf("?stop ")>0)stop();
else if(req.indexOf("?run ")>0 && state==IDLE && imuOK && fabs(angle-target)<8){state=RUN;runAt=millis();digitalWrite(5,HIGH);}
else if(state==IDLE){
if(req.indexOf("?clean ")>0){stop();} // New motor commissioning lock: current ratings unverified.
else if(req.indexOf("?drain ")>0){state=DRAIN;actionAt=millis();digitalWrite(6,HIGH);}
else if(req.indexOf("?tilt")>0){int t=req.substring(req.indexOf("?tilt")+5).toInt();if(t==0||t==15||t==25||t==35){target=t;}}
}
}
c.println("HTTP/1.1 200 OK");c.println("Connection: close");c.println("Cache-Control: no-store");
if(req.startsWith("GET /data")){c.println("Content-Type: text/plain\r\n");noInterrupts();uint32_t n=pulses;interrupts();c.print(millis()/1000);for(float v:volts){c.print(',');c.print(v,3);}c.print(',');c.print(flowRate,3);c.print(',');c.print(n/150.0f,3);c.print(',');c.print(angle);c.print(',');c.println(state==RUN?"RUN":state==CLEAN?"CLEAN":state==DRAIN?"DRAIN":"IDLE");}
else if(req.startsWith("POST")){c.println("Content-Type: text/plain\r\n");c.println("OK; check live state");}
else{c.println("Content-Type: text/html\r\n");c.print(page);}c.stop();
}Remix this project
Make it yours in one click
Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.




