Author Topic: Sump pump mote erratic readings  (Read 201 times)

brasskey4u

  • Newbie
  • *
  • Posts: 15
Sump pump mote erratic readings
« on: December 14, 2018, 06:29:19 PM »
I have the sump pump mote and seem to have very erratic readings.  Not sure if its a placement thing or what.  Also, if I get the sensor out and manually move it so that it triggers an event, moving it back to a range that does not cause an event doesn't seem to allow the sensor to read without powering it off and on.  Is that by design?  Attaching a picture of my graph.  Sometimes the value jumps 10 cm in one second with no water flowing.  My only other idea is the water dripping into the pit is causing ripples in the water and perhaps some sort of reflection.  Lastly (Geeze, does this guy shut up?)  ;D   Can the software be changed to show inches instead of cm?  I never learned the metric system! LOL..

Dave

HeneryH

  • Full Member
  • ***
  • Posts: 208
Re: Sump pump mote erratic readings
« Reply #1 on: December 14, 2018, 06:46:27 PM »
For the easy part...

There are two functions in the sketch for distance:

Code: [Select]
float microsecondsToInches(long microseconds)
{
  // According to Parallax's datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance travelled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
  return microseconds / 74.0 / 2.0f;
}

float microsecondsToCentimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return (float)microseconds / 29.0f / 2.0f;
}

and the current code is set to call call the metric one
Code: [Select]
float readDistance(byte samples)
{
  if (samples == 0) samples = 1;
  if (samples > 10) samples = 10;
  digitalWrite(SENSOR_EN, HIGH);
  //need about 60-75ms after power up before HC-SR04 will be usable, so just sleep in the meantime
  LowPower.powerDown(SLEEP_60MS, ADC_OFF, BOD_OFF);
  LowPower.powerDown(SLEEP_15MS, ADC_OFF, BOD_OFF);
  PING();
  LowPower.powerDown(SLEEP_15MS, ADC_OFF, BOD_OFF);
 
  unsigned long duration = 0;
  for (byte i=0; i<samples; i++)
  {
    duration += PING();
    if (samples > 1) LowPower.powerDown(SLEEP_15MS, ADC_OFF, BOD_OFF);
  }
  digitalWrite(SENSOR_EN, LOW);
  return microsecondsToCentimeters(duration / samples);
}

and in the gateway metrics.js file you have the metric defined:
Code: [Select]
  //SonarMote
  sonar : { name:'CM', regexp:/\b([\d\.]+)cm?\b/i, value:'', unit:'cm', pin:1, graph:1,  graphOptions: { legendLbl:'Level', lines: { lineWidth:1 }, colors:['#09c']} },

Kilo95

  • Sr. Member
  • ****
  • Posts: 303
  • Country: us
Re: Sump pump mote erratic readings
« Reply #2 on: December 16, 2018, 12:49:55 PM »
My water softener backwashes into the sump. I have a clear shield over my sump pump with the Sonar mote sensors sticking through the cover. I find some corrosion on the Sonar sensor parts that are sticking through into the pit after a few months. I just replace my sonar sensor when it does this. I have also found that my sonar sensor has a fairly wide "field of view" and there's only one spot I've found in my sump that it'll read down to the water. Also, I've occasionally found a spiderweb  in the way when mine gets erratic.

brasskey4u

  • Newbie
  • *
  • Posts: 15
Re: Sump pump mote erratic readings
« Reply #3 on: December 16, 2018, 01:16:45 PM »
OK, I am playing with the placement of the sensor to see if that fixes the problem.  I've commented out this section:

  //SonarMote
  sonar : { name:'CM', regexp:/\b([\d\.]+)in?\b/i, value:'', unit:'in', pin:1, graph:1,  graphOptions: { legendLbl:'Level', l
ines: { lineWidth:1 }, colors:['#09c']} },


Also changed the metrics.js to "in" everywhere CM was, and it still shows CM.

 //SonarMote
  sonar : { name:'IN', regexp:/\b([\d\.]+)in?\b/i, value:'', unit:'in', pin:1, graph:1,  graphOptions: { legendLbl:'Level', l
ines: { lineWidth:1 }, colors:['#09c']} },


I'm sure its a simple case of "you don't know , what you dont' know".  And clearly I don't know! :)



HeneryH

  • Full Member
  • ***
  • Posts: 208
Re: Sump pump mote erratic readings
« Reply #4 on: December 16, 2018, 01:23:27 PM »
I'm sure its a simple case of "you don't know , what you dont' know".  And clearly I don't know! :)
You need to

1) change the sketch readDistance() function to call the inches function rather than the cm function.
2) change the metrics.js as you've already done

restart the gateway service.

sparky

  • Full Member
  • ***
  • Posts: 244
  • Country: us
Re: Sump pump mote erratic readings
« Reply #5 on: December 16, 2018, 05:45:22 PM »
OK, I am playing with the placement of the sensor to see if that fixes the problem.  I've commented out this section:

  //SonarMote
  sonar : { name:'CM', regexp:/\b([\d\.]+)in?\b/i, value:'', unit:'in', pin:1, graph:1,  graphOptions: { legendLbl:'Level', l
ines: { lineWidth:1 }, colors:['#09c']} },


Also changed the metrics.js to "in" everywhere CM was, and it still shows CM.

 //SonarMote
  sonar : { name:'IN', regexp:/\b([\d\.]+)in?\b/i, value:'', unit:'in', pin:1, graph:1,  graphOptions: { legendLbl:'Level', l
ines: { lineWidth:1 }, colors:['#09c']} },


I'm sure its a simple case of "you don't know , what you dont' know".  And clearly I don't know! :)

I don't know if this is the correct way to do it but it work's (kinda);

Here is the change in the metrics.js
Code: [Select]
sonar : { name:'IN', regexp:/CM\:([\d\.]+)/i, value:'', unit:'in', pin:1, graph:1,  graphOptions: { legendLbl:'Level', lines: { lineWidth:1 }, colors:['#09c']}, duplicateInterval:3600, valuation:function(value) {return value*.39;}, graphOptions: { legendLbl:'Level', lines: { lineWidth:1 }, colors:['#09c']} }, 

The problem was every once in awhile it would display the number which went out about 7 decimal places.  I'm sure that could be resolved using ".toFixed(2)" (without the quotes) which Felix used for temperature just the other day.  I tried but couldn't get the syntax correct.

Edit:  Here is the thread he used .toFixed(2)
https://lowpowerlab.com/forum/pi-gateway/issue-with-gateway-when-converting-fahrenheit-to-celsius/
« Last Edit: December 16, 2018, 05:56:31 PM by sparky »

brasskey4u

  • Newbie
  • *
  • Posts: 15
Re: Sump pump mote erratic readings
« Reply #6 on: December 24, 2018, 11:59:26 AM »
Still no luck with getting this to work with inches.   :-[ >:(   Guess its why I am not a programmer.

sparky

  • Full Member
  • ***
  • Posts: 244
  • Country: us
Re: Sump pump mote erratic readings
« Reply #7 on: December 24, 2018, 12:18:00 PM »
Did you read my post?