No commit activity in last 3 years
No release in over 3 years
A Humble RPi plug to detect knocks using a knock sensor (piezo element).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.1.1, ~> 0.1
 Project Readme

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