Skip to content

DeviceStartConvert()

Arnd edited this page Dec 12, 2020 · 3 revisions

DeviceStartConvert([DeviceIndex][,WaitSwitch]);

This function will initiate a conversion (temperature measurement) on all DS-Family devices found if no parameters are specified, otherwise the conversion is started for only the device specified in DeviceIndex. If the optional WaitSwitch is set to "true", the function call will not return until the conversion is complete.

When one or more parasite devices are present, any subsequent 1-Wire operations that come in before the number of milliseconds specified in public variable ConversionMillis have passed after the DeviceStart_Convert() call will be delayed so that the conversion(s) can finish.

Likewise, the ReadDeviceTemp() function, if called before the last conversion call has had enough time to complete, will pause until the conversion is complete.


Example:

const uint8_t ONE_WIRE_PIN = 8;             // 1-Wire microLAN pin
DSFamily_Class ds(ONE_WIRE_PIN);            // Instantiate
uint8_t thermometers = ds.ScanForDevices(); // find all devices
Serial.print("Found ");
Serial.println(thermometers);
ds.DeviceStartConvert(thermometers-1);      // Start a conversion on the last device
Serial.print("Temperature of device ");
Serial.print(thermometers-1);
Serial.print("is ");
int16_t temp = ds.ReadDeviceTemp(thermometers-1);
Serial.print(temp*0.0625,3);                // using floating point
Serial.println("C");