Hi!
In my current arduino project I am trying to "fake" a lithium battery pack for an old Sony Aibo so it can work off a generic RC lipo. The original battery pack communicates with the Aibo using SMBus - original is based on the TI BQ2040 smart battery chip. I am basically trying to fake that chip using the arduino.
I am using an Arduino Nano 33 IoT (mostly because that is what I had on hand). This is the test code that I've written:
#include <Wire.h>
const byte MY_ADDRESS = 0x0B;
byte command;
void setup() {
command = 0;
Wire.begin (MY_ADDRESS);
Wire.onReceive (receiveEvent); // interrupt handler for incoming messages
Wire.onRequest (requestEvent); // interrupt handler for when data is wanted
//Begin Serial for debuging
//Serial.begin(9600);
}
void loop() {
}
void receiveEvent (int howMany) {
command = Wire.read (); // remember command for when we get request
}
void requestEvent () {
if (command == 0x21) {
byte byteArray[8] = { 0x07, 0x45, 0x52, 0x41, 0x32, 0x30, 0x31, 0x42 };
//Write the 3 bytes back
Wire.write(byteArray, 8);
}
}
This is the output from the logic analyzer when using the original battery:
write to 0x0B ack data: 0x21
read to 0x0B ack data: 0x07 0x45 0x52 0x41 0x32 0x30 0x31 0x42
write to 0x0B ack data: 0x16
read to 0x0B ack data: 0xE0 0x00
write to 0x0B ack data: 0x08
read to 0x0B ack data: 0x94 0x0B
write to 0x0B ack data: 0x09
read to 0x0B ack data: 0x6B 0x20
write to 0x0B ack data: 0x0A
read to 0x0B ack data: 0x00 0x00
write to 0x0B ack data: 0x10
read to 0x0B ack data: 0xD8 0x0E
...
This is the output from the logic analyzer when using the arduino with the code above:
write to 0x0B ack data: 0x21
read to 0x0B ack data: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 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 0xFF
write to 0x0B ack data: 0x16
read to 0x0B ack data: 0x07 0x45
write to 0x0B ack data: 0x08
read to 0x0B ack data: 0xFF 0xFF
write to 0x0B ack data: 0x08
read to 0x0B ack data: 0xFF 0xFF
write to 0x0B ack data: 0x09
read to 0x0B ack data: 0xFF 0xFF
write to 0x0B ack data: 0x0A
read to 0x0B ack data: 0xFF 0xFF
write to 0x0B ack data: 0x10
read to 0x0B ack data: 0xFF 0xFF
...
From various prints that I had in there I can see that the Aibo does successfully send the 0x21 command and that the arduino reads it ok (and reads any subsequent commands like
0x09). But what I don't get is where those 0xFF come from. Removing the Wire.write
call changes nothing. Looking at the output you can see that parts of the message 0x07 0x45
get written eventually, but just in between other noise.
I'm probably missing something stupid, however I cannot figure out what. Any ideas?