I am writing a class for handling multiple DS18B20 1-Wire digital temperature sensors on the same 1-wire bus. I have my code successfully performing bus scans, and reading temeratures but I cant’ seem to get my head wraped around re-calculating the CRC codes and comparing them to the CRC values from the DS18B20 using a ‘polynomial generator’. As I understand it you compare CRC values to make sure that there was not a data collision on the bus causing bit flips or otherwise corrupted data.


Then I discovered this function: Microsoft.SPOT.Hardware.Utility.ComputeCRC (see below)…

Does anyone have any idea if it will calculate the CRC code I need and if it will, what the heck is the “seed for the CRC calculation”?

public static UInt32 ComputeCRC (
byte[] buf,
int offset,
int length,
UInt32 crc

buf A buffer of data from which the CRC is computed.
offset The offset from the beginning of the specified array to the beginning of the data to be checked.
length The number of bytes of data to be checked, starting from the offset. The value -1 indicates that all data in the buffer starting from the offset is to be checked.
crc A seed for the CRC calculation.

I am not sure this CRC method is compatible with one used by one wire.

Thanks for the reply Gus…

REFERENCE: Beginners Guide To C# and .NET Micro Framework | PDF | Digital Technology | Electronic Engineering

“GHI exclusively support one wire devices on NETMF. Dallas semiconductor’s one wiredevices, like temperature sensors or EEPROMs, use only a single wire for data transfers.Multiple devices can can be connected and controlled on a single wire. The one wire class,provide many methods to read and write bytes from one wire devices. It also includes the onewire CRC calculation method as well.This example will read the temperature from DS18B20 one wire digital thermometer. Notethat this is a GHI exclusive feature and so it requires adding the GHI assembly to the build.”

…“also includes the onewire CRC calculation method as well”…

Do you know anything about the GHI CRC calculation method mentioned above"


Yes that was on 4.1 when we had our own implementation but on 4.2 we used microsoft’s and nog sure if they exposed CRC for it. I will check for you

I’m using a Panda II so still on 4.1 I think.


Then the method is inside one wire itself.

In 4.1 you want this

which is from the 4.1 API reference in the GHIElectronics.netmf.hardware namespace, onewire class. There you will find the CalculateCRC and CalculateCRC16 methods you need

I’m going to try this today I’ll let you know how it goes.

GHIElectronics.NETMF.Hardware.OneWire.Calc ulateCRC()