fixed i2c addr, added wait for sensor to take initial readings before requesting them
This commit is contained in:
+4
-3
@@ -35,8 +35,8 @@ int8_t check_file_exists(const char *filename)
|
|||||||
|
|
||||||
void user_delay_ms(uint32_t period)
|
void user_delay_ms(uint32_t period)
|
||||||
{
|
{
|
||||||
//usleep(period*1000); // if using gnu99
|
usleep(period*1000); // if using gnu99
|
||||||
sleep(period*1000); // if using c99
|
//sleep(period*1000); // if using c99
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BME280_FLOAT_ENABLE
|
#ifdef BME280_FLOAT_ENABLE
|
||||||
@@ -211,6 +211,7 @@ int8_t read_sensor_data_normal_mode(struct bme280_dev *dev)
|
|||||||
settings_sel |= BME280_FILTER_SEL;
|
settings_sel |= BME280_FILTER_SEL;
|
||||||
readings_result = bme280_set_sensor_settings(settings_sel, dev);
|
readings_result = bme280_set_sensor_settings(settings_sel, dev);
|
||||||
readings_result = bme280_set_sensor_mode(BME280_NORMAL_MODE, dev);
|
readings_result = bme280_set_sensor_mode(BME280_NORMAL_MODE, dev);
|
||||||
|
dev->delay_ms(200); // wait for first measurement
|
||||||
readings_result = bme280_get_sensor_data(BME280_ALL, &sensor_readings_data, dev);
|
readings_result = bme280_get_sensor_data(BME280_ALL, &sensor_readings_data, dev);
|
||||||
print_sensor_data(&sensor_readings_data);
|
print_sensor_data(&sensor_readings_data);
|
||||||
//save_data_to_json_file(&sensor_readings_data);
|
//save_data_to_json_file(&sensor_readings_data);
|
||||||
@@ -227,7 +228,7 @@ int main(int argc, char* argv[])
|
|||||||
printf("Failed to open the i2c bus %s", argv[1]);
|
printf("Failed to open the i2c bus %s", argv[1]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (ioctl(file_descriptor, I2C_SLAVE, 0x76) < 0) {
|
if (ioctl(file_descriptor, I2C_SLAVE, 0x77) < 0) {
|
||||||
printf("Failed to acquire bus access and/or talk to slave.\n");
|
printf("Failed to acquire bus access and/or talk to slave.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user