Presumably you have the device set for 12 bit precision. The datasheet says the conversion will take 750ms at that resolution. You've measured 854 - close enough.
If you want to speed up the conversion you can change to a lower precision. At 9 bits the conversion time is 93.75ms.
There is always the option not to wait for the converted temperature but doing something else instead.
in pseudocode
void setup()
{
...
requestNewTemperature();
}
void loop()
{
if (newTemperatureAvailable())
{
t = getTemperature();
requestNewTemperature();
}
// process t
// and other things
}
I've written a similar asynchronous extension for the Dallas Temperature Control lib (3.7.x) that does just this.
robtillaart:
There is always the option not to wait for the converted temperature but doing something else instead.
in pseudocode
void setup()
{
...
requestNewTemperature();
}
void loop()
{
if (newTemperatureAvailable())
{
t = getTemperature();
requestNewTemperature();
}
// process t
// and other things
}
I've written a similar asynchronous extension for the Dallas Temperature Control lib (3.7.x) that does just this.
- https://github.com/milesburton/Arduino-Temperature-Control-Library -
Hi, I'm doing a similar project, can you tell me more about how to do it?
You might be a bit more specific about your project. The issue here is that the sensor takes time to do its job, up to 750ms, and it varies according to the resolution. Read the data sheet. Arduino can do other things in the meantime and, if you only want readings at intervals greater than 750ms, none of this is a problem. Having several sensors makes no difference either.
All you need is here
In the unlikely event you need lightening-fast readings, you need a different sensor. You may even be demanding fast readings inadvertently, but no-one will know until you post the code.
robtillaart:
There is always the option not to wait for the converted temperature but doing something else instead.
in pseudocode
void setup()
{
...
requestNewTemperature();
}
void loop()
{
if (newTemperatureAvailable())
{
t = getTemperature();
requestNewTemperature();
}
// process t
// and other things
}
I've written a similar asynchronous extension for the Dallas Temperature Control lib (3.7.x) that does just this.
- https://github.com/milesburton/Arduino-Temperature-Control-Library -
Hi, I'm doing a similar project, can you tell me more about how to do it?
as I said "... the Dallas Temperature Control lib (3.7.x) that does just this."
Download the lib and check the waitforconversion2 example