Onewire device network

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?

I use this:


        static float GetTemperature(byte tempLo, byte tempHi)
        {
            return ((short) ((tempHi << 8) | tempLo))/16F;
        }

Please try Chris’ library from here: http://code.tinyclr.com/project/157/onewire-temp-sensor-example-ds18b20/

This works on my b and S models.

hm, that gives me the exact same result.
I’m starting to think this sensor is ready for the graveyard.

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

Have a look at the Code part. There is a helper.

"MULTIPLE DS18B20 SENSORS ON ONE LINE "

Cu, Wim.

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.

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.