No need for RLP since we have the PinCapture class available !
Please find below some (very quick) code I made this morning to read temp/humid from a DHT11 sensor. It is similar to the DHT22 (proprietary one-wire protocol), but you need testing. The DHT11 is great because cheap and accurate enough ! However its temperature range is only 0-50°C therefore I don’t know if the code below will work for negative temperature. Send me a DHT22 sensor and I’ll make you the driver
However, I was never able to make it work just using a single pin of my fez domino : PinCapture is made with an InputPin, and I was never quick enough on the same pin sending an Output “start signal” with “OutputPin” then switching to PinCapture to read the results. Then I used 2 pins I connected together to the sensor data pin. One pin “DHT11out” is a tristate port, because it can send a low 0 and high impedance 1s. One pin “DHT11in” is the Pincapture port.
for my test, the DHT11 is powered with 3.3v, I use data pin 6 as output and data pin 7 as input/pincapture (hardwired together). You may pick up any other port as far as they can work as interrup inputs.
Someday I will post an official driver, but at least this code is giving you a working example.
public class Program
public static void Main()
uint buffer = new uint;
TristatePort DHT11out = new TristatePort((Cpu.Pin)FEZ_Pin.Digital.Di6, false,false,Port.ResistorMode.PullUp);
if (DHT11out.Active == false) DHT11out.Active = true; // Make tristateport "output"
DHT11out.Write(true); //"high up"
PinCapture DHT11in = new PinCapture((Cpu.Pin)FEZ_Pin.Digital.Di7, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
DHT11out.Write(false); // "low down" : initiate transmission
Thread.Sleep(20); // For "at least 18ms"
if (!rt || rf) Debug.Print("Error : the 2 pins are not hardwired together !");
DHT11out.Write(true); //"high up" then listen
nb = DHT11in.Read(false, buffer, 0, 100, 1000);
if (nb < 81) Debug.Print("Error : did not get enough state change");
else // We read it from the last bit, since we don't know when we started recording
nb -= 2; // skip last 50us down
for (i = 0; i < 8; i++, nb -= 2) checksum |= (byte)(buffer[nb] > 50 ? 1 << i : 0);
for (i = 0; i < 8; i++, nb -= 2) decimalT |= (byte)(buffer[nb] > 50 ? 1 << i : 0);
for (i = 0; i < 8; i++, nb -= 2) integralT |= (byte)(buffer[nb] > 50 ? 1 << i : 0);
for (i = 0; i < 8; i++, nb -= 2) decimalRH |= (byte)(buffer[nb] > 50 ? 1 << i : 0);
for (i = 0; i < 8; i++, nb -= 2) integralRH |= (byte)(buffer[nb] > 50 ? 1 << i : 0);
//check if checksum is correct
if (((integralRH + decimalRH + integralT + decimalT) & 0xFF) != checksum) Debug.Print("Checksum Error");
Debug.Print("Temperature = " + integralT + "." + decimalT);
Debug.Print("Humidity = " + integralRH + "." + decimalRH);
Sorry for the ansi C looking like code