|
|
|
|
@ -138,7 +138,12 @@ struct SensorData read_sensor_data(struct SensorConfig sensor) {
|
|
|
|
|
value = (wiringPiI2CRead(sensor.fd) << 8 ) | wiringPiI2CRead (sensor.fd);
|
|
|
|
|
data.voltage = ((float)(value >> 3) * 4) / 1000;
|
|
|
|
|
|
|
|
|
|
data.power = (float) wiringPiI2CReadReg16(sensor.fd, INA219_REG_POWER) * (float) sensor.powerMultiplier;
|
|
|
|
|
// data.power = (float) wiringPiI2CReadReg16(sensor.fd, INA219_REG_POWER) * (float) sensor.powerMultiplier;
|
|
|
|
|
|
|
|
|
|
wiringPiI2CWrite(sensor.fd, INA219_REG_POWER);
|
|
|
|
|
delay(1); // Max 12-bit conversion time is 586us per sample
|
|
|
|
|
value = (wiringPiI2CRead(sensor.fd) << 8 ) | wiringPiI2CRead (sensor.fd);
|
|
|
|
|
data.power = (float) value * (float) sensor.powerMultiplier;
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|