diff --git a/src/main.c b/src/main.c index 7aa979e..17207de 100644 --- a/src/main.c +++ b/src/main.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -39,11 +40,11 @@ int main(void) request_sensor_data_sht4x(); humidity = get_value_from_current_sample_sht4x(SENSOR_CHAN_HUMIDITY); temp = get_value_from_current_sample_sht4x(SENSOR_CHAN_AMBIENT_TEMP); - printk("hum: %.2f%%\n", humidity); - printk("temp: %.2f °C\n", temp); + printk("hum: %d.%02d%%\n", (int)humidity, (int)(humidity * 100) % 100); + printk("temp: %d.%02d °C\n", (int)temp, (int)(temp * 100) % 100); request_sensor_data_mlx90614(MLX90614_IR_TEMP_ADDR); floor_temp = get_temp_from_raw_data_mlx90614(); - printk("floor_temp: %.2f °C\n", floor_temp); + printk("floor_temp: %d.%02d °C\n", (int)floor_temp, (int)(floor_temp * 100) % 100); /* Set relais based on temperature if not manually overridden */ if (!relais_manual_override) { diff --git a/src/sensors/sht4x.c b/src/sensors/sht4x.c index 6556eac..4a6247a 100644 --- a/src/sensors/sht4x.c +++ b/src/sensors/sht4x.c @@ -48,9 +48,11 @@ float get_value_from_current_sample_sht4x(enum sensor_channel sensor) float result; if (sensor_channel_get(sht, sensor, &value) == 0) { result = sensor_value_to_double(&value); - printf("Value '%s' successfully read [%f]", sensor, result); + const char* sensor_name = (sensor == SENSOR_CHAN_AMBIENT_TEMP) ? "temperature" : "humidity"; + LOG_DBG("SHT4X %s value: %.2f", sensor_name, result); } else { - LOG_ERR("Can't read sensor value '%s' from sample!", sensor); + const char* sensor_name = (sensor == SENSOR_CHAN_AMBIENT_TEMP) ? "temperature" : "humidity"; + LOG_ERR("Can't read SHT4X %s from sample!", sensor_name); return 0.0; } return result;