Jump to content

Banner.jpg.b89429c566825f6ab32bcafbada449c9.jpg

Water Level Gauge for the "Sump" Below my Observatory


Gina

Recommended Posts

Item 1. above - solder wires onto plug for sensor unit - completed in half an hour :)  I've also been out to the observatory and checked everything - sump empty but damp.  In fact the weather is damp - not quite a drizzle but decidedly damp.

Link to comment
Share on other sites

  • Replies 148
  • Created
  • Last Reply

Thanks :)

I'm now working on the wall :Envy:  Since the thicker bits can only be seen from the inside, I started by cutting a hole in the plasterboard on the living room side of the wall, beginning with a small hole to check I was at a reasonable position.  Then I cut a larger hole, big enough to get my mains hammer drill into.  I estimate the concrete as about 12mm thick and I have now got a 6mm hole about 9mm deep and taking a break - it's hard work - those concrete sections are really tough.  I think I may change down to a 4mm masonry bit to break through then finish off with the 6mm.  I think 6mm will take the CAT5 cable but if not I can open up to 7 or 8mm.

It's still raining :(

A bit later... Resumed drilling and measured depth with digital caliper and the hole is 14.3mm deep.  So much for the concrete being 12mm thick - this section evidently isn't :(

Link to comment
Share on other sites

Fine and sunny this morning but now clouding up again.  Very muddy after yesterday's and overnight rain and I nearly went A over T going to the observatory :( Good job my balance is still good :)  Water level was up to bilge pump which was running every so often clearing water, so just right for testing :) Connected power and line then plugged in and switched on.  Arduino detected high water level and duly turned the little pump on.  After a couple of minutes it had reduced the water level and switched off :)  After that I watched it for a while as the sump gradually filled and the little pump turned on, dropped the water level and turned off.  I continued watching while it worked for several cycles.

RESULT :- Pump control is working perfectly :icon_biggrin:  Next to connect up to the receiver unit...

Link to comment
Share on other sites

Been out to the observatory and checked things - all well but little pump was sucking air at the stopping point.  It did stop but it's a bit too near not switching off at all so I raised the stop level a bit.  I've also raised the start level but a bit less as the time the pump was running was quite short and I thought a slower cycle would be better.  Start level raised from 330 to 325 below sensor and stop level from 310 to 300.  Pump is now taking 30s to drop the water level from start level to stop level.

I decided to leave the laptop in the scope room reading the Serial Monitor and watching it over FreeView.

Here's the latest sketch.

/*
 File name :- HC-SR04_Ping_distance_sensor_mm_for_little_pump_04    2016-01-27 1315
 Test sketch sending output string to Serial Monitor.  Range 100-500 with 000 indicating error (out of range)
 Multiple readings taken to get average over 10 cycles
 Little pump is started and stopped at levels given by pumpStart and pumpStop on line 28.  Relative to bottom of control unit.
 Use editor to adjust these if required, recompile and upload.
 
 HC-SR04 Ping distance sensor:
 VCC to arduino 5v 
 GND to arduino GND
 Trig to Arduino pin 8
 Echo to Arduino pin 9 
 
 This sketch originates from Virtualmix: http://goo.gl/kJ8Gl
 Has been modified by Winkle ink here: http://winkleink.blogspot.com.au/2012/05/arduino-hc-sr04-ultrasonic-distance.html
 And modified further by ScottC here: http://arduinobasics.blogspot.com.au/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html
 on 10 Nov 2012.
 Adopted and modified by Gina January 2016.
 */
#define trigPin 3 // Trigger Pin
#define echoPin 2 // Echo Pin
#define LEDPin 13 // Onboard LED

