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

Member Since 27 Mar 2013
Offline Last Active Nov 23 2013 08:32 PM
-----

Posts I've Made

In Topic: Netduino Plus 2 OneWire DS18B20 on 4.2

07 August 2013 - 11:58 PM

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.