disable sensor detection - temporary solution
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
#define BLINK_GPIO 2
|
||||
|
||||
//uint8_t powerMode = LOW_POWER_MODE;
|
||||
// uint8_t powerMode = LOW_POWER_MODE;
|
||||
uint8_t powerMode = HIGH_POWER_MODE;
|
||||
|
||||
static uint8_t s_led_state = 0;
|
||||
@@ -59,11 +59,14 @@ void setPowerMode(uint8_t powerModeIn)
|
||||
powerMode = powerModeIn;
|
||||
if (foundDevices[0] == 2)
|
||||
{
|
||||
if (powerMode == HIGH_POWER_MODE) {
|
||||
if (powerMode == HIGH_POWER_MODE)
|
||||
{
|
||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CCS811_WAKE, 0);
|
||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CCS811_POWER, 1);
|
||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_MICS_POWER, 1);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CCS811_WAKE, 1);
|
||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_CCS811_POWER, 0);
|
||||
mcp23018_set_pin(MCP23018_DEV_HANDLE, MCP_MICS_POWER, 0);
|
||||
@@ -97,7 +100,7 @@ void init_connected()
|
||||
break;
|
||||
|
||||
case CCS811_ADDRESS:
|
||||
ret = ccs811_init();
|
||||
ret = ccs811_init();
|
||||
/* code */
|
||||
break;
|
||||
|
||||
@@ -136,13 +139,13 @@ void i2c_sensors_task(void *pvParameters)
|
||||
memset(foundDevices, 0, sizeof(foundDevices));
|
||||
memset(prevDevices, 0, sizeof(prevDevices));
|
||||
|
||||
// bme680b_init();
|
||||
// mpu9250_init();
|
||||
// ccs811_init();
|
||||
// ina260_init();
|
||||
bme680b_init();
|
||||
mpu9250_init();
|
||||
ccs811_init();
|
||||
ina260_init();
|
||||
|
||||
update_devices();
|
||||
init_connected();
|
||||
// update_devices();
|
||||
// init_connected();
|
||||
// initialize the xLastWakeTime variable with the current time.
|
||||
const int64_t interval_us = 50000; // 50 ms
|
||||
int64_t start_time, end_time, elapsed;
|
||||
@@ -172,86 +175,68 @@ void i2c_sensors_task(void *pvParameters)
|
||||
{
|
||||
start_time = esp_timer_get_time(); // µs since boot
|
||||
|
||||
uint8_t presentDevices = 0;
|
||||
update_devices();
|
||||
init_connected();
|
||||
uint8_t presentDevices = 0xFF;
|
||||
// update_devices();
|
||||
// init_connected();
|
||||
|
||||
//
|
||||
// handle sensor
|
||||
|
||||
if (foundDevices[BME680_ADDRESS] == 2)
|
||||
presentDevices |= BME680_PRESENT_BIT;
|
||||
|
||||
if (BME680_DEV_HANDLE)
|
||||
{
|
||||
|
||||
presentDevices |= BME680_PRESENT_BIT;
|
||||
|
||||
if (BME680_DEV_HANDLE)
|
||||
esp_err_t result = bme680_get_data(BME680_DEV_HANDLE, &bmeData);
|
||||
if (result != ESP_OK)
|
||||
{
|
||||
esp_err_t result = bme680_get_data(BME680_DEV_HANDLE, &bmeData);
|
||||
if (result != ESP_OK)
|
||||
{
|
||||
ESP_LOGE(TAG_BME, "bme680 device read failed (%s)", esp_err_to_name(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
bmeData.barometric_pressure = bmeData.barometric_pressure / 100;
|
||||
ESP_LOGI(TAG_BME, "dewpoint temperature:%.2f °C", bmeData.dewpoint_temperature);
|
||||
ESP_LOGI(TAG_BME, "air temperature: %.2f °C", bmeData.air_temperature);
|
||||
ESP_LOGI(TAG_BME, "relative humidity: %.2f %%", bmeData.relative_humidity);
|
||||
ESP_LOGI(TAG_BME, "barometric pressure: %.2f hPa", bmeData.barometric_pressure);
|
||||
ccs811_set_env_data(bmeData.air_temperature, bmeData.relative_humidity);
|
||||
ESP_LOGI(TAG_BME, "gas resistance: %.2f kOhms", bmeData.gas_resistance / 1000);
|
||||
ESP_LOGI(TAG_BME, "iaq score: %u (%s)", bmeData.iaq_score, bme680_air_quality_to_string(bmeData.iaq_score));
|
||||
}
|
||||
ESP_LOGE(TAG_BME, "bme680 device read failed (%s)", esp_err_to_name(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
bme680b_init();
|
||||
bmeData.barometric_pressure = bmeData.barometric_pressure / 100;
|
||||
ESP_LOGI(TAG_BME, "dewpoint temperature:%.2f °C", bmeData.dewpoint_temperature);
|
||||
ESP_LOGI(TAG_BME, "air temperature: %.2f °C", bmeData.air_temperature);
|
||||
ESP_LOGI(TAG_BME, "relative humidity: %.2f %%", bmeData.relative_humidity);
|
||||
ESP_LOGI(TAG_BME, "barometric pressure: %.2f hPa", bmeData.barometric_pressure);
|
||||
ccs811_set_env_data(bmeData.air_temperature, bmeData.relative_humidity);
|
||||
ESP_LOGI(TAG_BME, "gas resistance: %.2f kOhms", bmeData.gas_resistance / 1000);
|
||||
ESP_LOGI(TAG_BME, "iaq score: %u (%s)", bmeData.iaq_score, bme680_air_quality_to_string(bmeData.iaq_score));
|
||||
}
|
||||
}
|
||||
|
||||
if (foundDevices[CCS811_ADDRESS] == 2)
|
||||
else
|
||||
{
|
||||
presentDevices |= CCS811_PRESENT_BIT;
|
||||
ccs811_get_data(&eCO2, &tvoc, ¤tCCS, &rawData);
|
||||
ESP_LOGI(TAG_CCS, "eCO₂: %d ppm, TVOC: %d ppb", eCO2, tvoc);
|
||||
ESP_LOGI(TAG_CCS, "Current: %d μA, Raw voltage: %d V", currentCCS, rawData);
|
||||
bme680b_init();
|
||||
}
|
||||
|
||||
if (foundDevices[MPU9250_ADDRESS] == 2)
|
||||
presentDevices |= CCS811_PRESENT_BIT;
|
||||
ccs811_get_data(&eCO2, &tvoc, ¤tCCS, &rawData);
|
||||
ESP_LOGI(TAG_CCS, "eCO₂: %d ppm, TVOC: %d ppb", eCO2, tvoc);
|
||||
ESP_LOGI(TAG_CCS, "Current: %d μA, Raw voltage: %d V", currentCCS, rawData);
|
||||
|
||||
presentDevices |= MPU9250_PRESENT_BIT;
|
||||
if (mpu9250_read_sensor_data(MPU9250_DEV_HANDLE, accel, gyro, &temp, magnet) == ESP_OK)
|
||||
{
|
||||
mpu9250_convert_data(accel, gyro, temp, magnet, accel_f, gyro_f, &temp_f, magnet_f);
|
||||
|
||||
presentDevices |= MPU9250_PRESENT_BIT;
|
||||
if (mpu9250_read_sensor_data(MPU9250_DEV_HANDLE, accel, gyro, &temp, magnet) == ESP_OK)
|
||||
{
|
||||
mpu9250_convert_data(accel, gyro, temp, magnet, accel_f, gyro_f, &temp_f, magnet_f);
|
||||
|
||||
ESP_LOGI(TAG_MPU, "Accel: X=%.2f g, Y=%.2f g, Z=%.2f g", accel_f[0], accel_f[1], accel_f[2]);
|
||||
ESP_LOGI(TAG_MPU, "Gyro: X=%.2f°/s, Y=%.2f°/s, Z=%.2f°/s", gyro_f[0], gyro_f[1], gyro_f[2]);
|
||||
ESP_LOGI(TAG_MPU, "Magnet: X=%.2fμT, Y=%.2fμT, Z=%.2fμT", magnet_f[0], magnet_f[1], magnet_f[2]);
|
||||
ESP_LOGI(TAG_MPU, "Temperature: %.2f °C", temp_f);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG_MPU, "Failed to read sensor data");
|
||||
}
|
||||
ESP_LOGI(TAG_MPU, "Accel: X=%.2f g, Y=%.2f g, Z=%.2f g", accel_f[0], accel_f[1], accel_f[2]);
|
||||
ESP_LOGI(TAG_MPU, "Gyro: X=%.2f°/s, Y=%.2f°/s, Z=%.2f°/s", gyro_f[0], gyro_f[1], gyro_f[2]);
|
||||
ESP_LOGI(TAG_MPU, "Magnet: X=%.2fμT, Y=%.2fμT, Z=%.2fμT", magnet_f[0], magnet_f[1], magnet_f[2]);
|
||||
ESP_LOGI(TAG_MPU, "Temperature: %.2f °C", temp_f);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG_MPU, "Failed to read sensor data");
|
||||
}
|
||||
|
||||
if (foundDevices[INA260_ADDRESS] == 2)
|
||||
{
|
||||
presentDevices |= INA260_PRESENT_BIT;
|
||||
ina260_readParams(&volts, ¤t, &power);
|
||||
ina260_printParams(volts, current, power);
|
||||
|
||||
presentDevices |= INA260_PRESENT_BIT;
|
||||
ina260_readParams(&volts, ¤t, &power);
|
||||
ina260_printParams(volts, current, power);
|
||||
}
|
||||
presentDevices |= MCP23018_PRESENT_BIT;
|
||||
float VREFVoltage = 2.5;
|
||||
ADCData = mcp3550_read_all(VREFVoltage);
|
||||
|
||||
if (foundDevices[MCP23018_ADDRESS] == 2)
|
||||
{
|
||||
presentDevices |= MCP23018_PRESENT_BIT;
|
||||
float VREFVoltage = 2.5;
|
||||
ADCData = mcp3550_read_all(VREFVoltage);
|
||||
|
||||
log_mics_adc_values(&ADCData);
|
||||
}
|
||||
log_mics_adc_values(&ADCData);
|
||||
|
||||
if (packetReadiness == 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user