Skip to content

jrobertson/humble_rpi-plugin-knocksensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introducing the HumbleRPi-plugin-knocksensor gem

Testing the plugin

require 'humble_rpi-plugin-knocksensor'


class Echo

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

sensor = HumbleRPiPluginKnockSensor.new(settings: {pin: 0}, 
                                        variables: {notifier: Echo.new})
sensor.start

Output:

2016-03-06 22:53:02 +0000: pi/knock: detected
2016-03-06 22:53:02 +0000: pi/knock: detected
2016-03-06 22:53:03 +0000: pi/knock: detected
2016-03-06 22:53:03 +0000: pi/knock: detected
2016-03-06 22:53:04 +0000: pi/knock: detected
2016-03-06 22:53:05 +0000: pi/knock: detected
2016-03-06 22:53:06 +0000: pi/knock: detected
2016-03-06 22:53:06 +0000: pi/knock: detected
2016-03-06 22:53:07 +0000: pi/knock: detected
2016-03-06 22:53:07 +0000: pi/knock: detected
2016-03-06 22:53:08 +0000: pi/knock: detected
2016-03-06 22:53:09 +0000: pi/knock: detected
2016-03-06 22:53:09 +0000: pi/knock: detected

Note: The default threshold is set to 10, and the default analog pin is set to 0.

Using the plugin with the HumbleRPi gem

require 'humble_rpi'
require 'humble_rpi-plugin-knocksensor'

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

Resources

See also

humblerpi gem knocksensor sensor plugin

About

A Humble RPi plug to detect knocks using a knock sensor (piezo element).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages