need help with voltage reading: ina219 + acs712?

hi everybody,
sorry if my english is not the best and more than that if my electronic/electrical skills are bare minimum..

i happen to live in a little house with a source of water under the basement and a pump has to take it and throw in the sewage (i live in the city so it is not safe to use this water since could be contaminated).. the pump works a few times per day for a bunch of minutes, more in winter time, less in summer time.

if the pump fails my basement get flooded and i want to avoid that as much as i can, so i built a very simple system that checks how often the pump works and i write that in simple db, so i also happen to have a bit of stats. i attached a magnetic switch to the end of the exit pipe: when the water flows activate the switch and i read the state with a arduino connected to a pc i use for various tasks.
this system is really basic and not precise at all, and i cannot monitor the level of the well. so i studied a more advanced system and here i need your help to make it work..

you can find the schematic attached:

  1. the pump :slight_smile:

  2. a water level sensor with a floating ball (originally, a tank meter for boats)
    https://www.accessorigommoni.it/pimages/INDICATORE-SERBATOIO-LIVELLO-CARBURANTE-CON-GALLEGGIANTE-UNIVERS-extra-big-1765-440.jpg

  3. the exit pipe with the magnetic switch attached
    https://ae01.alicdn.com/kf/HTB1W_.DfnXYBeNkHFrdq6AiuVXaa/1-pz-Nuovo-Grigio-Serbatoio-sensore-livello-acqua-Orizzontale-liquido-interruttore-galleggiante.jpg_640x640.jpg

  4. a very simple alarm system: if the water touches the tips of the wires, the alarm goes on. it is set at a level the water should never arrive. works with a 9v battery. wire e) is connected to battery and wire f) is connected to the alarm, when they touch the circuit closes and beeeeeeep

  5. the tank meter attached to 2) (works with 12v power supply). the wires goes like that: g) goes to 12v; h) goes to heart of the psu and c); d) goes to i)

  6. the brain of the project, nodemcu esp8266.. i'll use it wit arduino ide, and it is basically an arduino a bit less complete. works with 5v, i'll use the 12v power supply and a dc>dc converter. you can find info here: NodeMCU GPIO with Arduino IDE | NodeMCU

i would like to:

  • monitor the 2) level. it is possible to check the resistance or the voltage
  • monitor if the alarm 4) goes on
  • monitor the 9v battery voltage
  • monitor if the magnetic switch is closed or open

my concerns are from the multiple masses (battery, psu, arduino) and well, for the fact that i don't know where to start and i don't want to melt my poor arduino

other than that, i would love to be able to detect when the ac motor of the pump goes on (i have access to the 220v ac wires of the pump).

thanks for the help!!

The NodeMCU works with 3.3V, not 5V.

Start with one, then work from there. The hardest is going to be to monitor the 9V battery voltage level without draining the battery in the process.

Keep things simple.
I would detect if the basement is flooding just using a simple magnetic float switch like you have at point 3.
Just write a sketch for that with some print statements to start.
Once that works build things up from there.

You want to know if the motor is running and you have access to 220V AC pump supply. So what turns the pump on and off now? There must be a float switch or relay that does that. That switch/relay may have spare contacts that you can use to sense when the pump is being told to run (you need to investigate).

Remember that electricity and water do not mix. Paddling around in a flooded basement with 220V present could be dangerous.

the water sensor is already installed and, connected to the indicator, gives the reading in a visual way. i just have to sense how much voltage is between points h and i.
i was thinking of ina219..
for the water alarm, one of the 2 wires is connected to battery, the other is nc until the water touches the tips. my goal is to understand if the nc wire has voltage or not, and i can use the ina219 module..

for the ac pump, i have access to the 220v connector in the wall, but not to the float switch, which is completely sealed and i will not touch it obviously.

i am quite aware of the dangers, but the setup should be secure enough: no electricity goes in the water, except the 9v alarm wires tips and the water level resistance, which if is flooded simply has resistance = 0 and the meter will show full tank (already tried).
all the electronics, power supply and ac pump connector are at 1mt over the floor (water will not arrive at this point.. hopefully :D) and is protected with magnetothermic safe switch.

