Author Topic: Moteino Liquid Level Sensor using eTape  (Read 3878 times)

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Moteino Liquid Level Sensor using eTape
« on: May 04, 2016, 03:23:37 PM »
Here is a mote I've had running for about 2 years with two sets of 2 x AAA batteries.  The first set expired fairly quickly as I hadn't refined my power management SW well enough.  The second set lasted well over a year.   The code has not yet been updated to Listen Mode code where I would expect longer battery life than the environmental life of a Mote mounted inside a PVC tube stuck in my stream.

Circuit description:

This uses a standard Moteino R4 that has been modified to remove the voltage regulator and reprogram the fuses to use the internal 8MHz RC oscillator.  This particular mote DOES have the standard winbond flash chip installed and uses an RFM69HW operating at 433MHz.  Nominal reporting interval is 10 minutes with the Mote in WDT sleep loop otherwise.  Not very aggressive, but the sensor is very low power as implemented.

The key to this implementation is recognizing that the eTape has two sets of sensor pins.  The middle two pins provide a resistance proportional to the height of liquid pressing on the tape.  The higher the liquid, the lower the resistance.  I have a 12 inch tape and it is nominally around 2.3K with no liquid.  The two outer pins are a reference resistance that does not vary and is equal to the 'dry' resistance of the middle two pins.

The main part of the circuit is U1 which is a monolithic current mirror.  Any current drawn from the collector/base junction will be reflected in the other collector.  The common emitters are tied to VDD (the two AAA batteries).   Q1 is turned on when a measurement is to be made and this grounds the two lower pins of the eTape sensor causing current to flow into both paths.  Because of the current mirror, the current is equal (more or less but this is beyond the scope of this introduction) and therefore, the voltage measured on the level sense pins is proportional to its resistance and the voltage on the reference sense pin.  This brings us to U2.  This is a low power Op Amp used as a voltage follower to buffer the reference voltage into the ARef pin.

So, given this description, it should be obvious to ALL AVR users that the voltage measured at A0, using ARef as the reference to the ADC, will yield a number from 0-1023 that is EXACTLY proportional to the liquid level measured from the BOTTOM of the eTape.  Note that the eTape does not measure anything below 0.700 inches so the full measurement range is only 11.3 inches.

I can post the eagle files if anyone is interested...


Tom


G550_Pilot

  • Full Member
  • ***
  • Posts: 151
  • Country: us
Re: Moteino Liquid Level Sensor using eTape
« Reply #1 on: May 04, 2016, 03:32:36 PM »
Tom -

Can I get your sketch to look over? Also, the new eTape only has three pins, not 4 so I am not sure this would work for me.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Moteino Liquid Level Sensor using eTape
« Reply #2 on: May 04, 2016, 03:38:33 PM »
Tom -

Can I get your sketch to look over? Also, the new eTape only has three pins, not 4 so I am not sure this would work for me.
You can't have the sketch because it is mostly all my infrastructure code, but here is the sampling code:
Code: [Select]
#define SCALE_OFFSET   700UL       // beginning of reading @ 0.700 inches
#define SCALE_MULT   11300UL      // amount of scale to reach 12.000 inches
#define SCALE_DIV         872UL      // divisor to convert reading to inches (872 over the 11.300 inch range)
unsigned long measure=0;
...
/******************************************************************************
*
*   readLiquidLevel()
*
******************************************************************************/
void readLiquidLevel(void) {
  unsigned int reading;

  analogReference(EXTERNAL);
  digitalWrite(VSenseEnable, HIGH);  // turn on the Amp and Sensor
  delay(20);
  reading = analogRead(VSensePin);
  digitalWrite(VSenseEnable, LOW);
 
  diff=1023-reading;
  measure = (((unsigned long)diff*SCALE_MULT)/SCALE_DIV)+SCALE_OFFSET;

}

I would expect the third pin is common so would still work with this circuit (Q1 drain connection).  eTape told me about the new connector after I complained about the leakage.  Let us know if it works.

Tom
« Last Edit: May 04, 2016, 03:49:42 PM by TomWS »

