Created
September 8, 2016 13:35
-
-
Save jezman/b3b79839aa7174e40d6e513b464c65a6 to your computer and use it in GitHub Desktop.
DHT11 + QuadDisplay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'dht-sensor-ffi' | |
require 'rpi_gpio' | |
PIN = 7 | |
DHT_MODEL = 11 # 11 or 22 | |
RPi::GPIO.set_numbering :board | |
RPi::GPIO.set_warnings(false) | |
RPi::GPIO.setup PIN, :as => :output | |
loop do | |
val = DhtSensor.read(PIN, DHT_MODEL) | |
system("/home/pi/display #{val.temp}") | |
if val.temp > 30 | |
RPi::GPIO.set_high PIN #Fan power on | |
else | |
RPi::GPIO.set_low PIN #Fan power ff | |
sleep 3 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment