ESPHome water level sensor

These very cheap current to voltage converters are also available:


Not sure whether it has any downsides to the DFRobot version.
In terms of set-up it is a bit confusing:
There are jumpers and the instructions say that in order to get 0-3.3V for 0-20ma you have to make sure both jumper caps are installed.
In addition, when the water tank is empty you have to turn one potentiometer until the output is 0V, then when the water tank is full you have to turn the other potentiometer until the output is 3.3V.

Also you would need to feed this one with the same power supply as you use for the water level sensor as it requires >7V so more than the ESP32 will provide.
In general it seems more flexible than the DFRobot version.

1 Like

Downside seem to be related to ESP8266 - cannot limit output voltage to 1V.
I am waiting for delivery (in 1-2 weeks) of exactly those. Will connect to ESP8266 and since my sensor is for 5m and my tank has max depth of 1,4m then it should be fine to have output voltage within 1V limit. In worst case I move to ESP32.
I am hoping for more stable readings as it says (in my seller page) that this module is using ā€œhigh precision low temperature drift ring resistor 0,1% 30ppmā€ which for sure is way better then resistor I have used.
Now, after reading this carefully and checking some data it may turn that NodeMCU ESP8266 has 0-3,3V input on A0. Only bare ESP8266 have 1V limit - will check this today.

Now for your calculation of accuracy I read that my sensor has 0,2-0,5% FS accuracy which is max 2,5cm. Then current-voltage converter also introduces error - not clear but I assume resistor tolerance 0,1% (another 0,5cm) and then comes ADC on ESP8266. With 10 bits it has resolution of 1024 which translates to 0,1% - then some tolerance has to be added to analogue conversion (could not find data for this) - I assume 0,2%.
So in total I have in worst case 0,9% (0,5+0,1+0,1+0,2) which means 5cm. In my case of 1,4m max level this translates to 3,5%ā€¦ This is theory which I will soon verify (have easy access to my tank so I can measure the level and compare with reading).

1 Like

Thank you @quizzical !
With your posts I have discovered that my NodeMCU ESP8266 can measure up to 3,3V on A0!

Tested and confirmed with multimeter.
This is actually described on ESPHome page (for some reason I have not paid enough attention to it - or did not fully understand) that some NodeMCUā€™s have internal devider and in order to read real voltage the multiply: 3.3 filter has to be applied.
Now it will be easier to attach current-voltage converter and accuracy should be also better.

1 Like

Excellent, glad I was able to help!
In case anyone is looking for a 24V power supply to feed the pressure sensor, Iā€™m planning to buy this one from Meanwell. To my very limited understanding itā€™s quite fine to buy low-voltage things from Aliexpress, but for devices that operate on 110-230V AC power itā€™s safest (electrocution/fire hazard) to buy from western countries (even if I have no doubt the actual production is in China).

You can also consider DC-DC step up converter to achieve from power supply of ESP (5V) by ā€œsteppingā€ it up to 24V. Or you plan to provide 24V and then step down to 5V to supply to ESP.

Yes my setup will be as follows:
I convert 230V AC to 24V DC and feed that into:

Mentally it somehow made more sense for me to convert 230V to 24V and then to 5V than to go from 230V down to 5V and then back up to 24V :slight_smile: Without any knowledge on the matter I assumed it would be more power efficient that way.

Do you feed a sufficiently powerful (or would 1A=5W be sufficient?) 5V USB power supply into your ESP8266 and then connect a DC-DC step up converter to the 5V and GND of your ESP to achieve 24V for the sensor and current to voltage converter?

2 Likes

Hey, Iā€™m trying to adjust this to suit my little reservoir but Iā€™m doing something wrong. I was going to keep the sensor 22cm above the full water line as recommended. The res is full at 21cm. Can you help me out with the equation? thanks

tank height: 30.5cm

# height from full to sensor: 22cm (essentially sensors minimum distance)
# full tank: 21cm
# current reading: x
# ergo: used = (x - 22)
# ergo: remaining = (21 - used)
# ergo: percent = (remaining / 21) * 100

filters:
  - lambda: return (1-((x-.22)/21))*100;
  - filter_out: nan
1 Like

Assuming sensor is powered with 24V and max current flow is 20mA it gives 0,48W of energy. This with 5V is 96mA. Taking some margins and assuming 90% efficiency of step-up module we get something around 140-150mA from 5V source (0,75W).
ESP8266 takes (from my measurement) 700-900mA, so together I would need 1,1 - 1,2 A to be safe.
I would go this was as I have several ESP8266 in my environment and I want all of them to be powered by cable from one central source which is also backed up with UPS.
Now, it happens that my entry gate is powered by 24V and is close to my tank to I decided to use those 24V for powering sensor and my standard 5V to power ESP8266.

