Introduction: Water Pressure Logger With Arduino
Warning!!! Project is still in progress. Still collecting data and documenting.
I thought maybe someone will want to do some data logging on their home using this project.
Click on the link below to buy everything you need in one buy. I will set it up for you make sure it works before shipping to you.
Also, I attached documentation "ASIS" since I'm still working on it, feel free to take a look.
Step 1:
Graphing the water pressure reading on the Y-axis and date time
on the X-axis.
You can see how it started with no pressure on the water line until the valve was opened then water pressure present until the valve was shut off and fitting removed from the faucet. Very cool.
More graph showing toilet flush and shower events.
Step 2:
Example logger output.
May need some more work. But, it's good enough for this project.
5 Comments
Question 2 years ago on Step 2
Good evening
I am looking at your Water Pressure with Aduino project - but the eBay link does not work. Can you let me know what components you used please?
Many thanks
Mike
Reply 2 years ago
Sorry i didn't get around to updating the document. But, here is a list of the parts used:
1. Arduino Uno
2. Logging Shield XD-204 For Arduino UNO
3. Pressure sensor P51-500-A-A-I36-5V-000-000.
4. Note: Less expensive alternative pressure sensor will also work.
5. JST SM 2Pin Plug Male to Female EL Wire Cable
6. Lowes threaded pipe hose fittings.
The must haves are #1 to #3.
Reply 2 years ago
Good morning
Many thanks - I have ordered the essential components and will give it a go when they arrive.
Many thanks
Mike
Reply 2 years ago
Good evening
One last query - I have received the logging shield and pressure sensor. The Arduino should arrive in the next day or two. I have sufficient other components to assemble the hardware.
Would you be so kind as to share the sketch code with me in order to speed up the commissioning of the assembly. I have a real problem with my water supply and I'd like to get on with the monitoring as quickly as possible.
Best regards
Mike
Reply 2 years ago
Here you go :)
You will need to calibrate your realtime clock so that the time comes out right.
If you purchased the same pressure sensor, then the scaling in the skatch below will work for you too.
/*
Need some more help help?
http://www.arduino.cc/en/Tutorial/AnalogReadSeria...
This app will try to monitor
pressure
log it to a file
//Alfred Udah
//4/25/2019
*/
#include "SD.h"
#include <Wire.h>
#include "RTClib.h"
//app configurations
#define LOG_INTERVAL 1000 // mills between entres
#define ECHO_TO_SERIAL 1 //echo data to serial port
#define WAIT_TO_START 0 // wait for serial input in setup()
//pin for indicator, digital pin that connect to led
#define redLEDpin 3
#define greenLEDpin 4
//configuration sensor
#define float scale = 50;
#define int offset = -25;
// anolog pin for sensors
// read the input on analog pin 0:
#define int sensorValue = analogRead(A2);
#define photocellPin 0 //analog 0
#define tempPin 1 //anolog 1
//RTC
RTC_DS1307 RTC; // define the real time clocl objects
//SD card config
const int chipSelect = 10;
//file logging
File logfile;
void error(char *str)
{
Serial.print("error: ");
Serial.println(str);
// red LED indicates errors
digitalWrite(redLEDpin, HIGH);
while(1);
}
}
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
Serial.println();
#if WAIT_TO_START
Serial.println("type any character to start");
while(!Serial.available());
#endif //WAIT_TO_START
// initialize the SD card
Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to
// output, even if you don't use it:
pinMode(10, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect))
{
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
// create a new file
char filename[] = "LOGGER00.CSV";
for (uint8_t i = 0; i < 100; i++) {
filename[6] = i/10 + '0';
filename[7] = i%10 + '0';
if (! SD.exists(filename)) {
// only open a new file if it doesn't exist
logfile = SD.open(filename, FILE_WRITE);
break; // leave the loop!
}
}
if (! logfile) {
error("couldnt create file");
}
Serial.print("Logging to: ");
Serial.println(filename);
Wire.begin();
if (!RTC.begin()) {
logfile.println("RTC failed");
#if ECHO_TO_SERIAL
Serial.println("RTC failed");
#endif //ECHO_TO_SERIAL
}
logfile.println("millis,time,light,temp");
#if ECHO_TO_SERIAL
Serial.println("millis,time,light,temp");
#if ECHO_TO_SERIAL// attempt to write out the header to the file
if (logfile.writeError || !logfile.sync()) {
error("write header");
}
pinMode(redLEDpin, OUTPUT);
pinMode(greenLEDpin, OUTPUT);
// If you want to set the aref to something other than 5v
//analogReference(EXTERNAL);
}
}
// the loop routine runs over and over again forever:
void loop() {
DateTime now;
// delay for the amount of time we want between readings
delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));
digitalWrite(greenLEDpin, HIGH);
// log milliseconds since starting
uint32_t m = millis();
logfile.print(m); // milliseconds since start
logfile.print(", ");
#if ECHO_TO_SERIAL
Serial.print(m); // milliseconds since start
Serial.print(", ");
#endif
// fetch the time
now = RTC.now();
// log time
logfile.print(now.get()); // seconds since 2000
logfile.print(", ");
logfile.print(now.year(), DEC);
logfile.print("/");
logfile.print(now.month(), DEC);
logfile.print("/");
logfile.print(now.day(), DEC);
logfile.print(" ");
logfile.print(now.hour(), DEC);
logfile.print(":");
logfile.print(now.minute(), DEC);
logfile.print(":");
logfile.print(now.second(), DEC);
#if ECHO_TO_SERIAL
Serial.print(now.get()); // seconds since 2000
Serial.print(", ");
Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.print(":");
Serial.print(now.second(), DEC);
#endif //ECHO_TO_SERIAL
float volt = (sensorValue *4.5)/1024.0;
float voltADC = ((float)sensorValue/1024.0) *5;
float psi = (scale*volt)+(float)offset;
Serial.print(sensorValue);
Serial.print(", ");
Serial.print(volt);
Serial.print(", ");
Serial.println(psi);
delay(1); // delay in between reads for stability
}