Monitor your car battery in Home Assistant

Would be nice to know if there has been any change in the reading from anyone who built one of these.
It’s been about three weeks now and my guess is that the voltage will be about the same now as three weeks ago even if the car has not been started once.

My hunch is that unless you have a history of several weeks in HA then you will not see any change except noise just as you can see in OPs image.

Thanks for the replies guys, appreciate the help.
I don’t really understand most of tech chat about programming these devices but I’m generally OK at following instructions and I don’t think this project is beyond me
So would these be perfect for the job (I’m planning on making 2 and have just bought 2 DC power shields via ebay UK)


the pin-outs look to be the same as the wemos.
Would I do everything the same as the instructions because if buying these meant I would have to deviate from them then I would probably buy a genuine wemos via davefi’s link (thanks Dave)

Is anyone using one of these devices?

They work fine.
Don’t worry too much about the pinout of the brand. Instead make sure it’s compatible with ESPHome.
Everything else is easily fixed.

The only thing that could happen if you buy a board with a different pinout is that you need to change the code from “D2” to GPIOxx, since the ports are labled on most boards it’s just to read off the board and change the code accordingly.
About the programming mentioned, as long as it has a USB port it’s fine.
Keep that as your main priorities instead, USB and compatible with ESPHome.

1 Like

Thanks Hellis81, I intend to (attempt) to run tasmota as I already have lots of devices running it via Home Assistant on a Raspberry Pi and it generally does what I want.
So in your opinion will those boards from Amazon suite the job without having to change anything or won’t I know for definite until I physically get them. For £8 I don’t mine taking the chance they will

1 Like

Oh right. Forgot that this project was tasmota.
I just know ESPHome has a list of boards buti have never heard of a board that is not compatible.
I even bought one that was not on the list and it worked fine.

1 Like

See how it says d1 mini - that means it is a wemos d1 mini clone. Should work exactly the same.

This would woek equally well in esphome, but we won’t confuse you :slight_smile:

1 Like

Great thanks. Good idea not to confuse me, its easily done

@MrDIY, your project is promising. Is it doable without tasmotising and just using esphome? With home assistant running off a SD card in RPI4+ 4G.

of course it is. look at adc in the esphome docs.

So sorry guys, I haven’t checked this post in a while and haven’t received any email notifications - my bad.

I migrated the code from gitlab to Instructables in the hope they will be easier to read/follow but my mistake was making the gitlab repos private. I just fixed that.

Thanks a lot Hellis81 & Nick for answering everyone’s questions - very thoughtful answers.

1 Like

Has anyone done this using Esphome instead of Tasmota? If so, would you please post and share your yaml code?

Sorry for the dumb question but what will happen if you don’t use the resistors and I connect directly the 12V to the AO pin of the D1 mini?

Thanks!

Hi, if you connect the battery directly without increasing the voltge divider resistor, you will feed 4V into the ESP8266 which is rated for Max 1V and destroy it.

You might want to watch this ESP8266 intro video to get more context - specifically jump to 1:42 where it shows the voltage divider part. https://youtu.be/dGrJi-ebZgI

As for ESPHome, I don’t have experience in that domain and I rather leave it to someone who does - so I can’t really answer that.

Hope that helped.

1 Like

Looks like you can accomplish this using the DEEP SLEEP feature. “Further Reading

I’m going to test it and and see how it works.

Although unconfirmed, based on some other threads, Deep Sleep is not recomended with Esphome, as it causes some errors in HA.

Actually, I implemented this using Esphome and deep sleep and everything works well.

Cool, do you mined sharing your config?

Sure!

Make sure that you have GPIO16 (pin D0 on the D1 mini board) connected to ground RST.

substitutions:
  devicename: battery_voltage
  devicename_friendly: Car Battery
  ip_address: 192.168.2.219


esphome:
  name: ${devicename}
  platform: ESP8266
  board: d1_mini
  
<<:  !include common/wifi_setup.yaml

<<:  !include common/logger.yaml

<<:  !include common/ota.yaml

deep_sleep:
  run_duration: 20s
  sleep_duration: 60min
  id: battery_deep_sleep

mqtt:
  broker: 192.168.2.XXX
  username: !secret mqtt_username
  password: !secret mqtt_password
  
  on_message:
    - topic: deep_sleep/ota_mode
      payload: 'ON'
      then:
        - deep_sleep.prevent: battery_deep_sleep
  
    
    - topic: deep_sleep/ota_mode
      payload: 'OFF'
      then:
        - deep_sleep.enter: battery_deep_sleep



binary_sensor:

  - !include common/binary_sensor_network_status.yaml
  

sensor:

  - platform: adc
    pin: A0
    name: "Voltage"
    update_interval: 10s
    filters:
      - multiply: 14.5583
    
    
  - !include common/wifi_signal.yaml
  
  - !include common/uptime.yaml
  
switch:

  - !include common/device_restart_switch.yaml
  

text_sensor:



  - !include common/mac_address_info.yaml

  - !include common/version.yaml
  
  - !include common/wifi_info.yaml

These scripts are in HA to stop/resume deep sleep if needed for an OTA update.

####################################################################    
stop_deep_sleep_on_esphome_devices:
  alias: Stop Deep Sleep
  sequence:
  - service: mqtt.publish
    data:
      topic: deep_sleep/ota_mode
      payload: 'ON'
      qos: 2
      retain: true
  - service: notify.mobile_app_my_iphone
    data:
      title: Deep Sleep
      message: Deep sleep turned off for OTA updates
      
####################################################################
resume_deep_sleep_on_esphomedevices:
  alias: Resume Deep Sleep
  sequence:
  - service: mqtt.publish
    data:
      topic: deep_sleep/ota_mode
      payload: 'OFF'
      qos: 2
      retain: true
  - service: notify.mobile_app_my_iphone
    data:
      title: Deep Sleep
      message: Deep sleep turned on

####################################################################

2 Likes

Thanks, did you try with the API and not MQTT?

I don’t remember where is the documentation, but I am 99.99% sure that you cannot use the API with deep sleep.

@laca75tn That’s what I meant by my previous statement.

Fake news

You should use MQTT not API for deep sleep.