Monitor your car battery in Home Assistant

Can you elaborate on this a little, why not for API?

I would have to find the thread(s) that explain it. It is probably the same one that gave you the impression that deep sleep is not recommended.

To GROUND or RST?

You are correct. D0 must be connected to RST. I fixed my post. Thanks!

1 Like

Hello I am trying to get this up and running via esp home but when uploading your config yaml I get an error
Error reading file /config/esphome/common/binary_sensor_network_status.yaml: [Errno 2] No such file or directory: ‘/config/esphome/common/binary_sensor_network_status.yaml’

this text is in red in your post so I think it needs to be changed for my setup but I am at a loss as what too? If you could expand a little please?

Can i use this to moniter my 12v 165ah solar battery
Tell me.

Those are pointers to included files. You can replace those with the ‘regular’ code you would have in an esphome node for wifi,log, ota etc
I can post the code in the more traditional way on Monday. Thanks

1 Like

Yes you can, just make sure that you have the correct resistors for the battery Amperage, otherwise you will burn your microprocessor.

1 Like

That would be great , thank you

Try this. This is the version without the included files.

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


esphome:
  name: ${devicename}
  platform: ESP8266
  board: d1_mini
  
wifi:
  networks:
    ssid: "HomeAssistant"
    password: "MyPassword"
    priority: 1
    
  #use_address: ${devicename}.local

  power_save_mode: none  

  reboot_timeout: 15min

  manual_ip:
    
    static_ip: ${ip_address}
    subnet: 255.255.255.0
    gateway: 192.168.1.1
    dns1: 192.168.1.1

  ap:
    ssid: "${devicename} Hotspot"
    password: "AnotherPassword"

  fast_connect: true     


captive_portal:    

logger:
  baud_rate: 0
  level: VERBOSE

ota:

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

mqtt:
  broker: 192.168.1.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:

  - platform: status
    name: ${devicename} network status
    id: ${devicename}_network_status
  

sensor:

  - platform: adc
    pin: A0
    name: "Voltage"
    update_interval: 10s
    filters:
      - multiply: 14.5583
    
    
  - platform: wifi_signal
    name: ${devicename} WiFi Signal
    update_interval: 60s
  
  - platform: uptime
    name: ${devicename} Uptime
    unit_of_measurement: h
    filters:
      - lambda: return int((x + 1800.0) / 3600.0);
  
switch:

  - platform: restart
    name: ${devicename} Restart
    id: restart_${devicename} 
  

text_sensor:

  - platform: version
    name: ${devicename} ESPHome version

  - platform: wifi_info
    ip_address:
      name: ${devicename} IP Address
    ssid:
      name: ${devicename} Connected SSID 
    bssid:
      name: ${devicename} BSSID

2 Likes

thank you I will have a look tomorrow.

How about a monitor to open the garage door when the car starts up.

( Although a non HA solution might be better)

Just trigger on the voltage going above 13.7 volts (to be on the safe side)

2 Likes

hello, I have successfully got the module up and running and talking to home assistant-Thank you very much.
I just need to play with the multiplier value as it is 0.10 to low.
I would like to add another 2 cars , so other than changing the ip address and the device name would there be any other issues?
Thanks

@laca75tn Also would it be possible to prevent deep sleep over a preset voltage say 13.5 volts when the engine is running, that way the wifi will be awake when the car arrives home, and could be used then for other automations ?

Yes, you can add that functionality using the on_value_range. It would be something like the code below. Check the indentation and syntax to make sure is correct.

sensor:

  - platform: adc
    pin: A0
    name: "Voltage"
    update_interval: 10s
    filters:
      - multiply: 14.5583

    on_value_range:
      below: 13.5
      then:
        - deep_sleep.prevent: battery_deep_sleep
1 Like

Emm… Will that not prevent deep sleep when it runs on battery?
Meaning while the car is parked the ESP will be on, when the car is running the deep sleep is activated?

Probably it should be above not below.
But even that will not be enough I believe.
If it does not know that the car is running then it can’t prevent the deep sleep.
So worst case scenario, if you update every 10 minutes then you could be unlucky to start the car just after an update, then it won’t go out of deep sleep until the next update which is almost 10 minutes later.

If I recall correctly, you can wake it up with a pin.
If you take a wire that is connected to something that is only on while the car is running then you could add a voltage divider to this and feed it to the pin, so as you start the car this pin goes high => ESP wakes up.

I don’t have all the details of what Philip wants to accomplish. I was just showing how he can prevent deep sleep based on a value. He can use above/below to prevent/enter deep sleep depending on what he wants to accomplish.

Only the Esp32 allows you to wake up from a pin, my example is using a D1 Mini 8266 and I can’t do that. Thanks.

1 Like

Sorry, that I didn’t reply to this sooner, I never received a notification about it. :frowning: Yes, you are correct, you just need to change the IP Address and name of the node. I would explicitly make the deep_sleep value to be internal to prevent confusion with the other node.

deep_sleep:
  run_duration: 20s
  sleep_duration: 60min
  id: battery_deep_sleep
  internal: true
1 Like

thank you for your help, I am using D1 minis , and I will have a play and see if I can get it working, I was just thinking long term for possible future automations.