G550_Pilot

  • Full Member
  • ***
  • Posts: 151
  • Country: us
Re: Moteino Liquid Level Sensor using eTape
« Reply #3 on: May 04, 2016, 09:07:41 PM »
Thanks Tom, your setup seems a lot more complicated than mine so for now I will stick with trying to see what is sucking my battery dry :-)

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Moteino Liquid Level Sensor using eTape
« Reply #4 on: May 05, 2016, 08:24:02 AM »
Thanks Tom, your setup seems a lot more complicated than mine so for now I will stick with trying to see what is sucking my battery dry :-)
You need to sleep everything and keep all sensors very low power or even cut power to them when not in use. That's really the main thing that dries your batteries.

SaffellBot

  • NewMember
  • *
  • Posts: 9
  • Country: us
Re: Moteino Liquid Level Sensor using eTape
« Reply #5 on: May 05, 2016, 10:21:18 AM »
Tom,

Can you post the circuitry? It was a little hard to digest for me mentally, my transistor theory is a bit rusty.

One of the biggest prolems with arduino's is the measurement of resistive sensors. It's nearly impossible to use the full range of the ADC. This results in very poor resolution that requires a ton of filtering to account for. In low power scenarios that filtering is expensive.

If I'm understanding the way your setup works it sounds like am amazing way to measure any resistive element (photo resistor, thermistor, etc) at a high resolution and at low power.

G550_Pilot

  • Full Member
  • ***
  • Posts: 151
  • Country: us
Re: Moteino Liquid Level Sensor using eTape
« Reply #6 on: May 05, 2016, 12:33:42 PM »
Tom,

Can you post the circuitry? It was a little hard to digest for me mentally, my transistor theory is a bit rusty.


Hi SaffellBot -

Looks like Tom posted a PDF of his circuit on the first post.

Cheers

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Moteino Liquid Level Sensor using eTape
« Reply #7 on: May 05, 2016, 02:55:05 PM »
Tom,

Can you post the circuitry? It was a little hard to digest for me mentally, my transistor theory is a bit rusty.
I did post the pdf, but attached is a zip file with the Eagle files.  Note that this was implemented on a PCB with another circuit so the PCB dimensions are about 2X the size needed for the liquid level sensor.
Quote
One of the biggest prolems with arduino's is the measurement of resistive sensors. It's nearly impossible to use the full range of the ADC. This results in very poor resolution that requires a ton of filtering to account for. In low power scenarios that filtering is expensive.

If I'm understanding the way your setup works it sounds like am amazing way to measure any resistive element (photo resistor, thermistor, etc) at a high resolution and at low power.
You are right, if you don't use the ARef input, it is very difficult to get a full range reading and, given the relatively low input resistance of ARef pin, you need the voltage follower Op Amp for any circuit with any appreciable source resistance. 

The circuit will do as you say, if you put a fixed resistor that matches your highest resistance of your sensor in the reference leg, then you will get a reading proportional to the sensor resistor value.   Bear in mind that this is not perfect.  The current mirror's gain will vary with temperature and definitely will not track if the temperature is different at each junction.  Also, if there is any variation between the two transistors in doping or area the gains will be different and you will not get a true current mirror.  Fortunately, this device being monolithic reduces the sensitivity to these issues somewhat.  The spec has a surprisingly large mismatch, but I have found the device matches well enough for this application.  YMMV...

Alternative circuits include creating a wheatstone bridge of the reference and sensor resistors, but then you'll need a decent differential amplifier with calibrated gains and offsets (at least 3 op amps and a pile of resistors).

Tom

SaffellBot

  • NewMember
  • *
  • Posts: 9
  • Country: us
Re: Moteino Liquid Level Sensor using eTape
« Reply #8 on: May 05, 2016, 04:33:06 PM »
Thanks for all your hard work on this site by the way.

Sorry I missed the attachment, that link is tiny of mobile. This seems like a pretty great approach though. I went be able to test it out until I get my setup a little further, but it seems a lot better than trying to mane a wheatstone or some other more complex method.