Smart Battery Guard
Monitor your vehicle's battery and get Home Assistant notifications when its power is getting low.
![Smart Battery Guard](/content/images/size/w2000/2023/09/header_small.jpg)
Skill | Cost | Time |
---|---|---|
2 / 5 | ~7 Euro | ~20min |
Picture this: your motorcycle has been sitting idle in your garage for a bit, and suddenly, your friends invite you for a ride on a beautiful day. Excited, you gear up, only to discover your battery is dead. Disappointing, isn't it? But fret not! In this guide, we'll walk you through building a Smart Battery Guard using a Wemos D1 mini, a 1M2 Ω
resistor, and a DC Power Shield, allowing you to monitor your vehicle's battery and get Home Assistant to notify you when its power is getting low.
Bill of materials
- Wemos LOLIN D1 Mini or D1 Mini Pro (with external antenna)
- Wemos DC Power Shield
- 1M2 Ω or 1M5 Ω resistor
- Waterproof Black DIY Housing (69 x 42 x 23mm (L x W x H))
Solution - Hardware
Incorporating a Wemos DC Power Shield eliminates the requirement for a separate power source, allowing the battery to power the D1 Mini directly. This shield is designed to accept input voltages ranging from 7
to 24
volts, making it an ideal match for our project requirements.
Safe and accurate measurements are vital for a 12V
battery that can reach nearly 15V
during charging. The Wemos D1 Mini features a voltage divider circuit employing 220kΩ
and 100kΩ
resistors. While the onboard ESP8266 A0
port reads up to 1V
, the voltage divider allows for readings up to 3.2V
, effectively converting the higher voltage to a safe 1V
range.
![](https://smarthomegeeks.io/content/images/2023/10/voltage_divider_formula-2.png)
To bring down the 15V
to the D1 Mini's safe reading range, we add a 1M2 Ω
resistor in series with the battery's positive terminal. This setup reduces the 15V
to approximately 0.99V
, allowing the D1 Mini to precisely measure the battery's voltage without risking damage to its internal components.
![](https://smarthomegeeks.io/content/images/2023/10/dc_power_board_with_resistor-1.png)
Alternatively, a 1M5 Ω
resistor can reduce the input to about 0.82V
. Although this slightly reduces precision, it also guarantees a safe measurement.
Desoldering the DC barrel connector from the shield enables us to shrink the entire setup, making it compact enough to fit inside a small, waterproof enclosure.
Wemos LOLIN D1 Mini Pro
If your car or motorcycle isn't near the WiFi network, opting for a D1 Mini Pro is a great solution. It provides the option to attach an external antenna, extending the range. Remember to re-solder the 0 Ω
resistor on the PCB to switch from the onboard antenna to the external connector (in red below).
![](https://smarthomegeeks.io/content/images/2023/10/d1_mini_pro_small-3.png)
![](https://smarthomegeeks.io/content/images/2023/10/d1_mini_pro_back_small-3.png)
Solution - Software
Our Arduino code reads the battery voltage through the voltage divider and publishes it to an MQTT server at a configurable interval. The incorporation of MQTT Discovery ensures hassle-free integration with Home Assistant.
![](https://smarthomegeeks.io/content/images/2023/10/home_assistant_2.png)
![](https://smarthomegeeks.io/content/images/2023/09/home_assistant.png)
Downloads
Result
Once linked to the battery, the module will publish voltage data and enter deep sleep mode to conserve power for the specified interval. The Keep Awake
switch prevents sleep mode, allowing over-the-air updates and calibration by connecting a voltmeter to the battery and saving the reading directly onto the module.
Here are some images showcasing the D1 Mini Pro version with an external antenna and the standard D1 Mini in a custom-designed 3D printed case.
![](https://smarthomegeeks.io/content/images/2023/10/battery_guard_disassembled.jpg)
![](https://smarthomegeeks.io/content/images/2023/10/battery_guard_open.jpg)
![](https://smarthomegeeks.io/content/images/2023/10/battery_guard_finished.jpg)
![](https://smarthomegeeks.io/content/images/2023/10/d1_mini_top.jpg)
![](https://smarthomegeeks.io/content/images/2023/10/case_open.jpeg)
![](https://smarthomegeeks.io/content/images/2023/10/case_closed-1.jpeg)
Conclusion
With your Smart Battery Guard up and running, you're no longer in the dark about your vehicle's battery status. Embrace the power of IoT and automation to stay connected with your car or motorcycle, ensuring they're always ready to hit the road when you are. This project enhances your vehicle's health and serves as a testament to what DIY electronics and programming can achieve. So, gear up, get your hands dirty, and embark on this exciting journey of building your Smart Battery Guard! Safe travels! 🚗🏍️