i didn't think about the battery drain, but if the wire is not connected until it touches the water shouldn't be a problem i guess..

i'll try to draw a schematic better the the sh*t i posted :slight_smile:

To measure battery voltage, you have to connect something across the poles of the battery. This something will draw some current to do its measurement, the point is to keep this current so small it's insignificant.

The ina219 will not do as it's a CURRENT sensor and you're looking for a VOLTAGE sensor.

You could detect current flowing to the pump using this;
http://henrysbench.capnfatz.com/henrys-bench/arduino-current-measurements/acs712-arduino-ac-current-tutorial/
However that involves tapping into the mains supply, which you may not want to do.

If the pump is not submerged then you could perhaps attach an encoder or use a hall effect sensor to detect the pump shaft rotating.

You are not actually going to get a resistance of 0 Ω even with salt water. The resistance will vary with the water purity. Your metal contacts are also going to corrode or get fouled so the resistance will change with time even if the water quality is constant.

Float switches of the type already used to turn the pump on and off are cheap and reliable. I would keep things simple and use one to give me a "high" alarm and another for a "high high" alarm. The switches would be normally closed and would open as the water level rose, which would help me to detect faulty switches and or wiring.

wvmarle:
To measure battery voltage, you have to connect something across the poles of the battery. This something will draw some current to do its measurement, the point is to keep this current so small it's insignificant.

The ina219 will not do as it's a CURRENT sensor and you're looking for a VOLTAGE sensor.

ok, i'll leave out the battery monitor if it will suck energy from her, was just a plus to the project. battery is there from 2 years and still good, and it is a secondary alarm that i want to keep in case arduino dies.
ina219 seems to be a voltage sensor too, i found a lot of projects that read voltage.

ardly:
You could detect current flowing to the pump using this;
http://henrysbench.capnfatz.com/henrys-bench/arduino-current-measurements/acs712-arduino-ac-current-tutorial/
However that involves tapping into the mains supply, which you may not want to do.

If the pump is not submerged then you could perhaps attach an encoder or use a hall effect sensor to detect the pump shaft rotating.

the pump is submerged and i cannot for any reason touch the floating switch, so it has to be with acs712. no problem for me to tap into the ac wires, i'll use all the correct attention (i am a bit bad with electronics, but i understand electricity at a reasonable level and i work quite clean and precise).

i made a little schematic with fritzting, i'm really bad but i hope that is a bit more clear..
i need to read voltage from wires A and B, i won't use resistance in any part of the project, just voltage.
i also need to understand when C starts and i have access to the wall socket.
my problems are in understanding how to connect everything together, and obviously if it could work.

Have you considered configuring a distance sensor with the Arduino for non-contact measurement of the water sump level? In this way you would appear to eliminate the battery powered apparatus and, thus, the need to monitor the battery voltage.

Just thinking out loud...

problem is that with the water lever sensor i have the same result, but all these systems rely on the arduino itself.
the day it will lock or light goes off i lose any alarm.
i'll send some pictures later of the setup.
here is when the pump failed a bit of time ago. power went out and i found that..

wvmarle:
The ina219 will not do as it's a CURRENT sensor and you're looking for a VOLTAGE sensor.

The INA219 can measure high-side current as well as bus voltage.
Leo..

I had not realised that the alarm was a separate system using a battery.

There are advantages to using a battery because the alarm will still operate even if the 220V AC fails. However I do think you are making a mistake trying to power the alarm through the water as shown in your diagram. Why would you not use a float switch?

Your pump has its 220VAC supply controlled by a float switch. Another option would be to use a 220V AC alarm also controlled by a float switch. You can get a 120dB 220V AC alarm cheaply. Of course if you lose mains you would also lose the alarm.

In both the battery and the mains solutions you will be at risk of undisclosed faults preventing the alarm working when it should.

Yet another option (perhaps as a backup to the main alarm) would be to have a normally closed float switch wired to the Arduino and for it to send an SMS (that means having a SIM card though).