Skip to content

Instantly share code, notes, and snippets.

@jezman
Created September 8, 2016 13:35
Show Gist options
  • Save jezman/b3b79839aa7174e40d6e513b464c65a6 to your computer and use it in GitHub Desktop.
Save jezman/b3b79839aa7174e40d6e513b464c65a6 to your computer and use it in GitHub Desktop.
DHT11 + QuadDisplay
#!/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