I have a rainwater collection system that feeds into several water tanks. I’d like to be able to monitor the tank levels for a variety of reasons, first and foremost because of the fact that we get almost no rain in the summer, and I have run the tanks to empty before.

In the past, I have used Milone eTape connected to an Atmel microcontroller to monitor water levels for a few different applications. I’d like to use this again if possible.

The eTape essentially acts as a potentiometer in a circuit. I’ve done some research on various ways to feed this into HomeAssistant, but I’m not really sure what’s best. My water tanks are just behind the wall from my HA server, so I could connect directly with USB, serial, or ethernet. WiFi or Zigbee or also options; nearly every other device I have connected to HA is Zigbee.

What I’m ideally looking for is a device that can take a voltage level between 0-5VDC, or a 5k potentiometer, and feed the result into HA. Building something isn’t out of the question (as long as I can program it in C or C++), but an off-the-shelf solution that integrates with HA would be ideal.

    • corroded@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      7 months ago

      I’ve looked at ESPHome, but this still means I have to build a circuit board with the ESPHome core device, if I understand correctly? This would certainly work, but it seems wasteful to me when I don’t really need a microcontroller at all, just an ADC that HA can read. If this is the best option, though, I’m open to the idea.

      • CameronDev@programming.dev
        link
        fedilink
        English
        arrow-up
        2
        ·
        7 months ago

        I use esp32 dev boards, they are very cheap for this kind of thing. You dont need to make a circuit board, other than the voltage divider which youll need anyway. Then its just a bit of esphome code and you are done. They dont use much power either.

        An “ADC that HA can read” sounds exactly like a job for a microcontroller to me?

        • corroded@lemmy.worldOP
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          7 months ago

          I was hoping for something that just reads an analog level and outputs a stream of serial data, but using an ESP32 does seem to make a lot more sense than having an ADC, UART controller, and probably a UART->USB interface. Seems like ESPs fairly cost-effective, too.

          Forgive me for sounding like an idiot, but how does ESPHome work exactly? I understand that I would flash ESPHome onto the dev board as an “operating system” of sorts. How does one program ESPHome to read the GPIO pins on the board? Do I modify the ESPHome code beforehand, then flash the entire package, or do I flash the ESPHome code, then interface with the ESP chip to configure it?

          As far as microcontrollers go, I’ve always just written my own code, then flash it to the microcontroller with an ISP or JTAG programmer. What kind of hardware/software is needed to interface with an ESP32 device? It looks like the dev boards usually have a USB interface built in.

          EDIT: So it looks like, if I understand this correctly, I would use esphome-flasher to transfer the ESPHome binaries to the ESP device, then do the rest of the configuration in HA with the ESPHome integration?

          • CmdrShepard@lemmy.one
            link
            fedilink
            English
            arrow-up
            1
            ·
            7 months ago

            Definitely read the docs but yes your edit is correct. In ESPHome (in HA) you’ll just edit the config file to tell it, for example, that GPIO pin 5 is connected to a potentiometer and then this becomes an entity in HA.

            I’d recommend getting some ESP8266 Wemos D1 mini boards as they’re better suited to this and half the cost of ESP32.

            Also you may consider other sensors you could use in this same area like temperature, lux, humidity, etc as they can all be run off the same ESP device in the same ESPHome config and you’ll have plenty of free pins.

          • CameronDev@programming.dev
            link
            fedilink
            English
            arrow-up
            1
            ·
            7 months ago

            The esphome config is more like a build script, it builds an esphome binary with the config built in. They are fairly simple yaml files, and there is plenty of doco and examples about. Esphome will generate a basic config for you, and you can modify it to suit.

            So, to start with, you just need to install the esphome addon in HA. From there, you can plug the esphome dev board into the PC you use to access HA (ideally, youll want to use chrome, as it supports flashing the esp device directly), and in the esphome interface click the “New device” button. You choose a name for the device, and then click connect. Esphome UI will then connect to your board, and try to determine what it is, and will setup a basic “failsafe but does nothing” config, and it will flash it to the board.

            From there, you can unplug the board, and subsequent flashes can happen over wifi. Adjust the config and reflash until it works. Home assistant should detect the board when it next boots up and you can add it as a device.

            If you get dev boards, no additional hardware is required, its built into the usb interface. Software wise, you will need to use Chrome for the first setup, as firefox doesnt support WebSerial which is needed gor the first flash.

            If you have any other questions shout out.

            If you want something more “flash, then configure”, tasmota is another option. You flash the device from a webbrowser (https://tasmota.github.io/install), and then next time it boots it starts a wifi network you can connect to, and then you can connect to a web interface and use a gui to configure it and connect it to your HA. Esphome is a little more work upfront, but your configs can be backed up more easily.

  • HappycamperNZ@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    7 months ago

    I do have do ask - does it have to be high tech? Aware you have a system in place, but does it have to match in for the sake of matching?

    • corroded@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      7 months ago

      I think I might have misstated what I already had. In the past, I have built tank-level sensors using the eTape, but never for integration with HA. For example, reading the level of an RV water tank and feeding the output to an LCD screen.

      I currently have no system in place to monitor the levels of my water tanks, other than walking over to them and saying “yep, they’re empty again.” The system doesn’t have to be high-tech, in fact that’s what’s pushing me away from something like EPSHome; it feels like overkill. I just need to be able to read a resistance level that corresponds to a water level and somehow feed it into HA.

      I had considered just using a leak sensor to detect if the tanks are empty, but I’d really like to have an indication of the current level so I know if I have enough left for the next watering cycle or if I need to supplement my tanks from municipal water.