MQTT DC volt meter

My brain is fried trying to figure this out (which is sad)…
This is only partially related to HA as ideally I will monitor multiple things from it in the end.

I am trying to find a way to monitor/measure a battery’s voltage and possibly current/power and then feed that via MQTT back to my broker. From there I can build automations on how to react/respond. [an OLED/LED/Bar display is okay as well just not as needed as the MQTT]

Ideally I need it to be accurate to the hundredths.

I’ve looked for arduino/nano/pi/esp32 options and have just not found anything good/great.

Any ideas or suggestions?

A esp with some INA*** module could cover your needs, for example a INA260 (or one of the others esphome supports) :slot_machine:

Check the display and light components for your needs :tv:

It’s not clear what that should mean. Without the desired voltage range and other factors that’s just like asking that you want a car that’s very fast :man_shrugging:

Anyway you got the links and the components also will guide you to the data sheets so you should be covered in that direction :wink:

1 Like

Thanks! The battery is 12V 55AH AGM so probably 15V max, 20ish to be safe. The battery drives a few regulators (12V, 6V, 5V) for various needs on the InMoov robot.

Many of the projects I have googled had the resolution to say 12.1V as opposed to 12.09V.

I’ll check this out as an ESP32 would be ideal. Also reviewing some arduino nano options.

I’ve done this for my motorbike, which is plugged into a battery tender.

I forget the actual code, it’s been a couple of years, but it’s using an 8266 with a voltage reducer, together with esphome. This bypasses mqtt and uses the esphome system to automatically generate the entity in Home Assistant

If you search for “esphome battery monitor” you should find quite a few other projects, hopefully this gives you a pointer on the route.

1 Like

That’s like the safe and simple (ultra low budget) version indeed. Such a ready made voltage divider and a d1 mini for example costs probably less than $3 (without shipping) from the country of origin. :point_down:

image
image

As @Corey_Johnson wanted not only have voltage but also current/power readings he needs a little bit more hardware (like some ina*** board as suggested :point_up:).

Sure, the native api from esphome mostly makes mqtt obsolete and with it all the time debugging and fiddling with it :muscle:

1 Like

Yep - that looks like the voltage sensor I used.

Have now found the esphome code I’m using for mine. The sensor reduces the voltage down so that the 82166 can measure it (they have a low voltage threshold). The multiplier in the code then multiplies it back in HA to the true voltage. It took some trial and error whilst measuring the actual voltage with a multimeter but it’s pretty accurate for me.

The sleep did seem to work okay and reduced parasitic drain a lot, but now I’m using a tender I stopped needing it as it now measures directly onto the charging wires from that.

esphome:
  name: voltage
  platform: ESP8266
  board: nodemcu

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: ""

ota:
  password: ""

wifi:
  ssid: "wifissid
  password: "wifipass"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome Voltage Fallback Hotspot"
    password: "wifipass"

captive_portal:

#deep_sleep:
#  run_duration: 20s
#  sleep_duration: 10min

sensor:
  - platform: adc
    pin: A0
    name: "Landrover Voltage"
    update_interval: 60s
    filters:
      - multiply: 24.8

1 Like

Ideally I’ll have it feed to HA and to the robot’s software - this is why MQTT was my goal. I’m pretty sure I can manage both though.

Wow, thank you. I’ve ordered the parts as well as some for other approaches but will try this. I have other 8266 and esp32 devices so this will fit right in.

Lucky you esphome also fully supports mqtt too :wink:

1 Like

Hi i need something similar to messure the amount of volts on the internal power grid here. Since the P1 is alredy used, i asumed it should be possible to put some device that sends out the voltage messurements every minute over mqtt and from there i pick it up in HA … i want to figure out of there there are power peek s in the grid here. Some guidance to built this is appriciated.

Eelco