Jump to content

Banner.jpg.b89429c566825f6ab32bcafbada449c9.jpg

Water Level Gauge for the "Sump" Below my Observatory


Gina

Recommended Posts

  • Replies 148
  • Created
  • Last Reply

Getting pretty close to testing the whole system now.  Been working on the display unit - servo and capacitor soldered onto the Arduino Nano.  I bought a handful of Nanos at a couple of quid each with the pins separate and not soldered in which means I can connect directly to the PCB.  I have yet to print the pointer but that's a detail.  Taking a little break ATM with a cuppa and watching Sir David Attenborough on TV - relaxing.

Link to comment
Share on other sites

Tested both units and all seems well - just need to calibrate the sensor for the appropriate water levels.  That needs doing in the observatory with sensor unit under the floor connected to laptop above.  Might be able to do that tomorrow morning before the rain comes in again in the afternoon - maybe...

This is the sender unit sketch.

/*
 File name :- HC-SR04_Ping_distance_sensor_mm_for_little_pump_03    2016-01-25 2112
 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 = 500; // Maximum range needed
int minimumRange = 170; // 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 = 400, pumpStop = 425;
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 / 2;
 analogWrite(5, outPWM);
 }
 
}

And this is the receiver sketch.

#include <Servo.h>

int analogPin = 7;
int sumpEmpty = 0;    // angle of servo for sump empty (degrees)
int val, 
depth;

Servo myservo;  // create servo object to control a servo

void setup() {
  Serial.begin (9600);
  myservo.attach(9);             // attaches the servo on pin 9 to the servo object
  myservo.write(sumpEmpty);      // sets the servo position to sumpEmpty
}
void loop() {
  val = analogRead(analogPin);   // read the input pin - range 0-1023
  depth = 1023 - val;
  myservo.write(val / 6);        // sets the servo position to indicate water level - 0-180 - divisor = 5.7
  Serial.println(val);

} 

 

Link to comment
Share on other sites

Hmmmmpppffff....  Rain has arrived several hours early - typical!!  Oh well, I shan't be doing outside stuff today - not to worry - some other time then...  Blowing a gale too.  Guess I can get on with the receiver and display unit or just "chill out" :hiding:

Link to comment
Share on other sites

Thank you Stu.  Yes, I think so.  Well, apart from sorting out something to sell, that is...  May even leave that though and do some water colour painting :icon_biggrin:

Link to comment
Share on other sites

I found this thread really interesting and inspiring! :) 

If one day, I will create my own observatory on the Dolomites or somewhere else, I will go through all your lessons. 

Wish you all the best with your new kit, Gina! Hopefully the rain will stop soon!

Piero

Link to comment
Share on other sites

Been out to the observatory this morning while it was only drizzling and checked measurements.  Also, noticed that the bilge pump had been working and water was a few inches deep but an inch or so below the bottom of the beams - we had a lot of rain yesterday and overnight.  Distance from under floorboards to bottom of hole is 18" (450mm), distance floorboards to piece of wood with bilge pump on is 16".  The water level sensor will be mounted on a noggin just above the pier base with the bottom and sensor reference slightly above the bottom of the noggin.  Approx. 100mm (4") below underside of floorboards.

Compared with reference level, bottom of hole is 450mm - 100mm = 350mm distance.  Outside ground level is about 250mm below underside of floorboards so water shouldn't ever rise above 150mm below reference level.  I'll allow 50mm safety margin giving a minimum distance of 100mm.  Range is thus 350mm to 100mm = 250mm.  That's convenient - I can use millimetres.  Output voltage from sender unit will go from 0v to +5v and 0-255 on the PWM output.  If I make 0 = 0v = 100mm, then 350mm (empty) becomes 250 = 4.9v.  A reading of 0v at the receiver would represent a water level 50mm above maximum or an open circuit cable.

Here are a couple of diagrams showing the hole plus scope room floor, pier base and ground.  Firstly a roughly E-W cross-section and secondly a roughly N-S cross-section.  Roughly to scale vertically but not to scale horizontally.

56a8b63f96819_HoleDiagram01.thumb.JPG.d056a8b64118065_HoleDiagram02.thumb.JPG.a8

Link to comment
Share on other sites

Further to tha above...  Bilge pump start should be at roughly 45mm above its base = 95mm above bottom of hole = 255 - 95 = 160 PWM units = 3.14v.  Bilge pump stop should be at roughly 25mm above its base = 75mm above bottom of hole = 255 - 75 = 180 PWM units = 3.53v.

For the little pump I can decide at what level it operates and I'm thinking start at 40mm and stop at 20mm above bottom.  The pump can go in the bottom of the hole 350mm distance from sensor so start at 310mm and stop at 330mm.

Link to comment
Share on other sites

Amended sketch for sender unit.

/*
 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 = 310, pumpStop = 330;
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

Raining this afternoon but thats's not stopping progress :icon_biggrin:  I've found something to fix the bilge pump - I was looking for wood but found a 20" long piece of builders bar - galvanised iron about and inch or so wide and 1/8" thick with lots of holes for fixing.  Managed to bend it to a right angle with around 16" and 4" parts.  I can screw the pump base wooden block to the short side and the other end to the noggin above the pier base.  Rather crude but should be adequate and nobody but me will see it :happy8:

I also plan to sort out connectors for the sender unit - just 4 wires - +12v, Gnd, Line, Line return.  I think I'll divide the CAT5 cable into its 4 twisted pairs with just one going to the water level sender unit.  The others will go to weather sensors and roof control I expect.  With the low cost of Arduino Nanos there's no point in struggling to get the best out of each unit.

I can also work on the indoor receiver and display unit.  I will need to drill a hole through the house wall to feed the CAT5 cable in.  That's about half inch concrete at the thinnest part of the pre-cast wall sections.  I have some masonry drills.  Then some sort of box to take the Arduino Nano receiver unit and micro servo motor, a 3D printed pointer and a dial printed in colour on my ordinary 2D on paper printer.

Link to comment
Share on other sites

Oh yes, very last century I'm afraid :tongue2:  One day I hope to have a multi-colour, multi-nozzle 3D printer but I'm afraid that's going to be quite a bit into the future...  I'm just idling at present, my energy is at a very low ebb...

Link to comment
Share on other sites

Nice sunny morning today - yes, real sunshine :icon_biggrin:  Cold though with a ground frost.  Should be all systems go for installation of the water level sender unit and pumps :icon_biggrin:

Link to comment
Share on other sites

Here's a new diagram.  May do one or two more later.

56aa152d1687d_HoleDiagram03.thumb.JPG.c4

 

And here are some photos.  I've moved the bilge pump out of the way ready for preparing the site and installing again with the other bits.

56aa155dcaf46_Hole05.thumb.jpg.19cf1326156aa1561a2b94_Hole06.thumb.jpg.5e538e74156aa1564154b4_Hole07.thumb.jpg.344344893

Link to comment
Share on other sites

It's amazing how long everything takes me these days :(  I've just finished fitting a 4w connector to the box and drilled two holes for fixing screws plus some sponge plastic - how can such simple things take a couple of hours ?!  I'm still hoping to have the pumps and control unit fitted today.  But I'm not guaranteeing it - oh no!!!!

56aa2ae89c398_WaterLevelControlUnit06.th

Link to comment
Share on other sites

Well...  Not bad :icon_biggrin:  Pumps installed, water level sensor unit screwed to joist and unit tested with laptop :)  Finished out in the cold observatory for today :icon_biggrin:

Here are some photos.

56aa4b80a8184_WaterLevelSensorUnitPumps0

56aa4b83c3a60_WaterLevelSensorUnitPumps0

56aa4b870496b_WaterLevelSensorUnitPumps0

56aa4b89dec84_WaterLevelSensorUnitPumps0

56aa4b8dbcf18_WaterLevelSensorUnitPumps0

56aa4b910489d_WaterLevelSensorUnitPumps0

56aa4b94601d8_WaterLevelSensorUnitPumps0

 

Link to comment
Share on other sites

Thanks Ed :)  If the electronics fails I should know and the bilge pump acts as a backup.  If the little pump fails the dial should show it and again the bilge pump should operate when the water level gets higher.  If I had the energy I would work on the display... but I haven't and have finished for the night.  Tomorrow is another day :)  I've found the masonry drills for the hole in the wall. 

Still to do (and estimated time) :-

  1. Solder wires onto plug for sensor unit (2 hours)
  2. Drill hole in house wall for cable (2 hours)
  3. In observatory (weather permitting), connect wires to power supply and CAT5 twisted pair. (2 hours)
  4. Hardware for display (2 days)

I may manage some of those tasks in less than the estimated time but don't bank on it  :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.