This commit is contained in:
@@ -23,31 +23,29 @@ uint16_t get_word(uint8_t address, uint8_t reg) {
|
||||
return (data[1] << 8) | data[0];
|
||||
}
|
||||
|
||||
char* INA233::print_device_number() {
|
||||
char data[6];
|
||||
int16_t rawVoltage;
|
||||
String INA233::print_device_number() {
|
||||
char data[7]; // Array size includes space for the null terminator
|
||||
|
||||
// Request data from the PMBus device
|
||||
Wire.beginTransmission(INA233::_address);
|
||||
Wire.write(0x9A);
|
||||
Wire.write(0x9A); // Command to read the manufacturer ID
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom(INA233::_address, 6);
|
||||
Wire.requestFrom(INA233::_address, 7);
|
||||
|
||||
if (Wire.available() == 6) {
|
||||
if (Wire.available() == 7) {
|
||||
uint8_t i = Wire.read();
|
||||
data[0] = Wire.read();
|
||||
data[1] = Wire.read();
|
||||
data[2] = Wire.read();
|
||||
data[3] = Wire.read();
|
||||
data[4] = Wire.read();
|
||||
data[5] = Wire.read();
|
||||
data[6] = '\0'; // Null-terminate the string
|
||||
} else {
|
||||
// return 0 on error
|
||||
data[0] = '\0';
|
||||
return data;
|
||||
return String("");
|
||||
}
|
||||
|
||||
// Combine the two bytes into a single 16-bit value
|
||||
return data;
|
||||
return String(data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ enum ConversionTime {
|
||||
|
||||
class INA233{
|
||||
public:
|
||||
char* print_device_number();
|
||||
String print_device_number();
|
||||
INA233(uint8_t addr, TwoWire* wire = &Wire);
|
||||
bool begin(const uint8_t sda, const uint8_t scl);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user