Hi, i found an article about using DS18B20 temperature sensor with just OneWire library, the problem is the accuracy is set to 1 degree:
#include <OneWire.h> int16_t dallas(int x,byte start){ OneWire ds(x); byte i; byte data[2]; int16_t result; do{ ds.reset(); ds.write(0xCC); ds.write(0xBE); for (int i = 0; i < 2; i++) data[i] = ds.read(); result=(data[1]<<8) |data[0]; result>>=4; if (data[1]&128) result |=61440; if (data[0]&8) ++result; ds.reset(); ds.write(0xCC); ds.write(0x44, 1); if (start) delay(1000); } while (start--); return result; } void setup{ dallas(A0,1); } void loop{ float currentTemp = dallas(A0,0); }
How can i get accuracy of .5 degree from this?
PS: i just copy/pasted above code from the site that i linked above, i don't know what's happening or what code doing what! i'm new to arduino and that is some advanced C++ for me!