Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

rbagley66's Content

There have been 1 items by rbagley66 (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#52034 Netduino Plus 2 OneWire DS18B20 on 4.2

Posted by rbagley66 on 07 August 2013 - 11:58 PM in Netduino Plus 2 (and Netduino Plus 1)

I am also getting the same error in the same location. TouchReset??  I do have a  reference to Microsoft.SPOT.Hardware.OneWire in my project. Any help would be great.

 

I am running VS2012 with 4.3.  Below is the code I am using. Just trying to get to work.

 

public static void Main()

{

// DS18B20, NETMF 4.2

// center pin is connected to digital pin 0, right pin is connected to 5V,

// left pin GND, 4k7 pull-up resistor between 5V and the center pin

OneWire oneWire = new OneWire(new OutputPort(Pins.GPIO_PIN_D0, false));

ushort temperature;

while (true)

{

if (oneWire.TouchReset() > 0)

{

oneWire.WriteByte(0xCC); // Skip ROM, we only have one device

oneWire.WriteByte(0x44); // Start temperature conversion

while (oneWire.ReadByte() == 0) ; // wait while busy

oneWire.TouchReset();

oneWire.WriteByte(0xCC); // Skip ROM

oneWire.WriteByte(0xBE); // Read Scratchpad

temperature = (byte)oneWire.ReadByte(); // LSB

temperature |= (ushort)(oneWire.ReadByte() << 8); // MSB

//Temperatu in C, If you will in F would be: ((1.80 * (temperature / 16.0)) + 32);

Debug.Print("Temperature: " + temperature / 16.0 + "C");

}

else

{

Debug.Print("No device detected");

}

Thread.Sleep(1000);

}

?

}





home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.