https://github.com/oldhammade/dht-pi
Example code for using the DHT11/22 temperature & humidity sensor with the Raspberry Pi
https://github.com/oldhammade/dht-pi
Last synced: about 2 months ago
JSON representation
Example code for using the DHT11/22 temperature & humidity sensor with the Raspberry Pi
- Host: GitHub
- URL: https://github.com/oldhammade/dht-pi
- Owner: OldhamMade
- License: mit
- Created: 2016-12-04T20:51:11.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-02T18:43:59.000Z (about 8 years ago)
- Last Synced: 2025-02-27T21:30:24.196Z (2 months ago)
- Language: C
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DHT11/22 TEMPERATURE & HUMIDITY SENSOR
This repository contains C code and instructions for using UUGear's DHT11 & DHT22
temperature & humidity sensors with the Raspberry Pi. Example taken from [here](http://www.uugear.com/portfolio/read-dht1122-temperature-humidity-sensor-from-raspberry-pi/)## Usage
Install `git`, clone the `wiringPi` repository:
$ git clone git://git.drogon.net/wiringPi
...then build & install:
$ cd wiringPi
$ ./buildNext, clone this repository:
$ git clone https://github.com/OldhamMade/dht-pi
$ cd dht-pi...and build the binary:
$ cc -Wall dht.c -o dht -lwiringPi
This binary can be executed with the following command:
$ sudo ./dht
A `JSON` object will be issued to the console every 2 seconds. Be aware that
reading the data can often fail due to timing issues. In this case, the values
of the `JSON` will all be `null`. It is recommended to cache the last good set
of values to use when `null` values are returned.For applications, one suggestion for usage would be to move the `dht` binary to
`/usr/local/bin` and run it via a supervisor process (for example,
[supervisord](http://supervisord.org)), capturing the output to a log, then
reading the last line from the log output when needed.