Monitor your car battery in Home Assistant

In this video tutorial, I show how to use a wemos d1 mini, a power shiled and some resistors to wirelessly monitor your car battery voltage and send the readings to Home Assistant over MQTT.

Please check the video description for links for the D1 Mini Power shield I used.




Having the ability to monitor your car battery can prevent some unpleasant surprises. I will show you how I assembled the hardware, loaded the software and installed the monitor in my car.

You will need a wemos d1 mini, a power shield and some resistors. First, I started by removing the power plug and installed the smaller connector to make the hardware more compact.

The D1 mini can measure external voltage up to 3.3v by using a voltage divider using R1=220KΩ & R2=100KΩ . This the voltage within the 0-1 Volt that the ADC can tolerate. To increase the 3.3v to 16v needed for the car battery, we need to increase R1 to 1.44MΩ. To do that we can add another 1.22MΩ in series to get the total 1.44MΩ. I did this by soldering a 1MΩ resistor to a 220KΩ resistor as shown here.

I then connected the D1 mini to my laptop and load the software. Make sure you select the sensor.bin version for the Analog input functionality. I then resumed with a typical Tasmota configuration.

I attached a long wire to the power input terminals to be able to connect them to the car battery.

At the car, I opened the hood and located the fuse box. I found the fuse box to be a safe and secure place to install my device.I first wrapped the device in heat resistant tape to cover any exported pin to withstand the engine heat. Since the entire car chase is ground, I found the nearest screw and connected my ground to it. Next, I located the nearest connection to the battery positive rail and connected my positive power input to it.

I then proceeded with calibrating the range of the analog input. I did this by connecting a multimeter to the battery and read the current voltage (in my case it was 12.73 volts). I then did some trial and error until my reading was 1273 as the analog reading. The last step was closing the fuse box and the car hood.

Back in Home Assistant, I opened the configuration file and added a new MQTT sensor. After I saved, I restarted home assistant for it to take effect. When it came back online, I added the new sensor to the dashboard.

The integration is now complete. You can now use this sensor to trigger alerts!

Thank you for reading!

18 Likes

Very clever. I personally wont be doing it but was great to see and the video was very easy to follow. Good job.

2 Likes

I like it - good work! What if I wanted to monitor my golf cart battery which is 48 volts but during charging can hit 60+ volts?

2 Likes

R1 has to be 6Mohm. That is for 60v.

Oh and you’ll need a different power supply as the wemos power shield takes a max of 24v.

1 Like

Very cool. I recently added a bluetooth battery monitor to my suburban. I may switch over to this instead.

1 Like

You need to be careful with this project’s power consumption: the Wemos can draw 50mA at 3.3V, and I don’t know how efficient the battery shield is. That may not sound like much, but it is an amp-hour each day, and your car battery will be somewhere between 40–80Ah and need a good state of charge to turn the engine over.

If you leave the car unused for more than a couple of weeks (COVID lockdown, holiday abroad?), the monitor will ironically cause the problem it’s meant to be monitoring.

If that’s a likely scenario, there are options for putting the device to sleep and waking up periodically.

6 Likes

Do you have problems with the battery voltage being too low?
I understand the problem, but I’m not sure this is a good solution.
If you would have used the deep sleep and only sent an update once an hour or perhaps every 5 hours then I could see an advantage, but now it will just drain your battery.
Sure it will take a few days, but still.

In my opinion change the battery or put a mains power switch on the car. (keep in mind that is not a good idea on new cars, consult your manual)

1 Like

No, no problem with the battery. I just thought it would be interesting and possibility useful to have some insight into what happens to the battery voltage over time.

Here is my battery after a quick drive:

That is a very valid point. I am looking into reducing the TelePeriod and enabling some energy saving options.

How did you manage to stay within WiFi range during the drive?

3 Likes

It wasn’t in range. The quick increase is when the engine is switched on and the alternator starts charging, then the car goes out of range (the flat section). The drop is when the car returns in range and is switched off, and the battery starts “calming down”.

1 Like

Yes, that is precisely what happened.

Tried clicking on the link to Gitlab but it appears to be dead. I’m VERY interested in making one of your devices to monitor the battery voltage on my solar setup

Does it need to be a Wemos D1 Mini or can any Node MCU be used, I don’t understand the difference and I will just be following your instructions on assembly the unit but here in the UK it seems difficult to get hold of the Wemos.
I want to use your device to monitor 12v batteries on my off grid solar

No the d1 mini is by no means compulsory. The D1 mini is different to a bare esp8266 in that it has a 5v -> 3.3v converter, and a usb port. This means:

  • it can be powered by 5v - although the other connections need to be 3.3v.
  • it can be programmed without an ftdi adaptor via the USB connector.

NodeMCU is an operating system for ESP8266 chips (running nodejs) but it has become a byword for a board that was manufactured to run nodemcu. In short any nodemcu board can do anything a wemos d1 mini can do.

The benefit of the wemos in this design is that it has a power supply board that just plugs in. The pin settings on a nodemcu may be different, but that doesn’t stop you using exactly the same principle to use any esp board.

There are still plenty of places to buy wemos d1 mini clones on aliexpress, or no doubt other similar sites.

4 Likes

Did you succeed in reducing the power consumption ?
I’d be very interested in monitoring my motorcycle battery and its capacity is way less that a car’s :yum:

Kind of annoying that @MrDIY has posted three projects here and then deleted them from gitlab, or not maintained his account, or whatever has happened. Hopefully he will sort it.

Posting the information directly to the forum, rather than us having to revert to other sites that may disappear is always preferable IMHO. And youtube is not a howto, it is a showoff!

I know they are more expensive than Amazon, eBay and AliExpress, but they are quick delivery and look to be legit and not cheap clones. I’ve used them a number of times and been very happy - no connection, just had a similar struggle to find them when I was looking in the UK with a quick turn around!

1 Like

By the way, this fellow has an instructable too, so if the gitlab resource has disappeared for good, see: https://www.instructables.com/id/DIY-Monitor-Your-Car-Battery-Code-Setup/

2 Likes

Thanks for that Nick, the NodeMCU thing has always confused me since I started looking to play with these things :slight_smile: