mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-11-03 22:28:28 +00:00
esp32 temperature node
This commit is contained in:
@@ -31,36 +31,6 @@
|
||||
|
||||
static bme280_handle_t sensor = NULL;
|
||||
|
||||
static esp_err_t bme280_read_raw_temperature(uint8_t device_address, uint8_t *raw_temperature) {
|
||||
// BME280_INIT_VALUE LN 136
|
||||
// BME280_TEMPERATURE_MSB_REG 0xFA
|
||||
// BME280_TEMPERATURE_DATA_LENGTH
|
||||
// BME280_TEMPERATURE_DATA_SIZE
|
||||
// I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS
|
||||
|
||||
esp_err_t command_result;
|
||||
//unsigned char raw_temperature[BME280_TEMPERATURE_DATA_SIZE] = {0, 0, 0};
|
||||
//command_result = i2c_master_read_from_device(0, BME280_I2C_ADDRESS1, *raw_temperature, BME280_TEMPERATURE_DATA_SIZE, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
|
||||
command_result = i2c_master_write_read_device(0, device_address, *raw_temperature, BME280_TEMPERATURE_DATA_SIZE, BME280_TEMPERATURE_REGISTER, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
|
||||
return command_result;
|
||||
}
|
||||
static esp_err_t i2c_driver_initialize(void)
|
||||
{
|
||||
int i2c_master_port = 0;
|
||||
|
||||
i2c_config_t conf = {
|
||||
.mode = I2C_MODE_MASTER,
|
||||
.sda_io_num = GPIO_NUM_21,
|
||||
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
.scl_io_num = GPIO_NUM_22,
|
||||
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
.master.clk_speed = I2C_MASTER_FREQ_HZ,
|
||||
.clk_flags= 0,
|
||||
};
|
||||
|
||||
return i2c_param_config(i2c_master_port, &conf);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
|
||||
Reference in New Issue
Block a user