|
| 1 | + |
| 2 | +# Home-Assistant-Water-Tank-Level-Indicator |
| 3 | +I have been using this project to measure sump (under ground) water tank water level with NodeMCU and ultrasonic sensor, implemented using Arduino, MQTT and Home Assistant. |
| 4 | + |
| 5 | +## Features |
| 6 | +1) Calculates how many liters of water available in tank (Here we used rectangular tank) |
| 7 | +2) Calculates Percentage of water in tank |
| 8 | +3) Calculates distance of water level in cm |
| 9 | +4) Calculates distance of water level in feet |
| 10 | +5) Shows historical record of water level in cm, percentage and in liters |
| 11 | + |
| 12 | +## Requirements |
| 13 | +1) [NodeMCU](http://s.click.aliexpress.com/e/nlefJ4PI) |
| 14 | +2) [Ultrasonic sensor (I used HCSRO4)](http://s.click.aliexpress.com/e/e6xt0wEy) |
| 15 | +3) [Home Assistant App](https://play.google.com/store/apps/details?id=io.homeassistant.companion.android&hl=en) |
| 16 | + |
| 17 | +## Installation |
| 18 | + |
| 19 | + - Open <code>secret.h</code> and change Wifi settings, server settings and few other parameters as per your project requirement. |
| 20 | + - Open <code>settings.h</code> - Usually you don't need to change any values here, but if you need any customization feel free play with it. |
| 21 | + |
| 22 | +## Hardware Connection |
| 23 | + |
| 24 | +### Ultrasonic Sensor to NodeMCU Connection |
| 25 | +5V/VCC to Vin </br> |
| 26 | +Trig to D6/12 </br> |
| 27 | +Echo to D5/14 </br> |
| 28 | +GND to GND </br> |
| 29 | + |
| 30 | +## Home Assistant Configuration |
| 31 | + |
| 32 | +### Add in configuration.yaml |
| 33 | +```python |
| 34 | +mqtt: |
| 35 | + discovery: true |
| 36 | + discovery_prefix: homeassistant |
| 37 | + broker: xxx.xxx.xxx.xxx |
| 38 | + port: xxxx |
| 39 | + client_id: Home-Assistant |
| 40 | + username: Your-MQTT-Username |
| 41 | + password: Your-MQTT-Password |
| 42 | + |
| 43 | + - platform: mqtt |
| 44 | + name: "Water Sump Firmware Update" |
| 45 | + state_topic: "/house/watersump/Confirmfirmware/" |
| 46 | + command_topic: "/house/watersump/firmware/" |
| 47 | + payload_on: "1" |
| 48 | + payload_off: "0" |
| 49 | + optimistic: true |
| 50 | + qos: 0 |
| 51 | +``` |
| 52 | + |
| 53 | +### Add in sensors.yaml |
| 54 | +```python |
| 55 | + - platform: mqtt |
| 56 | + name: "Distance in feet" |
| 57 | + state_topic: "/house/watersump/" |
| 58 | + unit_of_measurement: "ft" |
| 59 | + value_template: '{{ value_json.distanceInFeet }}' |
| 60 | + |
| 61 | + - platform: mqtt |
| 62 | + name: "Distance in cm" |
| 63 | + state_topic: "/house/watersump/" |
| 64 | + unit_of_measurement: "cm" |
| 65 | + value_template: '{{ value_json.distanceInCm }}' |
| 66 | + |
| 67 | + - platform: mqtt |
| 68 | + name: "Liters" |
| 69 | + state_topic: "/house/watersump/" |
| 70 | + unit_of_measurement: "L" |
| 71 | + value_template: '{{ value_json.volume }}' |
| 72 | + |
| 73 | + - platform: mqtt |
| 74 | + name: "Percentage" |
| 75 | + state_topic: "/house/watersump/" |
| 76 | + unit_of_measurement: "%" |
| 77 | + value_template: '{{ value_json.percentage }}' |
| 78 | + |
| 79 | + - platform: mqtt |
| 80 | + name: "Water Sump Build Number" |
| 81 | + state_topic: "/house/watersump/" |
| 82 | + value_template: '{{ value_json.buildNumber }}' |
| 83 | +``` |
| 84 | + |
| 85 | +## Software Setup |
| 86 | + |
| 87 | + - Download and install the Home Assistant App for iOS or Android. |
| 88 | + - Download this repo and copy the files in to your sketches directory. Open the sketch in Arduino IDE. |
| 89 | + - Go to the <code>settings.h</code> tab. This is where all the customisable settings are. You should be able to change almost everything from there before compiling. |
| 90 | + - Go to the <code>secret.h</code> tab. Here you change Wifi settings, server settings and few other parameters as per your project requirement. |
| 91 | + |
| 92 | +## Screenshot |
| 93 | +<img src="/Images/1.jpg" width="" height="" style="max-width:100%;"></br> |
| 94 | +<img src="/Images/2.jpg" width="" height="" style="max-width:100%;"></br> |
| 95 | +<img src="/Images/3.png" width="350" height="" style="max-width:100%;"> |
| 96 | +<img src="/Images/4.png" width="350" height="" style="max-width:100%;"> |
| 97 | +<img src="/Images/4.png" width="350" height="" style="max-width:100%;"> |
0 commit comments