Not used both, but everything I’ve read says better to use voltage sensor
Hey, has anyone used this method?
I only want to sense the water level depth from 0 to 50cm at 10 cm intervals.
I have a number of tanks in different locations, so reading early threads about needing 24v power supplies and a $50 pressure sensor seemed expensive.
Keen to hear any ones experience in doing this on esphome.
Cheers
Made the leap and ordered 2 without checking but does this mean I can use it without an ADS1115?
If so how does my yaml change? Currently I’m attempting to use some very bad math to convert my 3.3v input into height then using that height to calculate my volume in litres then percentage.
Depends if the ESP board you use has an ADC (analog-to-digital converter) input. If it does not, then the ADS1115 will be needed.
What does the documentation say about ADC, ADS1115, calculating voltage? Its all in the esphome documentation and has lots of examples for configuration/yaml.
Made corrections to the code and hopefully when I get power back, it should come together nicely. Aside the headache I’ve been getting with the DS18B20 temperature prongs.
external_components:
# - source:
# type: git
# url: https://github.com/nrandell/dallasng
# components: [ dallasng ]
# - source:
# type: git
# url: https://github.com/ssieb/esphome
# components: [ dallas ]
deep_sleep:
#Auto deep disabled for testing. Consider for solar & battery powered model
id: deep_sleep_1
run_duration: ${auto_wake_time}
sleep_duration: ${sleep_time}
substitutions:
sleep_time: 0min
auto_wake_time: 50min
internal_mode: "true"
long_deep_sleep_duration: 0s
dallas:
- pin:
number: GPIO14
# mode:
# input: True
# pullup: True
- pin:
number: GPIO13
mode:
input: True
pullup: True
light:
- platform: neopixelbus
disabled_by_default: True
type: GRB
variant: ws2812x
pin: GPIO4
num_leds: 12
id: water_tank_A_monitor_light
- platform: neopixelbus
disabled_by_default: True
type: GRB
variant: ws2812x
pin: GPIO2
num_leds: 12
id: water_tank_B_monitor_light
sensor:
- platform: wifi_signal
name: 'Tank Monitor WiFi strength'
update_interval: 10s
accuracy_decimals: 0
- platform: uptime
name: "Tank Monitor Uptime"
unit_of_measurement: hours
update_interval: 60s
accuracy_decimals: 1
filters:
- multiply: 0.000011574
# Water Tank A section
- platform: adc
pin: GPIO35
update_interval: 1s
id: "water_tank_A_Voltage"
disabled_by_default: True
name: "Water Tank A Sensor Voltage"
unit_of_measurement: Voltage
attenuation: auto
filters:
- filter_out: NAN
# - multiply: 3.3 # Scale the ADC reading to voltage
- multiply: 0.5 # unplugged testing
# - calibrate_linear:
# - 0.210 -> 0
# - 0.880 -> 1.570
- platform: template
name: "Water Tank A height"
id: "water_tank_A_height"
disabled_by_default: True
device_class: "distance"
state_class: "measurement"
unit_of_measurement: cm
accuracy_decimals: 0
update_interval: 1s
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 5
lambda: |-
auto current = id(water_tank_A_Voltage).state;
return (current / 3.3) * 500; // Sensor: supposedly 3.3v to cm, range=5m
# divides the current voltage by 3.3 to get a percentage of the full range. Then multiplies by 500 to convert to centimeters
- platform: template
name: "Water Tank A Volume"
device_class: "volume"
state_class: "measurement"
id: "water_tank_A_volume"
unit_of_measurement: "litres"
lambda: |-
// Radius in meters (0.71m), height in meters converted to liters (1m^3 = 1000 liters)
const float radius = 0.71; // Radius of the tank in meters
const float pi = 3.14159265;
float height = id(water_tank_A_height).state / 100.0; // Convert height from cm to meters
return pi * radius * radius * height * 1000; // Volume in liters
- platform: template
name: "Water Tank A Percentage"
id: "water_tank_A_percentage"
update_interval: 10s
unit_of_measurement: "%"
icon: "mdi:water-percent"
accuracy_decimals: 0
lambda: |-
float max_height = 153.5; // Maximum height of the tank in cm
float height = id(water_tank_A_height).state;
return (height / max_height) * 100; // Fill percentage
on_value_range:
- below: 1.0
then:
- light.turn_on:
id: "water_tank_A_monitor_light"
brightness: 60%
red: 100%
green: 0%
blue: 0%
- above: 1.0
then:
- lambda: |-
float percentage = id(water_tank_A_percentage).state;
int num_leds = (percentage / 100.0) * 12;
auto call = id(water_tank_A_monitor_light).turn_on();
for (int i = 0; i < num_leds; i++) {
call.set_rgb(0, 200, 255); // Blue color
}
call.set_brightness(0.4);
call.perform();
# Water Tank B section
- platform: adc
pin: GPIO33
update_interval: 1s
id: "water_tank_B_Voltage"
disabled_by_default: True
name: "Water Tank B Sensor Voltage"
unit_of_measurement: Voltage
attenuation: auto
filters:
- filter_out: NAN
# - multiply: 3.3 # Scale the ADC reading to voltage
- multiply: 0.5 #unplugged testing
# - calibrate_linear:
# - 0.210 -> 0
# - 0.880 -> 1.570
- platform: template
name: "Water Tank B height"
id: "water_tank_B_height"
disabled_by_default: True
device_class: "distance"
state_class: "measurement"
unit_of_measurement: cm
accuracy_decimals: 0
update_interval: 1s
filters:
- sliding_window_moving_average:
window_size: 10
send_every: 5
lambda: |-
auto current = id(water_tank_B_Voltage).state;
return (current / 3.3) * 500; // Sensor: supposedly 3.3v to cm, range=5m
# divides the current voltage by 3.3 to get a percentage of the full range. Then multiplies by 500 to convert to centimeters
- platform: template
name: "Water Tank B Volume"
device_class: "volume"
state_class: "measurement"
id: "water_tank_B_volume"
unit_of_measurement: "litres"
lambda: |-
// Radius in meters (0.71m), height in meters converted to liters (1m^3 = 1000 liters)
const float radius = 0.71; // Radius of the tank in meters
const float pi = 3.14159265;
float height = id(water_tank_B_height).state / 100.0; // Convert height from cm to meters
return pi * radius * radius * height * 1000; // Volume in liters
- platform: template
name: "Water Tank B Percentage"
id: "water_tank_B_percentage"
update_interval: 10s
unit_of_measurement: "%"
icon: "mdi:water-percent"
accuracy_decimals: 0
lambda: |-
float max_height = 153.5; // Maximum height of the tank in cm
float height = id(water_tank_B_height).state;
return (height / max_height) * 100; // Fill percentage
on_value_range:
- below: 1.0
then:
- light.turn_on:
id: "water_tank_B_monitor_light"
brightness: 40%
red: 100%
green: 0%
blue: 0%
- above: 1.0
then:
- lambda: |-
float percentage = id(water_tank_B_percentage).state;
int num_leds = (percentage / 100.0) * 12;
auto call = id(water_tank_B_monitor_light).turn_on();
for (int i = 0; i < num_leds; i++) {
call.set_rgb(0, 200, 255); // Blue color
}
call.set_brightness(0.4);
call.perform();
# DS18B20 temperature sensor (enable once address is recorded)
# - platform: dallasng
# address: _
# name: "Tank A Temperature"
# id: "water_tank_A_temperature"
# update_interval: 10s
# unit_of_measurement: "°C"
# device_class: "temperature"
# state_class: "measurement"
# accuracy_decimals: 1
# filters:
# - filter_out: NAN
# - platform: dallasng
# address: _
# name: "Tank B Temperature"
# id: "water_tank_B_temperature"
# update_interval: 10s
# unit_of_measurement: "°C"
# device_class: "temperature"
# state_class: "measurement"
# accuracy_decimals: 1
# filters:
# - filter_out: NAN
Final Edit:
Code finally works. But the LEDs lit up in only 2 boot cycles. Not been back since. Will let it run a while but I currently feel a bit better. Code compiled properly and despite the LEDs acting up, it’s working much better now.
Hello,
I have a drainage tank i want to run with this, Programming code is done but when i connected the power the INA219 just fried and also the esp…
Please can anyone tell me what went wrong in this wiring ?
Relay and stepdown is still alive, and only 5v after the stepdown…
Looks ok to me.
Is your step down exactly this one? Because there are some similar ones that don’t support 24v.
Yes its just that one, and that worked before and still works…
Did you solder or use jumper wires?
Maybe a short circuit?
Solder everything and checked for short between solders, but in the ina219 should there be anything solderd on the a0 or a1 ?
No.
A0 and A1 are for changing the address, only necessary if you use more than one sensor connected in parallel.
Have you run the Ina with 3.3 volts as a test?
I think it’s strange, the INA is also supposed to be capable of 5 volts.
No run everything with 5v , last thing i connected was the 24v side, ( The TL 136 sensor ) everything ells goes on 5v… Really did it cautious cus i have burned like 4 esp32 before on different projects.
I have personally had better results with 3.3 volts with all sensors that run via I2C. I currently have 3 INA modules running. 2 on a birdhouse which runs on solar and one on my greenhouse.
which may also be your distance from the esp to the ina. i2c is very sensitive. i experienced this with my greenhouse, where i have 3 BME running.
By the way, I use the 3.3 volt output of the esp for this.
Disconnect everything from the 24V-to-5V converter except the incoming 24V +ve and -ve.
Depending on the type you bought they can be different voltages and they can also be adjustable. In fact the image you used is of an adjustable one. There is a gray area just above where the 5V out is that you can turn with a phillips screwdriver. That changes the output voltage. If you fried everything except the step-down converter, it’s probably adjusted for something higher than 5V.
@mekaneck
He said that the step down output is 5v. So I believe he adjusted it before soldering.
@athlech
I’m looking at a diagram from an old project and I connected the ina219 to 3.3v because I was using an esp8266.
The ina219 supports 5v and I’ve already connected several sensors to the esp32 using 5v, even though it’s not recommended.
using 5v for my relay is 5v, trout it would be easier that way, but before i connected everything i started with 24v to the step down, measured and turned it down to 5v, then when everything was working and i got signal from the ina219 i turned off power and connected the vin- and vin+ and it just lit up. But i never checked for shortage between vin-/vin+ upper and down on the board. Could it be something there ? When i measure that now its short between the Measuring (0,02 Ω) (I first connected the 5v to the board on the vin+ and vin- on the bottom but before i put the 5v on it i noticed it and de-soldered and connected that to the vvc and gnd)
The resistor between VIN- and VIN+ is 0.1Ω (r100) and is almost a short circuit. I believe that most multimeters cannot even read it.
Look at posts 281 and 219, the connection is identical to yours.