diff --git a/lib/sensor_ds18b20.c b/lib/sensor_ds18b20.c index 0ae2476..1ef6a11 100644 --- a/lib/sensor_ds18b20.c +++ b/lib/sensor_ds18b20.c @@ -109,8 +109,14 @@ float sensor_ds18b20_temperature(uint64_t code) } // send ROM command to select slave - if (!onewire_master_rom_match(code)) { // select specific slave - return NAN; // ROM command failed + if (0 == code) { // broadcast convert + if (!onewire_master_rom_skip()) { // select all slaves + return false; // ROM command failed + } + } else { + if (!onewire_master_rom_match(code)) { // select specific slave + return false; // ROM command failed + } } // read scratchpad to get temperature (on byte 0 and 1) diff --git a/lib/sensor_ds18b20.h b/lib/sensor_ds18b20.h index 28f2b66..20f1334 100644 --- a/lib/sensor_ds18b20.h +++ b/lib/sensor_ds18b20.h @@ -36,7 +36,7 @@ bool sensor_ds18b20_convert(uint64_t code); */ float sensor_ds18b20_temperature(uint64_t code); /** set conversion precision - * @param[in] code ROM code of sensor to start conversion on (0 for all, if only DS18B20 sensors are on the bus) + * @param[in] code ROM code of sensor to start conversion on (0 for single DS18B20 sensor are on the bus) * @param[in] precision precision in bits (9-12) * @return if operation succeeded */