A ruby library to read from a DHT-XX type humidity/temperature sensor
MIT License
A Ruby library for reading from a DHT-11 or DHT-22 type sensor connected to a Raspberry Pi
First install the bcm2835 lib (v1.51+), available at: http://www.airspayce.com/mikem/bcm2835
Then either install manually
gem install dht-sensor-ffi
or add to your Gemfile
gem "dht-sensor-ffi"
require "dht-sensor-ffi"
val = DhtSensor.read(4, 22) # pin=4, sensor type=DHT-22
puts val.temp # => 21.899999618530273 (temp in C)
puts val.temp_f # => 71.4199993133545 (temp in F)
puts val.humidity # => 22.700000762939453 (relative humidity %)
val = DhtSensor.read(4, 22, 10) # 10 retries
There is also a simple binary for testing purposes
$ dht_sensor
Temperature: 22.40 C Humidity: 26.70%
Note: Running as root
may be required, depending on your configuration. YMMV!
Copyright (c) 2014 Chetan Sarva. Licensed under the MIT license. See LICENSE.txt for further details.