I’m trying to communicate with a laptop battery (Dell X284G) using i2c with a photon but I don’t know which library to use and how to correctly use this protocol.
I found the slave address in the datasheet, it’s 0x20
I saw that there are 9 registers
On the battery, there is 9 pins (P-, P-, alert, sys, bat, dat, clk, P+, P+). I think the SDA pin (d0) must be the “dat” pin and the SCL pin (d1) on the “clk” pin but I’m not sure. I also connected the battery gnd to the photon’s gnd
Here’s my code; It’s not working. How to know if the ship is correctly connected ?
What exactly does “it’s not working” mean? What do you expect it to do, what does it do and what doesn’t it do?
Furthermore, what’s the use of the while (true) loop within the loop() function? If you want an infinite loop, that’s kinda exactly what loop() does. Your while loop might break the cloud connection if you’re not careful with it (breathing green LED)
Within the inner while loop, you’re calling ‘debug’ twice, both causing a publish, which may, or may not go over the rate limit. I’d double check that if I were you.
Yes of course I know my code is not really correct but it’s just for debugging purpose and I forgot to remove while loop from an old test ^^
Actually I want to know if the ship is working because it’s stuck at “Fetching…”
I’d like to access to the first register (address 0x00) there is 6 response bits and I tried to save it into a int data type to read it after. but it seems stuck while fetching response…
Could you check if you’ve got pull-up resistors for the I2C lines installed? Wire.begin() should only sit in setup().
And I guess you might want to read your data even if you don’t have all six bytes available and add a timeout in case you won’t get all expected data either.
Why do you expect six bytes anyway? The six bits fit in only one byte
Since you’ll only get one byte from register 0x00 you will be stuck in while(Wire.available() < 6) forever.