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.
Thanks both for your replies and your advice !
Indeed, when I try to enter the physical pin number (21/20), the yaml file tells me that these pin numbers are not supported for the 8266 platform. However, I tried both GPIO4 & GPIO5 / D1 & D2, but unfortunately without any luck.
Unfortunately, I don’t have another I2C device to test with :-/
Please find enclosed the requested pictures. The pictures with the usb cable attached is the Wemos D1 mini, the little one is the INA219
Connections on INA219:
If I look at the picture of the INA sensor I would suggest to resolder the SCL and SDA pins. The soldering of these pins looks not so good, try to cover the whole puch hole with solder.
Resoldering the pins did the trick !!! you are hero’s !
[18:30:15][VV][scheduler:195]: Running interval 'update' with interval=10000 last_execution=17664 (now=27670)
[18:30:15][VV][i2c.arduino:126]: 0x40 TX 02
[18:30:15][VV][i2c.arduino:102]: 0x40 RX 07AA
[18:30:15][V][sensor:074]: 'INA219 Bus Voltage': Received new state 0.980000
[18:30:15][D][sensor:124]: 'INA219 Bus Voltage': Sending state 0.98000 V with 2 decimals of accuracy
[18:30:15][VV][i2c.arduino:126]: 0x40 TX 01
[18:30:15][VV][i2c.arduino:102]: 0x40 RX 0000
[18:30:15][V][sensor:074]: 'INA219 Shunt Voltage': Received new state 0.000000
[18:30:15][D][sensor:124]: 'INA219 Shunt Voltage': Sending state 0.00000 V with 5 decimals of accuracy
[18:30:15][VV][i2c.arduino:126]: 0x40 TX 04
[18:30:15][VV][i2c.arduino:102]: 0x40 RX 0000
[18:30:15][V][sensor:074]: 'INA219 Current': Received new state 0.000000
[18:30:15][VV][sensor.filter:014]: Filter(0x3fff1ecc)::input(0.000000)
[18:30:15][VV][sensor.filter:021]: Filter(0x3fff1ecc)::output(0.000000) -> SENSOR
[18:30:15][D][sensor:124]: 'INA219 Current': Sending state 0.00000 mA with 5 decimals of accuracy
[18:30:15][VV][i2c.arduino:126]: 0x40 TX 03
[18:30:15][VV][i2c.arduino:102]: 0x40 RX 0000
[18:30:15][V][sensor:074]: 'INA219 Power': Received new state 0.000000
[18:30:15][D][sensor:124]: 'INA219 Power': Sending state 0.00000 W with 5 decimals of accuracy
[18:30:15][V][component:199]: Component ina219.sensor took a long time for an operation (0.11 s).
[18:30:15][V][component:200]: Components should block for at most 20-30ms.
The only thing is, I wired my sensor using the scheme in this thread by @kimocal , but my voltages (see this log & Watts) are very low. I drowned it in a bucket of water and there is no movement of the values.
My sensor is powerd by 12V only, is this enough or should be 24V ?
Could this be the reason ? Or is the bucket no reference ?