Compare commits
2 Commits
25905198c6
...
ef5ff78b36
| Author | SHA1 | Date | |
|---|---|---|---|
|
ef5ff78b36
|
|||
|
cc1500c426
|
+6
-4
@@ -35,7 +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);
|
usleep(period*1000); // if using gnu99
|
||||||
|
//sleep(period*1000); // if using c99
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BME280_FLOAT_ENABLE
|
#ifdef BME280_FLOAT_ENABLE
|
||||||
@@ -210,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);
|
||||||
@@ -226,13 +228,13 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
dev.dev_id = BME280_I2C_ADDR_PRIM; //0x76
|
//dev.dev_id = BME280_I2C_ADDR_PRIM; //0x76 (if orange/pin 5 is connected to ground on Pi)
|
||||||
//dev.dev_id = BME280_I2C_ADDR_SEC; //0x77
|
dev.dev_id = BME280_I2C_ADDR_SEC; //0x77 (if orange/pin 5 is connected to 3.3V on Pi)
|
||||||
dev.intf = BME280_I2C_INTF;
|
dev.intf = BME280_I2C_INTF;
|
||||||
dev.read = user_i2c_read;
|
dev.read = user_i2c_read;
|
||||||
dev.write = user_i2c_write;
|
dev.write = user_i2c_write;
|
||||||
|
|||||||
Reference in New Issue
Block a user