int maximumRange = 355; // Maximum range needed
int minimumRange = 100; // Minimum range needed
long duration, distance; // Duration used to calculate distance
int cycles = 10; // Number of cycles of ping to accumulate average duration
int pumpStart = 300, pumpStop = 325;
boolean pumpRunning = false;
int outPWM = 0;

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)
}
//
void accumulateDuration() {
/* The following trigPin/echoPin cycle is used to determine the
 distance of the nearest object by bouncing soundwaves off of it. */ 
 digitalWrite(trigPin, LOW); 
 delayMicroseconds(2); 
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10); 
 digitalWrite(trigPin, LOW);
 duration = duration + pulseIn(echoPin, HIGH);
 //Delay 50ms before next reading.
 delay(50);
}
void loop() {
  duration = 0;
 for (int c = 0; c < cycles; c++) { accumulateDuration(); }
 duration = duration / cycles;
 //Calculate the distance (in mm) based on the speed of sound.
 distance = duration/5.82;

 if (distance >= maximumRange || distance <= minimumRange){
 /* Send a negative number to computer and Turn LED ON 
 to indicate "out of range" */
 Serial.println("000");
  analogWrite(5, 0);
}
 else {
  if ((distance < pumpStart) && !pumpRunning) { pumpRunning = true; Serial.println("Pump Started"); }
  if ((distance > pumpStop) && pumpRunning) { pumpRunning = false; Serial.println("Pump Stopped"); }
  digitalWrite(LEDPin, pumpRunning); 
/* Send the distance to the computer using Serial protocol, and
 turn LED OFF to indicate successful reading. */
 Serial.println(String(distance, DEC));
 outPWM = distance - 100;  //  max distance = 355 and min distance = 100.  Subtract 100 gives 0-255
 analogWrite(5, outPWM);
 }
 
}

 

Link to comment
Share on other sites

I've connected the receiver unit to the line and stuck a pointer on the servo motor.  It's moved a tiny bit since starting but there's very little change in water level in the hole - it's draining out (I arranged it as a soak-away) as fast as there's water coming in.  Pump will start when distance from sensor goes below 300mm and stop at 325.  Bottom of hole is at 350mm.  So ATM the water is about 45mm deep in the bottom of the hole.  If it rises around 5mm the pump should come on but I don't think that's going to happen until the rain starts again this evening.

56acf4e10f001_WaterLevelReadout01.JPG.1d

Link to comment
Share on other sites

No significant rain yet and the water is slowly draining from the sump and now giving a reading of 315mm below sensor = 35mm above bottom.  Pointer on dial is showing about 10mm below when I started the receiver, so that seems to be working.  I haven't yet printed the face for the dial with the calibration marks and colours.

Link to comment
Share on other sites

Pointer is now about 15° below horizontal which was set when I set up the receiver and water level was reading 305mm below sensor.  15° corresponds to 21.25mm according to my calculations (15 x 255 / 180) so the water level reading should be around 326mm.  Water level still going down - soaking away. Here is a screenshot of the water level readings on the laptop via FreeView.  This is showing that the water level dial is working well :)

56ad31802ec77_WaterLevelReadout02.JPG.15

Link to comment
Share on other sites

The sump is now fully drained and water level sensor is reading the ground level in the bottom.  As a sesult I have needed to adjust the measurement range to go up to 370mm with a minimum of 115mm to retain the range of 255mm.  Maximum water level if both pumps fail is still 150mm so there is still a saftey margin of 35mm.  115 is now subtracted from the distance value to give a range of 0-255 for the PWM output to the low pass filter and transmission line.  I have renamed the sketch to show this as the working version rather than testing.

/*
 File name :- Observatory_Sump_Water_Level_Unit_01    2016-01-31 1000
 Working sketch sending output string to Serial Monitor and analogue voltage to remote indicator unit.  Range 115-370mm with 000 indicating error (out of range)
 Multiple readings taken to get average over 10 cycles
 Little pump is started and stopped at levels given by pumpStart and pumpStop on line 28.  Relative to bottom of control unit.
 Use editor to adjust these if required, recompile and upload.
 
 HC-SR04 Ping distance sensor:
 VCC to arduino 5v 
 GND to arduino GND
 Trig to Arduino pin 8
 Echo to Arduino pin 9 
 
 This sketch originates from Virtualmix: http://goo.gl/kJ8Gl
 Has been modified by Winkle ink here: http://winkleink.blogspot.com.au/2012/05/arduino-hc-sr04-ultrasonic-distance.html
 And modified further by ScottC here: http://arduinobasics.blogspot.com.au/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html
 on 10 Nov 2012.
 Adopted and modified by Gina January 2016.
 */
#define trigPin 3 // Trigger Pin
#define echoPin 2 // Echo Pin
#define LEDPin 13 // Onboard LED

