copied code from wireRead but with int16_t

pull/18/head
alanbjohnston 7 years ago committed by GitHub
parent c7c6300429
commit 7d79af0af9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -118,9 +118,13 @@ struct SensorData read_sensor_data(struct SensorConfig sensor) {
// float valuec3 = (float)(twos);
// data.current = valuec3 / (float)sensor.currentDivider;
uint16_t valuex = (uint16_t)wireReadRegister(sensor.fd, INA219_REG_CURRENT);
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));
// 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);
uint16_t value2 = (uint16_t)wireReadRegister(sensor.fd, INA219_REG_BUSVOLTAGE);
data.voltage = ((double)(value2 >> 3) * 4) / 1000;

Loading…
Cancel
Save

Powered by TurnKey Linux.