I am currently trying to connect to a MAX17043 LiPo Battery monitor using the HiFive1 Board. I am using the arduino software library provided here and have been able to check the address properly using the included scanner.
The problem comes when I use the library to try and check the state of charge in the battery.
My simple question is whether there is a better software library for I2C for the HiFive1? If not is there a better code than this:
#include “SoftwareI2C.h”
SoftwareI2C softwarei2c;
void setup() {
//setup code
Serial.begin(115200);
softwarei2c.begin(18, 19); // sda, scl
delay(1000);
}
void loop() {
//Check Battery Voltage
softwarei2c.beginTransmission(0x36);
softwarei2c.write(0x04);
softwarei2c.endTransmission();
softwarei2c.requestFrom(0x36,0x01);
byte socreg = byte(softwarei2c.read());
int prcntBatt = socreg/255*100;
Serial.print(prcntBatt, DEC);
Serial.println("%");
delay(30000);
}