From 8aeade9922982b33c10cd6bb200b2c3e91b66612 Mon Sep 17 00:00:00 2001 From: Arthur Roberts Date: Wed, 1 Nov 2023 17:31:30 +0000 Subject: [PATCH] Added scaffolding for DS18B20 --- components/ds18b20/CMakeLists.txt | 3 +++ components/ds18b20/Kconfig.projbuild | 15 +++++++++++++++ components/ds18b20/ds18b20.c | 4 ++++ components/ds18b20/ds18b20.h | 0 main/main.c | 4 +++- 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 components/ds18b20/CMakeLists.txt create mode 100644 components/ds18b20/Kconfig.projbuild create mode 100644 components/ds18b20/ds18b20.c create mode 100644 components/ds18b20/ds18b20.h diff --git a/components/ds18b20/CMakeLists.txt b/components/ds18b20/CMakeLists.txt new file mode 100644 index 0000000..28bc0c8 --- /dev/null +++ b/components/ds18b20/CMakeLists.txt @@ -0,0 +1,3 @@ +idf_component_register(SRCS "ds18b20.c" + INCLUDE_DIRS "." + REQUIRES driver) diff --git a/components/ds18b20/Kconfig.projbuild b/components/ds18b20/Kconfig.projbuild new file mode 100644 index 0000000..84be5c7 --- /dev/null +++ b/components/ds18b20/Kconfig.projbuild @@ -0,0 +1,15 @@ +menu "DS18B20" + config DS18B20_ENABLED + bool "DS18B20 Enabled" + default y + + config DS18B20_GPIO_PIN + int "GPIO Pin used for 1-Wire DS18B20" + default 10 + depends on DS18B20_ENABLED + + config DS18B20_PERIOD_POLL + int "Period to poll the DS18B20 in seconds" + default 8000 + depends on DS18B20_ENABLED +endmenu diff --git a/components/ds18b20/ds18b20.c b/components/ds18b20/ds18b20.c new file mode 100644 index 0000000..fc5124c --- /dev/null +++ b/components/ds18b20/ds18b20.c @@ -0,0 +1,4 @@ +int test() { + int i = 5; + return i; +} diff --git a/components/ds18b20/ds18b20.h b/components/ds18b20/ds18b20.h new file mode 100644 index 0000000..e69de29 diff --git a/main/main.c b/main/main.c index 5998fbb..adb971b 100644 --- a/main/main.c +++ b/main/main.c @@ -116,7 +116,9 @@ void read_from_dht22() { ten_minute_average.time.myt_month = timeinfo->tm_mon; ten_minute_average.time.myt_year = timeinfo->tm_year; - // TODO check this conversion just works + // TODO: Consider rounding this number - although, .1 of a degree C + // no one is going to miss that. Probably the calculation require to + // do the rounding would affect the temperature that much anyways haha ten_minute_average.temp = temperature_tmp; ten_minute_average.rh = relative_humidity_tmp; ESP_LOGW(TAG, "ten_min_avg.temp %" PRIi16 ", .rh %" PRIu16, ten_minute_average.temp, ten_minute_average.rh);