Raspberry Pi 使用温湿度传感器(AM2302)

jackxiang 2013-9-20 18:59 | |
背景:孵化时不得不要温度监控。AM2302 (wired DHT22) temperature-humidity sensor -价格有点高,但不用写代码。
淘宝上卖得有点高:http://item.taobao.com/item.htm?spm=a230r.1.0.0.uWRxwK&id=18906174315
参考:http://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/overview

1.连线:

am2302不需要使用电阻,只需连接三个针脚即可(1,2,4)

1-->3.3v 既第一个针脚

2-->GPIO 可随意连接一个gpio针脚 (第7个阵脚,对应的是gpio pin 4)

3-->GND 连接接地针(连接的是第6个针脚)

然后参考http://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/software-install,下载安装执行命令即可



简单记录仅供备忘。。。

来自:http://www.cnblogs.com/yaoshan/archive/2013/03/14/2924701.html

Adapting the DHT C code

Since the DHT sensors use a low-level "Manchester-esque" timing protocol to send data, we need to be able to read the pin they are connected to at very high speeds. The python libraries aren't fast enough, but the low level C libraries are! The code we wrote is a good example of how to deal with bitbang in user space, without the need to write a kernel driver

Grab the lowlevel BCM2835 C Library from http://www.open.com.au/mikem/bcm2835/index.html
$ wget http://www.open.com.au/mikem/bcm2835/bcm2835-1.8.tar.gz
$ tar -zxvf bcm2835-1.8.tar.gz
$ cd bcm2835-1.8
$ ./configure
$ make
$ sudo make install
Then compile the Adafruit_DHT program with

gcc Adafruit_DHT.c -l bcm2835 -std=gnu99 -o Adafruit_DHT

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/6676/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2013-9-20 19:13
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]