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:

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

update: 20-feb-2016 @ 14:15

Version 0.1.1 by default will now only publish notifications once every 60 seconds or more.

Resources