I have some environmental monitoring on my water tank, tracking outdoor details as well as the water tank level. My config is as follows:
Wemos D1 mini as control unit. This is powered by an old DC plug-pack sheltered from the rain etc, connected to a cheap DC level converter to provide 5V DC to the D1 mini. The wifi connection to my home router is surprisingly reliable given the conditions.
A standard “rain monitor” daughter board and sensor connected to A0 and D4. This DOES NOT work reliably regardless of sensitivity setting; the unit false triggers on dew and high humidity (Sydney hits 100% humidity many mornings so not much use), the PCB gets a corrosive build-up quickly and needs cleaning, and the sensor reports “wet” conditions for a day or more after rainfall.
Temperature monitoring using a DS10B20, connected to pin D3.
Water tank level sensing using the JSN-SR20 connected to pins D6 & D7. I have dual sensors located directly on the top of the tank (it has a flat top, and I used exterior double-sided tape to stick them on which worked surprisingly well). This has been UNRELIABLE for me; I replaced the daughter board and dual ultrasonic sensors 4 times before I gave up. Additionally the water level can’t be read when it’s raining as the surface waves cause invalid readings (you could fix this by putting the sensors into a vented pipe within the tank), plus the reported levels vary with temperature (this might be the DC supply drifting with temp, haven’t really investigated).
Water level reported in cm, L, and %full.
All the above is in a capped 90mm PVC pipe enclosure, with entry and venting at the base and temp / rainfall sensors stuck to it. Despite the wettest first 3 months of the year on record here, I’ve had zero issues with moisture or condensation.
Tank is a 5000L circular tank, 2m tall.
I’m going to upgrade with humidity monitoring, a DIY rainfall sensor, and a 5MPa water pressure sensor (which I’ll connect via a 3mm x 2m tube to the tank outlet) to replace the JSN-SR20 but am still to test and config it. The drop-in sensors discussed previously sound like a better idea but I haven’t gone down that path yet.
Britespark,
This is a project i am about to get onto. I am just waiting to get my hands on some 18650 cells so i can set up a 24v battery with solar feed in.
My tank is located about 60m from my house uphill and I get good wifi there so will be using an esp32 as my controller with a thrown in pressure sensor.
The plan is to have the measured values provide a reliable value that will then be sent to another esp32 to trigger the pump for refill.
Would be good to keep in contact on our respective projects. I am in Northern NSW.
Pat
Sounds like fun, Pat. My brother has a very similar scenario, with a header tank on a hill he’d like to monitor and a bore to fill it when needed. If I get my system working reliably (I’m in residential Sydney, so if it fails there’s always mains pressure ) I’m planning to install on his property.
Thanks @OzGav that sounds sensible but I think that will defeat the purpose here - you need the tracks exposed for the rain / moisture to complete the circuit. It’s the actual tracks on the rain sensor, which look like solder-coated copper, that get the corrosion buildup on them. If the tracks were straight copper they’d probably be ok but I think the wave solder process in manufacture coats everything.
I haven’t really looked into what the impact of the buildup is, I guess over time it would reduce the conductivity. Or the buildup might become waterlogged and prevent the circuit drying out in a reasonable time. I’m thinking of replacing the stock sensor with some thin brass wire (easy to solder, or maybe stainless steel wire) wrapped as a closely-spaced double-helix around a piece of veroboard.
I also need to know how much water is in my cistern so I know when to fill it up again.
I bought an TL-136 Water Level Sensor and have an ESP8266 here.
this thread is miles long (with many different aprroaches) and I would like to know If anyone can share a step-by-step tutorial how to set everything up.
components used
how to wire everything up
how to setup up the software and the home assistant integration
Just a few questions. I have the same setup, but looking to connect to a Wemos D1 mini
I assume that the VCC & GND of your INA219 connect to the 5V and GND of your ESP, right ?
I assume that the SDA of your INA219 connects to the A0 of your board ?
Where is the yellow one going to ?
Here is the Home Assistant configuration.yaml parts:
template:
- sensor:
- name: "Water Tank Level"
unique_id: "water_tank_level_sensor_inches"
unit_of_measurement: "inches"
state: >
{% set height = ((states('sensor.ina219_current')|float * 5.0663) - 24.86) |round(2) %} #This equation was derived in a spreadsheet based upon actual water height and ina219 current values
{% if 0.000 <= height <= 72.000 %}
{{ height }}
{% else %}
unknown
{% endif %}
The INA219 is connected to the ESP32 via the wires in my diagram. The red is VCC and black is Ground. The yellow and green wires are the SDA and SCL pins on the M5 Stack ESP32. You’ll have to look up the Wemos D1 mini pins. On the M5 Stack the SDA and SCL pins are 21 and 22 respectively per the yaml code I shared.
This is part of the issue. Without seeing which pins you have the SDA and SCL lines physically connected to on the Wemos, it’s hard to trouble shoot. If you have them connected to the actual SCL and SDA pins then change these in your esphome yaml:
Also you may wait to add everything after those lines until your ESP can see the i2c devices. The ESP will scan the i2c bus and then give you the address of the INA219. That will show up in the logs. Then you can add the appropriate address in the remainder of the YAML.
sensor:
- platform: ina219
address: 0xZZ <---- TO BE DETERMINED WHEN THE ESP SCANS THE I2C BUS
Thanks again for your swift answer. Please find below the code. The Wemos D1 mini on an ESP8266 platform doesn’t support the declaration of the 20 and 19 pins, I need to use (I think) the GPIOnumbers.
So my SDA from the INA219 is connected to the GPIO4, the SCL from my INA219 is connected to the GPIO4. The GND from my INA219 connected to GND from Wemos & the VCC of INA219 connected to the 5V pin.
I try to scan the I2C, but no devices found. I tried to put a delay ‘on boot’, but that doesn’t work…
To be complete: I connected the pins for the INA219 to the Wemos board directly using the breadboard cables, but without using a breadboard (so from pin to pin)
If you are using a d1_mini you can also use the D-numbers for your pins in the yaml file.
The i2c scan doesn’t find any device, so 99 out of 100 times there is a problem with the wiring, or a defect sensor. Do you have another i2c device which can be used for testing to exclude the sensor itself.
I was going by other examples in a quick google search of using the pin #s I found online for esp8266. I have only played with ESP32s so not too familiar with the 8266 / Wemos idiosyncrasies.