This device, according to the wizard, is able to extend the battery life of the laptop several times. The idea to make such a device came to the master after the battery on a laptop bought two years ago sat down after 30 minutes, and a year later, the laptop turned off after 5 minutes of operation.
After searching for information on this problem on the Internet, the master found a study by CADEX which stated that reducing the battery charge to 40% extends its battery life by 6 times.
Thus, the solution proposed by the CEO of CADEX (a company that develops battery management tools) is to charge the battery when it is discharged to 40%, and turn off charging when it reaches 80% charge. But to constantly keep the battery charged at a level of 40 to 80% is not easy, if not impossible. That's why the wizard developed BatteryCare, a module for disconnecting or reconnecting the power supply to a PC. It is controlled via Bluetooth with a program that monitors the battery level.
For the manufacture of such a device, the following materials are needed:
Bluetooth module HC-05;
-Relay;
Microcontroller ATtiny85;
The circuit is quite simple and consists of an ATtiny85 microcontroller, a Bluetooth HC-05 module and a 230 V relay. In addition, there is a 5V power supply for electronics.
The code is also very simple. Charging starts when the “c” command is recognized and ends with the 'd' command. The wizard uses the SoftwareSerial library because ATtiny85 does not have hardware serial communication.
#include "SoftwareSerial.h"
#define RELAY_OUTPUT 4
const int rx = 3;
const int tx = 1;
SoftwareSerial mySerial (rx, tx);
int i = 0;
char buf [12];
int inByte = 0;
void setup ()
{
pinMode (rx, INPUT);
pinMode (tx, OUTPUT);
pinMode (RELAY_OUTPUT, OUTPUT);
digitalWrite (RELAY_OUTPUT, HIGH); // turn the RELAY off
mySerial.begin (9600);
}
void loop ()
{
if (mySerial.available () & gt; 0)
{
inByte = mySerial.read ();
if (inByte == 'c')
{
digitalWrite (RELAY_OUTPUT, LOW); // turn the RELAY on
}
else if (inByte == 'd')
{
digitalWrite (RELAY_OUTPUT, HIGH); // turn the RELAY off
}
}
}
The program also needs to be installed on a laptop.
The main principle of the program is to send the character “c”, activate the power supply and send the character “d” to turn it off. These commands are determined by the selected thresholds.
To communicate via Bluetooth, you must first pair the HC-05 module with a PC (parameters> Bluetooth devices and others>, add a Bluetooth device or other device), the requested code is 1234 or 0000.
You must store .exe in the same folder as .dll.You can also start BatteryCare at startup by placing the shortcut for .exe in: C: \ ProgramData \ Microsoft \ Windows \ Start Menu \ Programs \ Startup
The wizard developed this program, trying to simplify the user interface as much as possible.
This program turns off the power when it detects computer hibernation. However, it did not work out immediately to set the same mode when the power was turned off.
To facilitate connecting the module at startup, the wizard created a small configuration file called “config.txt”, it contains the serial communication port number that the computer uses to transmit information via Bluetooth, as well as the charge and discharge threshold.
To overcome the problem of disconnecting the module when turning off the PC, the wizard used a script, or rather two. When the PC shuts down, the BatteryCare_discharge.bat script is executed. He will run the ps1 script himself, which will send the “d” character to the communication port.
To configure the script to run when the computer is turned off, you need to do the following:
Turn on PowerShell script execution:
open PowerShell in the admin section: set-executepolicy unrestricted
win + r gpedit.msc: in user configuration / window settings / scripts / logOFF
Click add, then find and copy 2 files in the open folder and select the .bat file.
This is really not the best way to do this ... but it is the fastest that the master was able to implement.
All software is available at this address: https://github.com/David-LETINAUD/BatteryCare
The master has been using this device for more than 3 years and has no complaints.