int maximumRange = 370; // Maximum range needed
int minimumRange = 115; // Minimum range needed
long duration, distance; // Duration used to calculate distance
int cycles = 10; // Number of cycles of ping to accumulate average duration
int pumpStart = 300, pumpStop = 325;
boolean pumpRunning = false;
int outPWM = 0;

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)
}
//
void accumulateDuration() {
/* The following trigPin/echoPin cycle is used to determine the
 distance of the nearest object by bouncing soundwaves off of it. */ 
 digitalWrite(trigPin, LOW); 
 delayMicroseconds(2); 
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10); 
 digitalWrite(trigPin, LOW);
 duration = duration + pulseIn(echoPin, HIGH);
 //Delay 50ms before next reading.
 delay(50);
}
void loop() {
  duration = 0;
 for (int c = 0; c < cycles; c++) { accumulateDuration(); }
 duration = duration / cycles;
 //Calculate the distance (in mm) based on the speed of sound.
 distance = duration/5.82;

 if (distance >= maximumRange || distance <= minimumRange){
 /* Send a negative number to computer and Turn LED ON 
 to indicate "out of range" */
 Serial.println("000");
  analogWrite(5, 0);
}
 else {
  if ((distance < pumpStart) && !pumpRunning) { pumpRunning = true; Serial.println("Pump Started"); }
  if ((distance > pumpStop) && pumpRunning) { pumpRunning = false; Serial.println("Pump Stopped"); }
  digitalWrite(LEDPin, pumpRunning); 
/* Send the distance to the computer using Serial protocol, and
 turn LED OFF to indicate successful reading. */
 Serial.println(String(distance, DEC));
 outPWM = distance - 115;  //  max distance = 370 and min distance = 115.  Subtract 115 gives 0-255
 analogWrite(5, outPWM);
 }
 
}

 

Link to comment
Share on other sites

I think I shall leave the laptop in the scope room to continue reading the Serial Monitor for a few days until I'm sure everything has settled down and I have seen the full range of normal water levels.  I can continue to compare the indicator reading with the actual distance in mm.  It doesn't look like I shall want the laptop for imaging for at least a week :clouds2:  I may leave the final mounting of the dial unit until I make the full wall display unit with wind speed and direction plus other weather data.

Link to comment
Share on other sites

Gina, I see we have another storm heading our way; Henry.  By the looks of things at the moment North Scotland is to feel the brunt of the wind but you may get a chance to test the sump pump for real.  It shouldn't be too bad in Devon, I think the term the weatherman used was blustery!  Don't you just love it, I bet no other country on Earth has as many ways of describing weather as the British.  Lol most of those ways would involve words that would break the forum's code of conduct:happy8:

 

Jim

Link to comment
Share on other sites

Thank you Jim :)  Hope your weather there is not too bad :) 

Raining here now but not heavy - it takes heavy rain to raise the ground water level above the bottom of the sump/soakaway.  The sump is currently empy according to the sensor and the dial is reading about 45° below horizontal corresponding to about 369mm below sensor.  Here's a screenshot.

56ae07b9a3d4c_WaterLevelReadout03.JPG.af

Link to comment
Share on other sites

This has really come together now for you Gina; being able to have a real time reading of the water level in the sump will give you a good bit of peace of mind.  Does the code/sketch give an audible high warning level warning through the laptop as well or just on the physical system itself?

Re Storm Henry, I think most of the really high wind will hit the far North (Highland and Islands).  I can't complain much as my little bit of Fife has escaped most of the really horrible stuff to date.  My faith hangs on those big heavy duty trailer latches you found last year:hello2:.  I have two holding the roof down at the moment, to be honest best bit of non astro astro kit I have bought in a way. I have a plan for a further two later on.

 

Jim

Link to comment
Share on other sites

Thank you Jim :)

No alarm on the laptop and that will be disconnected in a few days anyway.  No alarm indoors yet either but I'll add that when I make the wall display unit.

Link to comment
Share on other sites

With averaging 10 readings the values were varying rather a lot so I've increased it to 50 - this gives a reading about every couple of seconds - quite fast enough, and smoothed the values significantly.  That's what this "running in" period is about - testing operation and adjusting as required.

Link to comment
Share on other sites

