|
|
|
|
@ -120,11 +120,13 @@ struct SensorData read_sensor_data(struct SensorConfig sensor) {
|
|
|
|
|
|
|
|
|
|
wiringPiI2CWrite(sensor.fd, INA219_REG_CURRENT);
|
|
|
|
|
delay(1); // Max 12-bit conversion time is 586us per sample
|
|
|
|
|
int16_t valuex = (int16_t)((wiringPiI2CRead(sensor.fd) << 8 ) | wiringPiI2CRead (sensor.fd));
|
|
|
|
|
int value1 = wiringPiI2CRead(sensor.fd);
|
|
|
|
|
int value2 = wiringPiI2CRead(sensor.fd);
|
|
|
|
|
int16_t valuex = (int16_t)(value1 << 8 ) | value2);
|
|
|
|
|
|
|
|
|
|
// uint16_t valuex = (uint16_t)wireReadRegister(sensor.fd, INA219_REG_CURRENT);
|
|
|
|
|
data.current = (double)valuex / (double)sensor.currentDivider;
|
|
|
|
|
printf("&&&&&&&& valuex %d current %f \n", valuex, data.current);
|
|
|
|
|
printf("&&&&&&&& value1 %d value2 %d valuex %d current %f \n", value1, value2, valuex, data.current);
|
|
|
|
|
|
|
|
|
|
uint16_t value2 = (uint16_t)wireReadRegister(sensor.fd, INA219_REG_BUSVOLTAGE);
|
|
|
|
|
data.voltage = ((double)(value2 >> 3) * 4) / 1000;
|
|
|
|
|
|