1 Like

What kind of sensor are you using ?

FYI hereā€™s a video about the built in ADCā€™s in the ESP8266 and ESP32.

Conclusion: ESP8266ā€™s ADC inaccuracy can be fixed with some coding. ESP32ā€™s ADC is garbage. This cheap dedicated ADC is excellent and does not need any fixing.

Did your current to voltage converter arrive? Did you get it to work?

Most of the things I need have arrived and I decided to do some testing.
First thing was to put 24V on the pressure sensor and measure the amperage with a multimeter.
In this drawing you can see how I took a USB powered ESP8266, converted the 5V from there to 24V and connected this 24V to the pressure sensor (with a multimeter in between). It shows 4mA when not submerged and Ā±6mA when I put it in a bucket of water. So far so good!

However the current to voltage converter doesnā€™t work for me. I put this converter where the multimeter used to be on my previous drawing, and give the converter itself 24V of power:


Result: the thing starts smoking and a burning smell appears. The Vout doesnā€™t give a voltage.
If I just power on the converter with 24V but donā€™t put anything on I+ and I-, the thing first makes a lot of noise and the indicator light blinks a lot. After a while the noise stops and the light goes solid. However if I put a lower voltage (itā€™s supposed to work on 7-36V) the light wonā€™t stay on. The component which Iā€™ve indicated with a green arrow gets Ā±130Ā°c warm!!!

Am I doing something wrong?
image

I think Iā€™ll be buying this one from DFRobot instead.

Unfortunately my order from Aliexpress got stucked somewhere (was send 38 days and is still not in my country :frowning: ), so I need to contact seller and investigate status.