A minor mod - if (distance >= maximumRange || distance <= minimumRange){  changed to if (distance > maximumRange || distance <= minimumRange){

This allows distance to be 370mm resulting in PWM value of 255.  Previously 370mm would produce an error condition.

this is the full sketch :-

/*
 File name :- Observatory_Sump_Water_Level_Unit_02    2016-01-31 2015
 Working sketch sending output string to Serial Monitor and analogue voltage to remote indicator unit.  Range 115-370mm with 000 indicating error (out of range)
 Multiple readings taken to get average over 10 cycles
 Little pump is started and stopped at levels given by pumpStart and pumpStop on line 28.  Relative to bottom of control unit.
 Use editor to adjust these if required, recompile and upload.
 
 HC-SR04 Ping distance sensor:
 VCC to arduino 5v 
 GND to arduino GND
 Trig to Arduino pin 8
 Echo to Arduino pin 9 
 
 This sketch originates from Virtualmix: http://goo.gl/kJ8Gl
 Has been modified by Winkle ink here: http://winkleink.blogspot.com.au/2012/05/arduino-hc-sr04-ultrasonic-distance.html
 And modified further by ScottC here: http://arduinobasics.blogspot.com.au/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html
 on 10 Nov 2012.
 Adopted and modified by Gina January 2016.
 */
#define trigPin 3 // Trigger Pin
#define echoPin 2 // Echo Pin
#define LEDPin 13 // Onboard LED

int maximumRange = 370; // Maximum range needed
int minimumRange = 115; // Minimum range needed
long duration, distance; // Duration used to calculate distance
int cycles = 50; // Number of cycles of ping to accumulate average duration
int pumpStart = 300, pumpStop = 325;
boolean pumpRunning = false;
int outPWM = 0;

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)
}
//
void accumulateDuration() {
/* The following trigPin/echoPin cycle is used to determine the
 distance of the nearest object by bouncing soundwaves off of it. */ 
 digitalWrite(trigPin, LOW); 
 delayMicroseconds(2); 
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10); 
 digitalWrite(trigPin, LOW);
 duration = duration + pulseIn(echoPin, HIGH);
 //Delay 50ms before next reading.
 delay(50);
}
void loop() {
  duration = 0;
 for (int c = 0; c < cycles; c++) { accumulateDuration(); }
 duration = duration / cycles;
 //Calculate the distance (in mm) based on the speed of sound.
 distance = duration/5.82;

 if (distance > maximumRange || distance <= minimumRange){
 /* Send a negative number to computer and Turn LED ON 
 to indicate "out of range" */
 Serial.println("000");
  analogWrite(5, 0);
}
 else {
  if ((distance < pumpStart) && !pumpRunning) { pumpRunning = true; Serial.println("Pump Started"); }
  if ((distance > pumpStop) && pumpRunning) { pumpRunning = false; Serial.println("Pump Stopped"); }
  digitalWrite(LEDPin, pumpRunning); 
/* Send the distance to the computer using Serial protocol, and
 turn LED OFF to indicate successful reading. */
 Serial.println(String(distance, DEC));
 outPWM = distance - 115;  //  max distance = 370 and min distance = 115.  Subtract 115 gives 0-255
 analogWrite(5, outPWM);
 }
}

 

Link to comment
Share on other sites

Well, building this seems to have stopped the very heavy rain for now though there is a small amount of water in the sump from recent moderate rain :icon_biggrin:  How long it will last remains to be seen, of course.  So far so good, a heavy rain deterrent but it needs something better...  Something that will stop the rain altogether and then go on to disperse the cloud :)  I took a look at my astro images in Pictures last night and reminisced on nice times in the distant past when astro imaging was possible and wondering if I will ever see such conditions again.  I think my glass is still half full :)  Just one problem - it's rainwater ... doh ...

Link to comment
Share on other sites

I seem to have lost the link from the sensor unit - the receiver is registering no volts.  The laptop in the scope room is showing a small amount of water in the sump and the sensor unit seems to be reading water level alright.  I'll have to go out tomorrow and see what's happened.  Not tonight because the ground is very slippery and I'm not going to risk it.

Link to comment
Share on other sites

Falling over in the dark on slippery grass is absolutely not worth it Gina, much better to retire to the warmth of indoors with a cupa and form a plan of attack for tomorrow. :happy7:  I liked your musings on coming up with a device to disperse the clouds altogether - crikey your not working on a thermonuclear bomb now Gina - and I thought your Moon Phase clock was challenging!

 

Jim

Link to comment
Share on other sites

Quite right Jim - about not risking falling on slippery grass I mean - no I'm not working on a bomb :Envy::icon_biggrin:  And yes, the moon phase clock certainly is challenging :D

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.