Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions DS1624.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
26/03/2010 Release 0.1
Written by Federico and Riccardo Galli
http://www.sideralis.org
fixed by Richard Toth http://risko.org
*/

#include "DS1624.h"
Expand All @@ -30,23 +31,17 @@ void DS1624::start()

float DS1624::getTemp()
{
float temperature = 0;
int tempmsb = 0;
int templsb = 0;
int temp2 = 0;

uint16_t t = 0;

Wire.beginTransmission(this->addr);
Wire.write(READ_T);
Wire.requestFrom(this->addr, 2);

if (Wire.available()) {
tempmsb = Wire.read();
}
if (Wire.available()) {
templsb = Wire.read();
}
temp2 = templsb >> 3;
temperature = (float(tempmsb) + (float(temp2) * 0.03125));
if (Wire.available()) t = Wire.read() << 8;
if (Wire.available()) t |= Wire.read();

Wire.endTransmission();
return temperature;

t >>= 4;
return (float)((t & 0x800 ? (t & 0x7ff) - 0x800 : t) / 16.0);
}