Skip to content

Commit 743bbe1

Browse files
committed
Documentation
1 parent 6d33afc commit 743bbe1

File tree

7 files changed

+186
-10
lines changed

7 files changed

+186
-10
lines changed

.github/workflows/TestCompile.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
# This is the name of the workflow, visible on GitHub UI.
99
name: TestCompile
10-
on: push
10+
on:
11+
workflow_dispatch: # To run it manually
12+
description: 'manual build check'
13+
push:
1114
jobs:
1215
build:
1316
name: Test compiling examples for UNO

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@
33
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
44
[![Commits since latest](https://img.shields.io/github/commits-since/ArminJo/Smart-Battery-Module-Info_For_Arduino/latest)](https://github.com/ArminJo/Smart-Battery-Module-Info_For_Arduino/commits/master)
55
[![Build Status](https://github.com/ArminJo/Smart-Battery-Module-Info_For_Arduino/workflows/TestCompile/badge.svg)](https://github.com/ArminJo/Smart-Battery-Module-Info_For_Arduino/actions)
6-
[![Hit Counter](https://hitcounter.pythonanywhere.com/count/tag.svg?url=https%3A%2F%2Fgithub.com%2FArminJo%2FSmart-Battery-Module-Info_For_Arduino)](https://github.com/brentvollebregt/hit-counter)
6+
![Hit Counter](https://visitor-badge.laobi.icu/badge?page_id=ArminJo_Smart-Battery-Module-Info_For_Arduino)
77

88
Prints SBM controller info
99

10-
Based on https://github.com/PowerCartel/PackProbe from Power Cartel http://powercartel.com/projects/packprobe/.
10+
Based on the unmaintained [PackProbe program](https://github.com/PowerCartel/PackProbe) from Power Cartel http://powercartel.com/projects/packprobe/.
1111

1212
# Disclaimer
13-
**I do not know how to enter full access mode, clear permanent failure or unlock any controller IC.** Unfortunally according to most datasheets, you need an unlock key.
13+
**I do not know how to enter full access mode, clear permanent failure or unlock any controller IC.** Unfortunately according to most datasheets, you need an unlock key.
1414
See also this [article from 2011](https://media.blackhat.com/bh-us-11/Miller/BH_US_11_Miller_Battery_Firmware_Public_WP.pdf).
1515
Extract: *Macbook batteries ship with a default unseal password (0x36720414). This was found by reverse engineering a Macbook battery update. On Macbook batteries, the full access mode password is also hardcoded and default (0xffffffff).*
1616

1717
## Compile with the Arduino IDE
1818
Download and extract the repository. In the Arduino IDE open the sketch with File -> Open... and select the SBMInfo folder.
1919

2020
## Identifying the right connection
21+
Valuable information about battery pinout can also be found [here](https://www.laptopu.ro/community/laptop-battery-pinout/) or [here](https://powercartel.com/projects/packprobe/battery-connection/).<br/>
2122
The minimal connector layout is: | GROUND | THERMISTOR (103AT) | CLOCK | DATA | VCC (11 or 14 volt) | (clock and data my be switched).
2223
- The **thermistor** connection has 10 kOhm to ground at 25 degree celsius.
23-
- **Clock** und data connectors have the same resistance (around 0.3 to 1 MOhm) to ground.
24+
- **Clock** und data connectors have the same resistance (around 0.3 to 1 MOhm) to ground and are next to each other.
2425
- **VCC** may not be enabled. Sometimes it gets enabled when *Host Present* is connected to ground or clock and data are pulled high to 3.3 or 5 volt.
2526

2627
Some packs (e.g.for IBM-T41 with bq29310) require once an external voltage (e.g. 11 volt) at the VCC connector to initially get alive after full discharge condition.
@@ -201,4 +202,4 @@ Average minutes remaining until empty: 16 h 11 min
201202
### Version 3.1.1
202203
- Better prints at scanning.
203204

204-
#### If you find this library useful, please give it a star.
205+
#### If you find this program useful, please give it a star.

SBMInfo/ADCUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
#define SHIFT_VALUE_FOR_REFERENCE REFS2
8181
#define MASK_FOR_ADC_REFERENCE (_BV(REFS0) | _BV(REFS1) | _BV(REFS2))
8282
#else // AVR_ATtiny85
83+
8384
#define SHIFT_VALUE_FOR_REFERENCE REFS0
8485
#define MASK_FOR_ADC_REFERENCE (_BV(REFS0) | _BV(REFS1))
8586
#endif

SBMInfo/SBMInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* SBMInfo.h
33
*
4-
* Copyright (C) 2016 Armin Joachimsmeyer
4+
* Copyright (C) 2016-2021 Armin Joachimsmeyer
55
66
*/
77

SBMInfo/SBMInfo.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,8 @@ bool checkForAttachedI2CDevice() {
460460
Serial.print(F("Transmission error code="));
461461
if (tRetCode == 2) {
462462
Serial.print(F("\"address send, NACK received. Device not connected?\""));
463+
} else if (tRetCode == 5) {
464+
Serial.print(F("\"timeout while waiting until twi is ready\""));
463465
} else {
464466
Serial.print(tRetCode);
465467
}
@@ -474,7 +476,7 @@ bool checkForAttachedI2CDevice() {
474476
uint8_t scanForAttachedI2CDevice(void) {
475477
static unsigned int sScanCount = 0;
476478
int tFoundAdress = SBM_INVALID_ADDRESS;
477-
for (uint8_t tI2CAddress = 0; tI2CAddress < 127; tI2CAddress++) {
479+
for (uint_fast8_t tI2CAddress = 0; tI2CAddress < 127; tI2CAddress++) {
478480
Wire.beginTransmission(tI2CAddress);
479481
uint8_t tOK = Wire.endTransmission(true);
480482
if (tOK == 0) {
@@ -1001,7 +1003,7 @@ void printBatteryStatus(struct SBMFunctionDescriptionStruct *aSBMFunctionDescrip
10011003

10021004
void printFunctionDescriptionArray(struct SBMFunctionDescriptionStruct *aSBMFunctionDescription, uint8_t aLengthOfArray,
10031005
bool aOnlyPrintIfValueChanged) {
1004-
for (uint8_t i = 0; i < aLengthOfArray && sGlobalReadError == 0; ++i) {
1006+
for (uint_fast8_t i = 0; i < aLengthOfArray && sGlobalReadError == 0; ++i) {
10051007
readWordAndPrint(aSBMFunctionDescription, aOnlyPrintIfValueChanged);
10061008
aSBMFunctionDescription++;
10071009
}
@@ -1196,7 +1198,7 @@ void printSBMATRateInfo(void) {
11961198
Serial.println();
11971199

11981200
delay(20); // > 5 ms for bq2085-V1P3
1199-
for (uint8_t i = 1; i < (sizeof(sSBMATRateFunctionDescriptionArray) / sizeof(SBMFunctionDescriptionStruct)); ++i) {
1201+
for (uint_fast8_t i = 1; i < (sizeof(sSBMATRateFunctionDescriptionArray) / sizeof(SBMFunctionDescriptionStruct)); ++i) {
12001202
readWordAndPrint(&sSBMATRateFunctionDescriptionArray[i], false);
12011203
}
12021204
}

extras/T41_Start_PEC.logicdata

27.3 KB
Binary file not shown.

extras/T41_Start_PEC.txt

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
Time [s], Analyzer Name, Decoded Protocol Result
2+
4.098691000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read byte
3+
4.100878000000000,SMBus,Command SpecificationInfo '26' (0x1A)
4+
4.101203000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read byte
5+
4.101472000000000,SMBus,Byte 1 (0x31) ACK
6+
4.101749000000000,SMBus,Bad PEC '0' (0x00) should be '157' (0x9D)
7+
4.102687000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
8+
4.102950000000000,SMBus,Command RemainingCapacityAlarm '1' (0x01)
9+
4.103276000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
10+
4.103539000000000,SMBus,Word '56065' (0xDB01) ACK
11+
4.104102000000000,SMBus,PEC '241' (0xF1) OK
12+
4.105066000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
13+
4.105329000000000,SMBus,Command RemainingTimeAlarm '2' (0x02)
14+
4.105655000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
15+
4.105924000000000,SMBus,Word '2560' (0x0A00) ACK
16+
4.106482000000000,SMBus,PEC c (0x63) OK
17+
4.107446000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
18+
4.107708000000000,SMBus,Command AtRate '4' (0x04)
19+
4.108034000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
20+
4.108303000000000,SMBus,Word '0' (0x0000) ACK
21+
4.108919000000000,SMBus,PEC '149' (0x95) OK
22+
4.110004000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Write word
23+
4.110267000000000,SMBus,Command BatteryMode '3' (0x03)
24+
4.110528000000000,SMBus,BatteryMode '128' (0x0080) INTERNAL_CHARGE_CONTROLLER=0, PRIMARY_BATTERY_SUPPORT=0, CONDITION_FLAG=1, CHARGE_CONTROLLER_ENABLED=0, PRIMARY_BATTERY=0, ALARM_MODE=0, CHARGER_MODE=0, CAPACITY_MODE=0
25+
4.111040000000000,SMBus,PEC ' (0x27) OK
26+
4.112051000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
27+
4.112313000000000,SMBus,Command BatteryMode '3' (0x03)
28+
4.112639000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
29+
4.112908000000000,SMBus,BatteryMode '128' (0x0080) INTERNAL_CHARGE_CONTROLLER=0, PRIMARY_BATTERY_SUPPORT=0, CONDITION_FLAG=1, CHARGE_CONTROLLER_ENABLED=0, PRIMARY_BATTERY=0, ALARM_MODE=0, CHARGER_MODE=0, CAPACITY_MODE=0
30+
4.113497000000000,SMBus,PEC ~ (0x7E) OK
31+
4.114455000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
32+
4.114718000000000,SMBus,Command DesignCapacity '24' (0x18)
33+
4.115044000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
34+
4.115306000000000,SMBus,Word '36882' (0x9012) ACK
35+
4.115903000000000,SMBus,PEC '133' (0x85) OK
36+
4.380271000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
37+
4.380534000000000,SMBus,Command DesignVoltage '25' (0x19)
38+
4.380860000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
39+
4.381128000000000,SMBus,Word '12330' (0x302A) ACK
40+
4.381687000000000,SMBus,PEC # (0x23) OK
41+
4.909191000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
42+
4.909454000000000,SMBus,Command ManufactureDate '27' (0x1B)
43+
4.909780000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
44+
4.910041000000000,SMBus,ManufactureDate '47664' (0xBA30) 1/16/2009
45+
4.910606000000000,SMBus,PEC } (0x7D) OK
46+
5.438022000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
47+
5.438284000000000,SMBus,Command SerialNumber '28' (0x1C)
48+
5.438610000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
49+
5.438872000000000,SMBus,Word '47108' (0xB804) ACK
50+
5.439469000000000,SMBus,PEC '185' (0xB9) OK
51+
5.966915000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Block write
52+
5.967178000000000,SMBus,Command ManufacturerName ' ' (0x20)
53+
5.967504000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Block write
54+
5.967772000000000,SMBus,Byte count '8' (0x08)
55+
5.968061000000000,SMBus,Byte S (0x53) ACK
56+
5.968331000000000,SMBus,Byte A (0x41) ACK
57+
5.968612000000000,SMBus,Byte N (0x4E) ACK
58+
5.968919000000000,SMBus,Byte Y (0x59) ACK
59+
5.969200000000000,SMBus,Byte O (0x4F) ACK
60+
5.969482000000000,SMBus,Byte '0' (0x00) ACK
61+
5.969763000000000,SMBus,Byte 0 (0x30) ACK
62+
5.970044000000000,SMBus,Byte 2 (0x32) ACK
63+
5.970358000000000,SMBus,PEC '131' (0x83) OK
64+
6.497883000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Block write
65+
6.498146000000000,SMBus,Command DeviceName ! (0x21)
66+
6.498472000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Block write
67+
6.498740000000000,SMBus,Byte count '11' (0x0B)
68+
6.499017000000000,SMBus,Byte I (0x49) ACK
69+
6.499298000000000,SMBus,Byte B (0x42) ACK
70+
6.499580000000000,SMBus,Byte M (0x4D) ACK
71+
6.499861000000000,SMBus,Byte - (0x2D) ACK
72+
6.500155000000000,SMBus,Byte 0 (0x30) ACK
73+
6.500424000000000,SMBus,Byte 8 (0x38) ACK
74+
6.500706000000000,SMBus,Byte K (0x4B) ACK
75+
6.500987000000000,SMBus,Byte 8 (0x38) ACK
76+
6.501269000000000,SMBus,Byte 1 (0x31) ACK
77+
6.501550000000000,SMBus,Byte 9 (0x39) ACK
78+
6.501831000000000,SMBus,Byte 3 (0x33) ACK
79+
6.502145000000000,SMBus,PEC '177' (0xB1) OK
80+
6.503179000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Block write
81+
6.503441000000000,SMBus,Command DeviceChemistry " (0x22)
82+
6.503767000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Block write
83+
6.504036000000000,SMBus,Byte count '4' (0x04)
84+
6.504313000000000,SMBus,Byte L (0x4C) ACK
85+
6.504594000000000,SMBus,Byte I (0x49) ACK
86+
6.504875000000000,SMBus,Byte O (0x4F) ACK
87+
6.505157000000000,SMBus,Byte N (0x4E) ACK
88+
6.505438000000000,SMBus,PEC 1 (0x31) OK
89+
6.506453000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
90+
6.506716000000000,SMBus,Command ChargingVoltage '21' (0x15)
91+
6.507055000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
92+
6.507336000000000,SMBus,Word '14385' (0x3831) ACK
93+
6.507894000000000,SMBus,PEC " (0x22) OK
94+
6.509012000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Block write
95+
6.509274000000000,SMBus,Command OptionalMfgFunction5 / (0x2F)
96+
6.509626000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Block write
97+
6.509895000000000,SMBus,Byte count '11' (0x0B)
98+
6.510171000000000,SMBus,Byte 1 (0x31) ACK
99+
6.510453000000000,SMBus,Byte Z (0x5A) ACK
100+
6.510734000000000,SMBus,Byte 7 (0x37) ACK
101+
6.511015000000000,SMBus,Byte S (0x53) ACK
102+
6.511297000000000,SMBus,Byte N (0x4E) ACK
103+
6.511578000000000,SMBus,Byte 4 (0x34) ACK
104+
6.511872000000000,SMBus,Byte 5 (0x35) ACK
105+
6.512141000000000,SMBus,Byte T (0x54) ACK
106+
6.512422000000000,SMBus,Byte 0 (0x30) ACK
107+
6.512704000000000,SMBus,Byte X (0x58) ACK
108+
6.512986000000000,SMBus,Byte K (0x4B) ACK
109+
6.513301000000000,SMBus,PEC '141' (0x8D) OK
110+
6.514359000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
111+
6.514621000000000,SMBus,Command OptionalMfgFunction1 ? (0x3F)
112+
6.514947000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
113+
6.515211000000000,SMBus,Word '52528' (0xCD30) ACK
114+
6.515774000000000,SMBus,PEC " (0x22) OK
115+
6.516917000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
116+
6.517179000000000,SMBus,Command ManufacturerAccess '0' (0x00)
117+
6.517505000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
118+
6.517774000000000,SMBus,Word '6152' (0x1808) ACK
119+
6.518358000000000,SMBus,PEC \n (0x0A) OK
120+
6.519475000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
121+
6.519738000000000,SMBus,Command Temperature '8' (0x08)
122+
6.520064000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
123+
6.520326000000000,SMBus,Word '41995' (0xA40B) ACK
124+
6.520891000000000,SMBus,PEC '0' (0x00) OK
125+
6.521854000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
126+
6.522117000000000,SMBus,Command Voltage \t (0x09)
127+
6.522443000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
128+
6.522712000000000,SMBus,Word '27436' (0x6B2C) ACK
129+
6.523301000000000,SMBus,PEC '205' (0xCD) OK
130+
6.524234000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
131+
6.524496000000000,SMBus,Command RemainingCapacity '15' (0x0F)
132+
6.524822000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
133+
6.525091000000000,SMBus,Word '0' (0x0000) ACK
134+
6.525649000000000,SMBus,PEC '31' (0x1F) OK
135+
6.526613000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
136+
6.526875000000000,SMBus,Command FullChargeCapacity '16' (0x10)
137+
6.527201000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
138+
6.527470000000000,SMBus,Word '17157' (0x4305) ACK
139+
6.528060000000000,SMBus,PEC '213' (0xD5) OK
140+
6.528966000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
141+
6.529229000000000,SMBus,Command Current \n (0x0A)
142+
6.529555000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
143+
6.529824000000000,SMBus,Word '0' (0x0000) ACK
144+
6.530382000000000,SMBus,PEC Q (0x51) OK
145+
6.531422000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
146+
6.531685000000000,SMBus,Command ChargingCurrent '20' (0x14)
147+
6.532011000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
148+
6.532275000000000,SMBus,Word '61450' (0xF00A) ACK
149+
6.532872000000000,SMBus,PEC '208' (0xD0) OK
150+
6.533904000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
151+
6.534166000000000,SMBus,Command AverageCurrent '11' (0x0B)
152+
6.534492000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
153+
6.534761000000000,SMBus,Word '0' (0x0000) ACK
154+
6.535370000000000,SMBus,PEC G (0x47) OK
155+
6.536309000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
156+
6.536571000000000,SMBus,Command AverageTimeToFull '19' (0x13)
157+
6.536897000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
158+
6.537161000000000,SMBus,Word '65535' (0xFFFF) ACK
159+
6.537723000000000,SMBus,PEC '180' (0xB4) OK
160+
7.065432000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
161+
7.065695000000000,SMBus,Command AverageTimeToEmpty '18' (0x12)
162+
7.066021000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
163+
7.066289000000000,SMBus,Word '0' (0x0000) ACK
164+
7.066880000000000,SMBus,PEC '134' (0x86) OK
165+
7.594261000000000,SMBus,Write address '11' (0x0B) ACK Protocol=Read word
166+
7.594523000000000,SMBus,Command RunTimeToEmpty '17' (0x11)
167+
7.594849000000000,SMBus,Read address '11' (0x0B) ACK Protocol=Read word
168+
7.595118000000000,SMBus,Word '0' (0x0000) ACK
169+
7.595708000000000,SMBus,PEC '188' (0xBC) OK

0 commit comments

Comments
 (0)