Liquid level sensor


#1

My project involves a water tank (5 gal bucket now and maybe a large pickling barrel later) which supplies water for a pump. I have seen some liquid level sensors online but I do not want to pay $25-35 for one of these. All I need is a sensor to notify the photon when water has diminished to a certain level. Does anyone have any ideas on how to make this or a cheaper sensor that I could buy and modify to do this?

Thanks


#2

Water conducts electricity, so you could make a simple digital switch using water and two probe wires at the level you want to test for. (Just make sure the probes are sealed in.) When the switch reads LOW, the wires would no longer be conducting with the water so the water would be below that point.


Ultrasonic sensor JSN-SR04T to Electron
#3

could you show me a quick schematic of this setup?


#4
     ========                =======
     =Photon=                = Water
     =     D0----------------= Probe
     =     GND---------------= Probe

Something like this. If you made each of the probes come in at the same height on the bucket.


Ultrasonic sensor JSN-SR04T to Electron
#5

thank you!


#6

Good luck with your project!


#7

are you familiar with monitoring voltage from a 12V battery with a photon?


#8

Not really, and you should keep that discussion on your other post.


#9

Technically, it doesn’t. Pure water is an insulator, and the conductivity varies wildly. Seeing as real life isn’t perfect, it’ll probably conduct though.

That said, why not use a float switch? They’re cheap, easily accessible, and simply to use.


#10

@Moors7 is correct about the conductivity of water. You might want to play around with your probes and a multimeter before getting too committed. You’d be surprised at how little clean water actually conducts.


#11

I am making the assumption that @jonmlewis is not using pure water. A float switch would probably be a better option.


#13

You could also use one of these distance sensors to measure the height of the water from the top of the bucket. Just keep water off the sensor via some sort of rig which shouldn’t be too hard to figure out.


#14

I don’t think the circuit provided by @nrobinson2000 is going to work; there’s no power source there so what would you be measuring? I have made a water level detector with a Photon, using a voltage divider circuit, like you have in your other post. The probes act as one of the resistors of the divider, and the actual resistor needs to be quite large, in the megohm range. I got a significant change in readings between the probes being in or out of my tap water. I just used some tinned connection wire as my probes.


#15

@Ric You are correct. My circuit is wrong.


#16

you could try an old spark plug mounted horizontally through the side of the tank.


#17

could you send a link to that if you have it? This is what I have so far.


#18

I’d also vote for the Float Switch. I’ve used Stainless Steel Float Switches that cost $5-$8.

But you can also use 2 wires connected to a Digital Pin and Ground.
The code below triggers when TAP Water reaches both wires, you would want to modify.

/*
Simple Script to monitor 2 wires instead of a float Switch for High Water Alarm   
INSTRUCTIONS:   Connect 1 wire to Ground and the other wire to Digital Pin 6.  You're Done!  Place both wires in the Container (say 1" apart).  Alarm condition when water reaches both wires.
*/

#define alarm_delay        2000    
unsigned long previousMillis;
unsigned int lastAlarm = 0;  
int Water = D6;   // 2 wire "Switch" will be connected to Ground and Digital Pin 6
int Switch = 1;   // Set to HIGH for startup (High Signal means the Switch is hanging in air- "no water".  We dont want a false alarm at system startup.

void setup() {
    pinMode(Water, INPUT_PULLUP);   // Bring the pin HIGH. The circuit will be grounded when the Switch CLOSES (when water reaches the 2-Wires) and pull D6 LOW.
    Serial.begin(9600);
}
 
void loop()  { 
    
    Switch = digitalRead(Water);
    if (Switch == 0)  { // 0 is LOW, so the circuit was grounded by the 2-Wire float switch (HIGH WATER Condition)
        unsigned long now = millis();
        if ((now - lastAlarm) > alarm_delay)  {
            Particle.publish("ALARM", "HIGHWATER"); // Water has reached the 2 wires.
            lastAlarm = now;
        }
    }
    delay(100);
}  
              

  

#19
#define alarm_delay        2000    
unsigned long previousMillis;
unsigned int lastAlarm = 0;  
int Water = D6;   // 2 wire "Switch" will be connected to Ground and Digital Pin 6
int Switch = 0;   // Set to HIGH for startup (High Signal means the Switch is hanging in air- "no water".  We dont want a false alarm at system startup.

void setup() {
    pinMode(Water, INPUT_PULLUP);   // Bring the pin HIGH. The circuit will be grounded when the Switch CLOSES (when water reaches the 2-Wires) and pull D6 LOW.
    Serial.begin(9600);
}
 
void loop()  { 
    
    Switch = digitalRead(Water);
    if (Switch == 1)  { // 0 is LOW, so the circuit was grounded by the 2-Wire float switch (HIGH WATER Condition)
        unsigned long now = millis();
        if ((now - lastAlarm) > alarm_delay)  {
            Particle.publish("ALARM", "LOWWATER"); // Water has reached the 2 wires.
            lastAlarm = now;
        }
    }
    delay(100);
}

I changed your code to this and it seems to work great. I really appreciate the help!


#20

Resistance and capacitance are both frequently used to detect liquids and are reliably used for that in the food industry. When applying a DC voltage to water however you are likely to see buildup on the sense electrodes as charged particles get attracted to them. To avoid it these resistance circuits usually use an AC signal, you can probably find a few examples online if you look hard enough.

Other methods include a load cell or liquid level eTapes both of which could tell you how much liquid is in your bucket. As could a pressure sensor…

As mentioned above there are also distance sensors both sonic and optical you could probably employ as well if you were feeling adventurous.

The simplest answer is always going to be a float however


#21

You’re very welcome. I still suggest a $8 Float Switch. The Float Switch will work with the same code. Just use the “wires only” to get you started and testing. Also, these floats can be swapped from Normally Open/Closed by removing the ball and flipping it upside down on the shaft. They are extremely useful.