Skip to content

Code for ESP32 Huzzah with A02YYUW waterproof distance meter. Displayed via LCD and through JSON web page.

Notifications You must be signed in to change notification settings

braham2019/waterlevel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

Waterlevel

My first ever project based on Arduino code. I recently installed two 10000 liter rainwater tanks, and I wanted to visualize how much water is left in the tanks in real time. The information needed to be visual on a small LCD screen inside my garage and also on a web page, where it could be scraped or viewed. I also wanted to be able to update the Arduino code using a web browser.

IMG_1708

Hardware components used:

Software components (Arduino libraries) used:

  • Wifi: for network connectivity
  • rgb_lcd: for the Grove Seeed LCD screen
  • Softwareserial: to represent the software serial port for the ultrasonic distance sensor
  • ArduinoJSON: to buid the web page
  • Webserver & ElegantOTA: for Over The Air updates of the code

The code is pretty self-explanatory (I think): first Wifi is enabled then the JSON webserver and the OTA webserver are started. The loop will take a reading and update the LCD screen every 5 seconds. When a web client connects, an up-to-date web page will be generated.

Additional info:

  • I gave the ESP32 a static IP address through DHCP reservation.
  • The JSON webserver is running on port 80, the OTA server on port 81.
  • The LCD screen is connected to SDA & SCL ports.
  • The LCD screen shows the reading in percentage and displays a progress bar.
  • The JSON webserver shows percentage and the distance to the water. The percentage information is gathered by Home Assistant through a REST API call sensor so I have historical metrics available.
{
  "data": 87,
  "distance": 313
}

Home Assistant configuration:

sensor:
- platform: rest
    name: regenput
    resource: http://192.168.0.x
    value_template: "{{value_json.data}}"
    unit_of_measurement: "%"
    scan_interval: 60
  • I also display the information on my Dakboard. As Dakboard can only talk to external https resources, I am using a Traefik reverse proxy, protected by Cloudflare and a Cloudflare Tunnel to allow access to the JSON server (config out of scope).

View of the hardware

Cable between sensor and ESP32 not shown IMG_1668

About

Code for ESP32 Huzzah with A02YYUW waterproof distance meter. Displayed via LCD and through JSON web page.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages