From 580600aa538fe391d7f7d9be683bc7d82234d47b Mon Sep 17 00:00:00 2001 From: David Antliff Date: Tue, 5 Sep 2017 11:31:39 +1200 Subject: [PATCH] Updated README. --- README.md | 2 ++ components/esp32-owb | 2 +- main/app_main.c | 11 ++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0061da9..b136eac 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ To run this example, connect one or more DS18B20 devices to a single GPIO on the `make menuconfig` can be used to set the 1-Wire GPIO. +If you have several devices and see occasional CRC errors, consider using a 2.2 kOhm pull-up resistor instead. Also consider adding decoupling capacitors between the sensor supply voltage and ground, as close to each sensor as possible. + ## Features This example provides: diff --git a/components/esp32-owb b/components/esp32-owb index 57bcaf0..c62cd2e 160000 --- a/components/esp32-owb +++ b/components/esp32-owb @@ -1 +1 @@ -Subproject commit 57bcaf06f500953e3acb97d23c6a6a98712824ab +Subproject commit c62cd2e7fe0850b29e2563d1fde49ff452676b57 diff --git a/main/app_main.c b/main/app_main.c index 95224bc..d9a875c 100644 --- a/main/app_main.c +++ b/main/app_main.c @@ -44,6 +44,9 @@ void app_main() { esp_log_level_set("*", ESP_LOG_INFO); + /// stable readings require a brief period before communication + vTaskDelay(1000.0 / portTICK_PERIOD_MS); + // Create a 1-Wire bus #ifdef USE_STATIC OneWireBus owb_static; // static allocation @@ -132,6 +135,7 @@ void app_main() // } // read temperatures more efficiently by starting conversions on all devices at the same time + int crc_errors[MAX_DEVICES] = {0}; if (num_devices > 0) { while (1) @@ -156,7 +160,12 @@ void app_main() printf("\nTemperature readings (degrees C):\n"); for (int i = 0; i < num_devices; ++i) { - printf(" %d: %.1f\n", i, temps[i]); + if (temps[i] == DS18B20_INVALID_READING) + { + ++crc_errors[i]; + } + + printf(" %d: %.1f %d errors\n", i, temps[i], crc_errors[i]); } // make up delay to approximately 1 second per measurement