Windows 10 IoT Raspberry Pi 2: DHT22 / AM2302

I just wanted to start experimenting with the DHT22 / AM2302 (temperature and humidity sensor), but I have no idea how to initialize and get data from this ... I tried using GpioPin:

gpioController = GpioController.GetDefault(); if(gpioController == null) { Debug.WriteLine("GpioController Initialization failed."); return; } sensorPin = gpioController.OpenPin(7); //Exception throws here sensorPin.SetDriveMode(GpioPinDriveMode.Input); Debug.WriteLine(sensorPin.Read()); 

but get an exception: "The resource required for this operation is disabled."

After that, I looked at the library for unixoids and found this:

https://github.com/technion/lol_dht22/blob/master/dht22.c

But I have no idea how to understand that in VCSharp using Windows 10, does anyone have an idea or experience?

Thank you in advance!

UPDATE:

I got a hint that there is no GPIO-Pin 7, and this is true, so I repeated it, but the GPIO-Output seems just HIGH or LOW ... Therefore, I need to use I2C or SPI ... According to this project, I decided to try it with SPI: http://microsoft.hackster.io/windowsiot/temperature-sensor-sample and take steps forward ... the difficulty now is to transfer the above linked C-library with the C-Sharp-SDK to get the right data ...

 private async void InitSPI() { try { var settings = new SpiConnectionSettings(SPI_CHIP_SELECT_LINE); settings.ClockFrequency = 500000; settings.Mode = SpiMode.Mode0; string spiAqs = SpiDevice.GetDeviceSelector(SPI_CONTROLLER_NAME); var deviceInfo = await DeviceInformation.FindAllAsync(spiAqs); SpiDisplay = await SpiDevice.FromIdAsync(deviceInfo[0].Id, settings); } catch(Exception ex) { Debug.WriteLine("SPI Initialization failed: " + ex.Message); } } 

This does not work as well as to be clear: it only works once, starting raspberries pasp2, and then it starts / uninstalls the debugging program, but after exiting the application and restarting it, their SPI is not initialized.

And now I'm working on reading data from a pin and will show the code in a future update. Any comments, answers and / or recommendations are still welcome.

+5
source share
1 answer

DHT22 requires a very accurate time. Although the core of the Rabberry PI / Windows 10 IoT is extremely fast, as it is an operating system where other things have to happen, if you are not writing some low-level driver (and not C #), you will not be able to generate the timings needed for communication with DHT22.

I am using a cheap Arduino Mini Pro for about $ 5 for the sole purpose of generating and sending the correct timings between the microcontroller and the Raspberry Pi, and then setting up some kind of communication channel between the Arduino Mini Pro (I2C, Serial) to pull data from the Arduino.

+1
source

All Articles