|
|
|
@ -22,8 +22,6 @@ |
|
|
|
* SOFTWARE. |
|
|
|
*/ |
|
|
|
|
|
|
|
#include <inttypes.h> |
|
|
|
|
|
|
|
#include "freertos/FreeRTOS.h" |
|
|
|
#include "freertos/task.h" |
|
|
|
#include "esp_system.h" |
|
|
|
@ -38,10 +36,11 @@ |
|
|
|
#define DS18B20_RESOLUTION (DS18B20_RESOLUTION_12_BIT) |
|
|
|
#define SAMPLE_PERIOD (1000) // milliseconds
|
|
|
|
|
|
|
|
void app_main() |
|
|
|
_Noreturn void app_main() |
|
|
|
{ |
|
|
|
// Override global log level
|
|
|
|
esp_log_level_set("*", ESP_LOG_INFO); |
|
|
|
esp_log_level_set("*", ESP_LOG_DEBUG); |
|
|
|
|
|
|
|
// To debug, use 'make menuconfig' to set default Log level to DEBUG, then uncomment:
|
|
|
|
//esp_log_level_set("owb", ESP_LOG_DEBUG);
|
|
|
|
@ -150,6 +149,14 @@ void app_main() |
|
|
|
// vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Check for parasitic-powered devices that require a strong-pullup
|
|
|
|
bool require_strong_pullup = false; |
|
|
|
ds18b20_check_for_parasite_power(owb, &require_strong_pullup); |
|
|
|
printf("Strong pullup (parasitic power) %srequired\n", require_strong_pullup ? "" : "not "); |
|
|
|
if (require_strong_pullup) |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
// Read temperatures more efficiently by starting conversions on all devices at the same time
|
|
|
|
int errors_count[MAX_DEVICES] = {0}; |
|
|
|
int sample_count = 0; |
|
|
|
@ -157,15 +164,21 @@ void app_main() |
|
|
|
{ |
|
|
|
TickType_t last_wake_time = xTaskGetTickCount(); |
|
|
|
|
|
|
|
while (1) |
|
|
|
{ |
|
|
|
while (1) { |
|
|
|
last_wake_time = xTaskGetTickCount(); |
|
|
|
|
|
|
|
ds18b20_convert_all(owb); |
|
|
|
|
|
|
|
// In this application all devices use the same resolution,
|
|
|
|
// so use the first device to determine the delay
|
|
|
|
ds18b20_wait_for_conversion(devices[0]); |
|
|
|
if (require_strong_pullup) { |
|
|
|
ets_delay_us(750000); |
|
|
|
gpio_set_level(5, 0); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ds18b20_wait_for_conversion(devices[0]); |
|
|
|
} |
|
|
|
|
|
|
|
// Read the results immediately after conversion otherwise it may fail
|
|
|
|
// (using printf before reading may take too long)
|
|
|
|
|