Sorting by

×

Nissan Leaf Battery Monitoring

Last modified date

Comments: 0

esphome-leafbat2.yaml

##########################################    
# Name of our ESPHome device
##########################################    
esphome:
  name: esp-leafbat2

##########################################    
# Specific board for ESPHome device
# https://esphome.io/devices/
##########################################    
esp8266:
  board: d1_mini

##########################################    
# Enable Logging
##########################################    
logger:

##########################################    
# Enable the Home Assistant API
# The key gets pasted in HA when asked for
# DO NOT enable this if MQTT is NOT enabled
##########################################    
api:
  encryption:
    key: "long_random_key_r8I0sg7ssglsrcggas4sLdfwsasnM4pxesySa5c="

##########################################    
# Enable Over the Air Update Capability
# Safe mode will detect boot loops
##########################################    
ota:
  safe_mode: true
  password: "78e272b9211391518b0e6f4ff5cbd11e"

##########################################    
# Use Wifi (with DHCP here)
# (credentials are in secrets file here)
# https://esphome.io/components/wifi.html
##########################################    
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # Details for fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-Leafbat2 Fallback Hotspot"
    password: "random_password_for_fallback"

# Enable the captive portal
captive_portal:

##########################################    
# Web Portal for display and monitoring
# It will display sensor info, and allow
# ota updates (if enabled) but has
# a username/password that you put here
##########################################    
web_server:
  port: 80
  auth:
    username: admin
    password: !secret web_server_password
    
##########################################    
# MQTT Monitoring
# https://esphome.io/components/mqtt.html
##########################################    
mqtt:
  broker: 192.168.3.200
  topic_prefix: esphome/esp-leafbat2
  username: mqtt_user
  password: !secret mqtt_password
  #  
  # A way to prevent deep sleep using MQTT command
  # Use any topic you like.
  on_message:
    - topic: esphome/leafbat2/deepsleepoff
      payload: 'ON'
      then:
        - deep_sleep.prevent: deep_sleep_1
    - topic: esphome/leafbat2/deepsleepon
      payload: 'ON'
      then:
        - deep_sleep.enter: deep_sleep_1

##########################################    
# Deep Sleep
# Remember that the reset pin will need to
# be connected to a GPIO to wake up...
# https://esphome.io/components/deep_sleep.html
##########################################    
deep_sleep:
  run_duration: 20s
  sleep_duration: 10min
  id: deep_sleep_1
  
##########################################    
# SENSORS
# Pop all your sensors down here
# https://esphome.io/components/sensor/
##########################################    
sensor:
  # Quality of Wifi in dBm
  - platform: wifi_signal
    name: "WiFi Signal"
    update_interval: 20s
  # Analog sensor for voltage reading (A0)
  - platform: adc
    pin: A0
    name: "Battery Voltage"
    update_interval: 20s
    filters:
      - multiply: 18.52 # trial and error calc/measure
      - calibrate_linear:
        - 5.99 -> 6.0
        - 11.98 -> 11.99
        - 16.98 -> 16.98

Leave a Reply

Your email address will not be published.

Post comment