These batteries in most cases are connected to an I2C/SMBus of the laptop and they use the Smart Battery protocol, which is a standard of most advanced battery powered systems, especially laptops.
The hardest part normally is to find the pinout of these batteries, but since Acer easily leaks complete motherboard schematics, it has not been hard to find these pinouts.
For now i've worked with a AL10B31 battery and a AS07B41 battery, they have different pinout, but both can be found on the respective schematics of the Quanta ZE6 and Quanta ZO3. One important thing to be careful about is that once you are using the connector from the motherboard outside the laptop, it's easy to insert it reversed by accident and cause serious damage both to the arduino and to the battery itself.
Charging the battery and using it
The AL10B31 and AS07B41 batteries are both 11.1V , that means that there are 3 cells in series, so to charge them you have to use a CC-CV power supply with 12.6V ( 4.2*3 ) and at most 1.5-2 amperes.
The battery of the Acer Aspire One ( Quanta ZE6 ) has an additional safety measure that will prevent you from charging it by just applying 12.6V on it's + and - terminals.
There's the pin 3 that has to be connected to ground with a 1KOhm resistor to enable the battery.
Quanta ZE6 battery connector |
Even if in the above schematic it says "short", i've used 1KOhm resistor because that's the resistance i've measured on the netbook's motherboard between this pin and ground.
The AS07B41 that has same pinout of the AS07A(31/32/41) used by Quanta ZO3 but reversed and it does not have any safety measure that remove power from it's + and - pins if not connected to the laptop, so if you just want to charge it you are ready to go with 12.6V CC-CV and at most 2 amperes
Quanta ZO3 battery connector |
Connecting to and monitoring the battery with an arduino
SMbus and I2C are physically compatible with each other, so like in the laptops i2c devices and battery share same bus, you can use the battery almost like and i2c device.
The only problem is that arduino Wire library does not give you much control over speed and start/stop, so, you will have to use a software i2c library.
The one i've used is http://playground.arduino.cc/Main/SoftwareI2CLibrary , this library allows both setting speed and having control on i2c start and stop.
Before including the .h of the library ( if you are too lazy to put the library in a folder, like me , you can just paste the contents on you sketch ), you have to define which pins to use for software I2C.
#define SDA_PIN 3
#define SDA_PORT PORTD
#define SCL_PIN 2
#define SCL_PORT PORTD
#define I2C_SLOWMODE 1
On the arduino mega 2560 these are pins 19 for SCL ( MBCLK ) and pin 18 for SDA ( MBDATA ) .
If you are using another type of arduino or you want to use different pins use https://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0 to find out what AVR port and pin number to use on the #define
You have also to define I2C_SLOWMODE in the case you have problems with communicating to the battery.
I'm using that sketch to read values from the battery:
LiquidCrystal lcd(12,11,50,51,52,53);
byte deviceAddress = 11;
#define VOLTAGE 0x09
#define TEMPERATURE 0x08
#define CURRENT 0x0a
#define CAPACITY 0x10
#define TIME_TO_FULL 0x13
#define CHARGE 0x0d
void setup()
{
lcd.begin(16,2);
//pinMode(22,INPUT_PULLUP);
//pinMode(23,INPUT_PULLUP);
Serial.begin(115200); // start serial for output
Serial.println(i2c_init());
//pinMode(22,INPUT_PULLUP);
//pinMode(23,INPUT_PULLUP);
scan();
}
int fetchWord(byte func)
{
i2c_start(deviceAddress<<1 | I2C_WRITE);
i2c_write(func);
i2c_rep_start(deviceAddress<<1 | I2C_READ);
byte b1 = i2c_read(false);
byte b2 = i2c_read(true);
i2c_stop();
return (int)b1|((( int)b2)<<8);
}
void scan()
{
byte i = 0;
for ( i= 0; i < 127; i++ )
{
Serial.print("Address ");Serial.print(i);
bool ack = i2c_start(i<<1 | I2C_WRITE);
if ( ack )
Serial.println("OK");
else
Serial.println("NO");
i2c_stop();
}
}
void loop()
{
int v = fetchWord(VOLTAGE);
Serial.print("Voltage: ");
Serial.println(v);
lcd.clear();
lcd.print((float)v/1000.0);lcd.print("V ");
Serial.print("Temp: ");
unsigned int tempk = fetchWord(TEMPERATURE);
float tempc = ((float)tempk)/10.0-273.15;
lcd.print(tempc);
lcd.print("C");
lcd.setCursor(0,1);
Serial.println(tempc);
Serial.print("Current (mA):" );
int ma = fetchWord(CURRENT);
lcd.print(ma);lcd.print("mA ");
Serial.println(ma);
Serial.print("Capacity (mAh):" );
int mah = fetchWord(CAPACITY);
Serial.println(mah);
int ch = fetchWord(CHARGE);
Serial.print("Charge PCT: ");Serial.print(ch);
lcd.print(ch);lcd.print("% ");lcd.print(float(mah)/1000.0);lcd.print("Ah");
Serial.print(" Minutes remaining for full charge: ");
Serial.println(fetchWord(TIME_TO_FULL));
delay(5000);
}
I've omitted the beginning because it's just the software i2c library and some includes like LiquidCrystal.h .
Quanta ZE6 battery |
Charging AS07B41 |
Charging AS07A(31,32,41) , Quanta ZO3 |
Charging AS07B31 ( Same pinout as AS07B41 ) |
You have also, as the master of the i2c bus provide the pullup, so you have to use 2 10K resistors connected between +5V and the SDA,SCL lines.
Once you enable the battery ( if required ) , you should be able to communicate with it using that code.
If you are interested on monitoring other parameters, like remaining time to 0%, design voltage , manufacture date , etc, you can see what is the ID to use here http://sbs-forum.org/specs/sbdat110.pdf
Finally, i remind to who is going to use these batteries, that they have high energy density, so they can start a fire or explode if mishandled.
Edit: I've discovered that sometimes reading are wrong, lowering I2C frequency solves that issue , to do that modify
#if I2C_SLOWMODE
#define I2C_DELAY_COUNTER (((I2C_CPUFREQ/25000L)/2-19)/3)
#else
to
#if I2C_SLOWMODE
#define I2C_DELAY_COUNTER (((I2C_CPUFREQ/15000L)/2-19)/3)
#else
#if I2C_SLOWMODE
#define I2C_DELAY_COUNTER (((I2C_CPUFREQ/15000L)/2-19)/3)
#else
How do you control charging, by arduino or by an external charger?? Li Ion batteries need a dedicated controller for this and laptops have s special Maxim chip in charger section.
RispondiEliminaHello!
RispondiEliminaCan you help me do the same thing. I have one Toshiba Satelite battery. I don't need the LCD monitor to look over the voltage and precentage. I will monitor them trough the Serial.
I want to achieve this result with Arduino Uno.
Please help :)
Have you tried looking up laptop's motherboard schematics?
EliminaIm tryng for a while now to do this but the library it doesn't work, on serial monitor appears only weirds characters, can u please help me with your original library that u used and sketch and send them to my email plss? im tryng to do this for a very long time, pls help me:( send pls at adycobra2003@yahoo.com
RispondiEliminaNice. I bacame interested in laptop batteries after my dell laptop failed to charge.
RispondiEliminaTo admit your nice write , I`d say one could also follow Smart Battery System Specifications for example http://sbs-forum.org/specs/sbdat110.pdf for more commands. There is chance, many laptop battery manufacturers might follow these specs.
To charge laptop battery (my case old R51 batt) I set CC/CV lab power supply at 12,6 V limiting current to say 2000 mA (better look inside for charge current). I am not sure it is healthiest method, but without dedicated charger seems to work OK. Not all laptop batteries are the same so one shoud do it with care and supervising at least. For example I found, cheap chinese laptop battery replacement I own has no thermal control inside at all :)
It seems there is no way to know which exactly IC was used inside of smart battery without opening it. Say bq2060 and bq2084 would respond commands the same way, but datasheets are not same.
Do you have any info on that? Is there any way to detect chip model used inside?
And by the chance, have you ever tried communicate to sony InfoLithium battery (camcorder, 3 terminals +/- and data) ? They seem to use some kind of one wire protocol. It seems to be interesting to play with too :)
Hi, charging with CC-CV is fine as long the battery chip terminates charging, which on acer batteries happens, at least the ones in the article.
EliminaTo know which chip is inside of them is not very easy because most of these chips are programmable, maybe if you find the datasheet you could try to guess by issuing manufacturer specific commands to it.
About the 3 terminal ones never tried communicating with them, but it sounds like an interesting project when i'll get hands on a logic analyzer, probably they work in a similiar manner to DHT11 sensors i guess.
Ah and don't forget to check the new blog at https://linuxehacking.ovh , this one is no longer updated
Hello!
RispondiEliminaVery interesting blog.
I´m trying to read "Relative SOC" parameter in a Smart Battery with SMBus communications with a Arduino M0 Pro.
I tried to do something similar to your example but I have a problem with SoftI2CMaster library. It includes library and when I compile it I have some errors in it. It seems that is for AVR based microcontrollers, and M0 Pro Arduino has SAMD21 microcontroller, ARM based one.
¿What can I do to use SoftI2CMaster library?
Hello,
RispondiEliminaThank you! I used it and port to PIC24FJ256GA106.
#define I2C_WRITE 0
#define I2C_READ 1
void initI2C(long fcy) {
const long BUS_FRQ = 4000L; // 1kHz
OpenI2C1(I2C_ON
& I2C_IDLE_CON
& I2C_7BIT_ADD
& I2C_STR_EN
& I2C_GCALL_DIS
& I2C_SM_DIS
& I2C_IPMI_DIS
,
(fcy /(2*BUS_FRQ))-1);
IdleI2C1();
}
int getAkkuParam(unsigned char code) {
unsigned char batteryAddress = 0xB;
StartI2C1();
IdleI2C1();
MasterWriteI2C1(batteryAddress<<1 | I2C_WRITE);
IdleI2C1();
MasterWriteI2C1(code);
IdleI2C1();
RestartI2C1();
IdleI2C1();
MasterWriteI2C1(batteryAddress<<1 | I2C_READ);
IdleI2C1();
unsigned char b[2] = {0,0};
// unsigned int result = if OK return 0
MastergetsI2C1(2, b, 50000);
StopI2C1();
IdleI2C1();
return (int)b[0]|((( int)b[1])<<8);
}
Thanks,
Yuriy
How to make Laptop Battery charge. Controller Controller chip With arduino
RispondiEliminaAcer switch 3, Acer alienware laptop and Acer swift 3 which one is worth for buying?
RispondiEliminaAcer Swift 3 Laptops are not the most popular – according to the sales of the company consistently acts in the role of catch-up. However, at the Acer, as in others, there is quite a successful model, are worth paying attention to. Today we look at one of them.
RispondiEliminanice content with diagram explanation liked it
RispondiElimina<a href='http://totoodo.com/acer-laptop-service-center/">Acer laptop service center</a>
Great post.Thanks for one marvelous posting! I enjoyed reading it;The information was very useful.Keep the good work going on!!
RispondiEliminaAcer laptop
I want the project in full detail as possible please help
RispondiEliminaExcellent post. Can these batteries charge and discharge at the same time ? I mean can they be charged while powering a device ?
RispondiElimina