Skip to content

A Humble RPi plugin to read the ambient temperature and humidity from the DHT sensor.

Notifications You must be signed in to change notification settings

jrobertson/humble_rpi-plugin-dhtsensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introducing the Humble_Rpi-plugin-dhtsensor gem

Testing the gem

require 'humble_rpi-plugin-dhtsensor'

class Echo

  def notice(s)
    puts "%s: %s" % [Time.now, s]
  end
end

rpi = HumbleRPiPluginDhtSensor.new(settings: {pin: 4}, 
                                      variables: {notifier: Echo.new})
rpi.start

Output:

ready to monitor temperature and humidity
2016-02-20 13:14:35 +0000: pi/dht11_sensor: temperature: 15.0 humidity: 39.0
2016-02-20 13:15:13 +0000: pi/dht11_sensor: temperature: 16.0 humidity: 39.0
2016-02-20 13:16:15 +0000: pi/dht11_sensor: temperature: 17.0 humidity: 38.0
2016-02-20 13:18:22 +0000: pi/dht11_sensor: temperature: 18.0 humidity: 38.0
2016-02-20 13:24:47 +0000: pi/dht11_sensor: temperature: 17.0 humidity: 38.0
2016-02-20 13:25:49 +0000: pi/dht11_sensor: temperature: 16.0 humidity: 38.0

In the above example I tested the sensor by adding a cup of water (that was previously warm) next to the DHT11 sensor at 1315hrs. I then removed the cup of water at 1319hrs and I observed it took 1 or more minutes for the temperature to change.

Notes:

  • By default the temperature and humidity is refreshed every 3 seconds
  • The temperature and humidity will be published when ever the temperature value changes by 1 or more, or if the humidity value changes by 2 or more.

Using the plugin with the Humble RPi gem

require 'humble_rpi'
require 'humble_rpi-plugin-dhtsensor'

r = HumbleRPi.new device_name: 'ottavia', sps_address: '192.168.4.140',\
  plugins: {DhtSensor: {pin: 4} }
r.start

Resources

humblerpidhtsensor gem dhtsensor humblerpi

About

A Humble RPi plugin to read the ambient temperature and humidity from the DHT sensor.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages