Zhang Yuexin

C# programmer. Know a bit of hardware knowledge. 3D model design novice.

张高兴 - 土味儿编程


张高兴的 Windows 10 IoT 开发笔记:DHT11 温湿度传感器

本文约 201 字,包含 0 张图片,5 个代码段,阅读时间约 1 分钟
QR Code


This is a Windows 10 IoT Core project on the Raspberry Pi 2/3, coded by C#.



  • OUT - Pin 3
  • VCC - 5V
  • GND - GND



What Contains

In DHT11.cs file

One Struct

// DHT11 data struct
struct DHT11Data
  // Temperature - ℃
  public short Temperature;
  // Humidity - %
  public short Humidity;
  // Check the data is true or false
  public bool IsTrue;

One Constructor

You need to pass sensor pin value to create a new object.

Three Methods

// Initialize DHT11
public void Initialize();
// Read data from DHT11
public DHT11Data Read();
// Cleanup
public void Dispose();

How to Use

  • First, you need to create a DHT11 object. After that you should call Initialize() to initialize.
DHT11 sensor = new DHT11(3);
  • Second, Read().
DHT11Data data = sensor.Read();
  • If you want to close the sensor, call Dispose().
最后更新时间 : 2017/01/29 22:07 张高兴 阅读(778) 评论(0)
文章标签: C# UWP IoT Raspberry Pi
Click to Refresh