For your connections all seems correct. At the same time if the module gets hot this is not good.
Do you have only 1 ordered (there is a small chance that it was brokenā€¦) or more to test other ?
What if you power module from one source (12V lets say) and sensor from another source (in a way in your case you are connecting VCC with + input for current sensor and I do not know if the sensing part is somehow isolated/resistant to this ?).
And IMO with no sensor connected at all module should start working, no part should get hot (not more then 40-50C) and you should get close to zero voltage on Vout which can be regulated with ā€œTurn zeroā€ potentiometer.
Also did you play with jumpers (maybe there is some bad connection) just to see if this changes anything (with no sensor connected).
The element which gets hot is names U2 and looks like transistor or similar active component. Also double check + and - of connection (I know it is obvious but happen something ā€¦ :frowning:
Last I would maybe try to connect sensor between Vout of setp-up module and + input of the sensor.
And last think which comes to my mind is the fact that setup module does produce some noice, which current to voltage converter does not like ? And maybe putting capacitor at the output may help ? This actually woudl be eliminated if you power the module from batteryā€¦
I keep fingers crossed for your testing ā€¦ !

2 Likes

Surprisingly today I have got my modules.
So afternoon started to test them knowing @quizzical issues. Andā€¦ unfortunately there is something wrong with them :frowning:

  1. They seem to be OK with Vcc between 5 and 12V. Over 12V power-LED goes off and increacing Vcc get the led to flicker and module to give strange noice. The part indicated by @quizzical is getting hot (power consumption by module goes to above 150mA). BTW I can that this part is linear voltage regulator LM317LZ
  2. I was trying to simulate current load to input and it does not seem to work. I have stable Vout voltage regardless of current I regulate. I was however able to make 0V with ā€œzeroā€ regulator.
  3. On my board/module there is a symbol HW-685 - I can see this site with information about this module, where it says that Vcc is between 5 and 12V !

It seems that my both modules behave the same.
Is it possible that information on the Aliexpress seller page is so wrong ? (Vcc up to 37V)
And that reviews of this product are so good ?

Not happy :frowning: :frowning: :frowning:

EDITED 18.3.2021
Based on the link above I have made another test powering module with Vcc=5V (red power LED is going on but not as strong as with 12V). It seems that with such power hte module is working correctly. I was able to adjust zero and max 3V when current was 20mA. Regulating current between 4 and 20 mA Vout was changing from 0 to 3 V.
So this is positive. Next step will be to connect to my system/sensor and see the live results.
(Still shocked with the many available information that module power is from 7 to 34 V !)

1 Like

Thanks for your insights. Based on your feedback I tried powering the current to voltage with 5V and sure enough the light was steady and nothing was extreely hot. So far so good.
But then I connected my pressure sensor which has 24V on it. As soon as I put power on the system there was a component which immediately caught fire. On my previous post itā€™s the device called the ā€˜current signal sampling resistorā€™.
Perhaps because of the abuse it has allready had before when I used 24V instead of 5V? In any case it looks like this is not for meā€¦ Iā€™m patiently waiting for the DFRobot one to arrive.

Looking forward for your test of DFRobot.
The one possible explanation for your ā€œfireā€ on the board could be connection 24V just to the board (or some shortcut on the sensor cables) in which case you are creating 240mA current (I have measured the resistance of this ā€œpreciseā€ resistor and is equal 100 Ohm). Important in connecting is to make sure that GND of 24V is connected to ā€œ-ā€ of the current sensor connector (as this is connected with GND of power supply). So I think, safe connection would be +24V to + of the sensor, - of the sensor to + of current sensor connector, - of current sensor connector to GND of 24V. Especially if you are using setp-up module (in which GND of input is connected with GND of output).

I am also thinking of another test to just connect high precision resistor (lets say 0,05%) with value selected to my measures and needs. ESP8266 NodeMCU (which I am using) can measure on A0 voltage from 0 to 3,3V. My tank can only be filled up to 1,4m level which corresponds to appr. 8,5mA of sensor current. So I need to use resistor which with lets say 9mA gives me 3,3V - this 366Ohm. So, using 370 Ohm resistor I will get 1,48V at the level 0 (4mA) and 3,14V at the level of 1,4m. Surely I am ā€œloosingā€ the 0-1,48V range and my accuracy drops down.

1 Like

Thanks for the advice,
On the site you found, they indeed connect the Vout- to the converter and have the Vout+ go trough the sensor.
I have been following the schema on the site of DFrobot where they have the Vout+ connected to the converter and the Vout- to the sensor. That could indeed explain the reason my converter catches fire.
My DFRobot current to voltage converter arrived today. I assume I should still connect this one to the Vout+ right (and have the Vout- go trough the sensor and then to the converter), as is depicted on the schema on the DFRobot website?

Looking forward for your experience with DFrobot.
IMO as lomg as you are using completely separate power for sensor than it should not matter where you connect the sensor (either between Vcc and + connector, or GND and - connector - keeping in mind sensor + and -). The chalenge starts when you use setup-up module which (in most cases) hard connects GND of input and output. In that case you can galvanic connection between your sensor power GND and module power GND which has to be taken in consideration.
I woudl first check if ā€œ-ā€ connector of module input is connected to GND of module power supply (as it was in the other module). And in case it is, I would connect sensor between Vcc and + input of module. It should not matter for the sensor as it ā€œcreatesā€ current as a result of itā€™s measure and you are safe that GND of sensor power supply is connected to

1 Like

Iā€™m in the situation where I use one power supply that provides 5V to most of my devices and powers a step-up power supply that delivers the 24V.

I can confirm your statement about the cheap converter: the resistance between GND and the - on the current sensing part is 0.00 Ohm.

For the more expensive DFRobot converter, the resistance is 0.2 Mohm (200 000 Ohm).

I really want to avoid destroying the DFRobot one. Given that the GND and - are not connected, how would you suggest I connect the converter to the sensor and step-up power supply?

This is good sign - meaning that module is more ā€œsecuredā€. IMO there should be no difference in connecting sensor either to Vcc od GND of step-up board. At the same time I think it is always ā€œmore safeā€ to connect it between Vcc and + of the module (in case the GND matters and knowing that GND of your step-up module is connected to GND of power supply).

1 Like

OK so I connected the DFRobot converter according to your suggestions and it works fine!
I then also connected the cheap converter with the burnt ā€˜current signal sampling resistorā€™ in the same manner and it works fine too!
I also have a brand new version of this cheap converter nowā€¦

So I now have the luxury problem that I need to choose between the DFRobot and the cheap converter.
The cheap one has the benefit that I can set for which mA it should output 0V and for which mA it should output 3.3V. It also has many more components on it, which as a layman I would assume means its fancier.

But my number 1 criterium is safety (e.g. not catching fire), I guess the DFRobot one wins in that front, though I have not (and will not) connected it in the ways that made the cheap converter smoke/catch fire.

Which one would you pick?

Thanks a million for all the advice you have given, I donā€™t think I would have figured it out without you!