Well,
it does not work for a DS18S20.
From an arduino library I got this:
int16_t rawTemperature = (((int16_t)scratchPad[TEMP_MSB]) << 8) | scratchPad[TEMP_LSB];
return (float)(rawTemperature >> 1) - 0.25 +((float)(scratchPad[COUNT_PER_C] - scratchPad[COUNT_REMAIN]) / (float)scratchPad[COUNT_PER_C] );
and I know it works, because I used that library for a long time.
Now i converted this to C#:
Int32 rawTemperature = (Int32)((tempHigh << 8) | tempLow);
TemperatureC = (float)(rawTemperature >> 1) - 0.25f + ((float)(countc - countremain) / (float)countc);
However, I get a temperature of 203.125°C which is…yeah, kinda high considering the sensor is just sitting on my breadboard.
Can any of you spot a possible mistake?
Gralin
June 15, 2011, 10:13am
22
I use this:
static float GetTemperature(byte tempLo, byte tempHi)
{
return ((short) ((tempHi << 8) | tempLo))/16F;
}
MarkH
June 15, 2011, 10:20am
23
hm, that gives me the exact same result.
I’m starting to think this sensor is ready for the graveyard.
MarkH
June 15, 2011, 10:43am
25
Are you running it as parasitic or powered? Do you have all the right resistors in place?
powered and the resistor is in place.
The other sensors on the network (DS18B20 and DS2438) report their temp correctly, it’s only this DS18S20 that is not correct.
Will try another one soon.
HVACengi,
Would you please send me your multiple sensor onewire code to docwelch at yahoo dot com.
Thanks
WimC
July 4, 2011, 6:00am
28
Have a look at the Code part. There is a helper.
"MULTIPLE DS18B20 SENSORS ON ONE LINE "
Cu, Wim.
goseid
July 5, 2011, 12:29pm
29
Wim, thanks for posting your code. It should be very helpful.
I’m new to programming TinyCLR. I’m assuming the helper you mentioned is the c_Convert.iso attachment. Can you give a little guidance as to how to implement it? I’m not familiar with “.iso” files and how to reference them in c#.
Thanks in advance.
Greg
This is strange, why the file is iso?! If you rename the file to zip, you can open it and see the file inside.
WimC
July 6, 2011, 8:05am
31
That indeed is strange Gus.
It should really be a .zip file.
Can you rename it please or shall I upload an new one?
@ all:
The c_Convert class is in [url]http://code.tinyclr.com/project/317/ls7366-library/[/url] too.
Cu, Wim.