I think I’ve linked this video before in this thread (or a similar one).
It shows that the ESP32 has a particularly poor built-in ADC.
That’s why an external one like the ADS1115 is recommended.
Using the ADS1115 and a well suited pressure sensor (in my case one with a range from 0 - 2 meters for a pool that fills up to about 1.35m) I get a precision of about 1-2 millimeters!
Quizzical
Yeah the guy with the swiss accent is on my subscribe list. He also convinced me to purchase the ads1115. I am measuring a 22000 litre water tank - depth about 2.4. I should have it all in a box soon.
Pat
The ADS1115 uses an I2C interface to send data to the NodeMCU, therefore the A0 connection is not required at all.
The ADS1115 uses the connection between the ADDR and other pins to set its address so, yes, that connection is correct for the address “0x48”. Other connections and addresses below:
ADDR → VDD “0x49”
ADDR → SDA “0x4a”
ADDR → SCL “0x4b”
This is a very handy feature which allows connection of multiple ADS1115 modules to a single NodeMCU if required. I have 3 water tanks in my RV that each have four outputs “1/4”, “1/2”, “3/4” and “Full”. This is a total of 12 possible water levels. Using 3 x ADS1115 I can configure my tanks to display individually in HA, using one NodeMCU.
The gravity sensor uses current in the range of 4mA - 20mA as its output. This means that the circuit current must flow through the device for it to work. The accompanying module converts the current to a voltage for the ADS1115.
No, the picture is correct. The throw-in sensor uses the 24V directly and the 5.2V output of the regulator is used only for powering the NodeMCU and the current to voltage converter.
@rusty_away, can you share your config and more detail about the wire; I’m looking for a solution to measure 2 tanks (one next to the other) and your description rang me the bell that I can use a single NodeMCU for that
First you have to set up the pins on the NodeMCU that the I2C interface will use:
i2c:
sda: GPIO4
scl: GPIO5
scan: true
id: bus_a
Then you declare the address the ADS1115 will be using (for example “0x48”) In this case the address is set on the ADS1115 itself by connecting “ADDR” to “GND” of the same module.
In the above code I have configured the first two analogue inputs of the ADS1115 which is using address 0x48. Read up on the ADS1115 as you will need to use a “gain” value that matches your input voltage range. In the example, above, the ADS1115 input 1 (A0) and input 2 (A1) are referenced to ground (GND) which is the -ve DC rail of the circuit.
So, if you are using throw-in level sensors, connect the output of the first current to voltage module (Tank 1 ??) to A0 and the output of the second current to voltage module (Tank 2 ??) to A1 of the ADS1115.
I have just connected all my bits together yesterday and the results look good. I was struggling a bit at first and I believe I found two possible issues.
The board type may be crucial - I had originally flashed my esp32 using the esphome io. It put the board as a esp32 dev board. I changed this to nodemcu-32s.
I also decided to send power from a 3v pin on my esp to the ads1115.
After making these two changes my error with receiving no connection from the ads1115 fixed straight away.
So now a couple more twekas before going into the box. If anyone has advice.
I read in this forum, possibly from hummingbear - that it is better to send the power to the ads1115 through a gpio. Then the ads1115 is only drawing power when you wake from deep sleep otherwise it is sucking 3v all the time?
I am also then considering that my project should all run on a parallel 3 x 18650 battery. Currently I draw .2A through my 24v battery bank (18650). If I tie my smaller 18650 battery to a 5v solar and use deep sleep I should have about 150 days of running without being charged. This is based on the power usage calculator at IOT Battery Life Calculator (thanks Mr swiss man)
I then thought I could use less power by instead of using a 5v relay to send a regular 18v to the sensor that I could use the small battery bank with a dc/dc step up to 18v as the gravity throw in sensor only draws minimal power. This step up would then be switched with a n channel mosfet driven by gpio from the esp32.
Does this make sense?
Pat
Thansk for all your help, works for me very well now. I took the freedom to slightly modify your diagram based on your instructions and what worked for me:
Liflitz
I am wondering - you have sent your voltage to the A1 pin. You are referencing vdd then? Any reason why you do this and not to ground on AO?
Do you know your power usage at work and deep sleep?
Pat
Liflitz,
glad I wasn’t seeing things.
I have just been doing some reading about using proper grounding of components so that there is no fluctuation of signal due to electromagnetic interference. This youtube video posted in an arduino forum though really in depth made me think that my rats nest of wires and cables might be causing some fluctuations to occur. (US) Designing the Signal Return Path Through the PC Board - Susy Webb - Expert Live Training - YouTube
Might see how a good ground base may assist.
Pat
Advice welcome
I have my bits connected and thought I would put it through it’s paces to see how consistent the readings are.
Everything is powered by a bench top supply delivering 14v. I then step this down to 13.3 for the sensor. I have a separate step down to 5v. This power goes to the esp32, the 5v relay (switching power to sensor on upon wake), the current to voltage converter and then to the ADS1115.
All grounds are connected.
Looking at the logs I see that there is fluctuation on readings - is this normal in your setup? see piccy
I have the exact same setup. But unfortunately I always get 9,7V from the current to voltage converter, no matter what the water level sensor sends.
Could you share a wiring diagram? Maybe I missed something…
Thanks!
Philipp
Here is my just made schematic. You can see that this is my first time using draw.io - maybe I’ll work on it amongst the other 327 jobs.
I get readings that are within +/- .03
Thought people here may be interested in a solar ESPhome based water level sensor I recently completed work on. I have a water tank/bladder under the house which I wanted to track for garden watering purposes.
Several iterations were needed to improve/reduce battery usage. The first version had the sonar wired directly to the battery which constantly drained it. The HD-SR04P version it can be powered as/when required from a ESP8266 pin.
The battery is a small 240mAh one I had left over from another hobby. On this it will last roughly a week without sun from a full charge with my deepsleep settings. I’d recommend going with a better battery with proper low power cutoff as I destroyed more than one battery during testing.
This was my first attempt at PCB design so I wouldn’t recommend going out and make clones of this but I can say it works well for me.
Was thinking that it would be cool if this community could put together libraries of known working (and expert reviewed) designs and recommended parts for things like this.
I’m happy to upload schematic/BOM files for anyone interested.
Code is probably what took me the longest to get working correctly. Hopefully this will help others. Just set your deep sleep settings and the battery voltage settings in the bits below.
I have 4 boards left that I probably will not end up using as you have to order with a minimum of 5. If you are in Australia and are interested in something like this feel free to PM me.
Hi @bobderbuilder thank you for sharing it and sounds a fantastic job
I’m not from Australia, but if you share your schematic, I will be happy to learn from you