No commit activity in last 3 years
No release in over 3 years
A Humble RPi plugin which detects the opening or closing of a door using a magnetic switch sensor.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.1.2, ~> 0.1
>= 0.1.5, ~> 0.1
 Project Readme

Introducing the Humble_rpi-plugin-magneticswitch gem

Testing the plugin

require 'humble_rpi-plugin-magneticswitch'


class Echo

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


switch = HumbleRPiPluginMagneticSwitch.new(settings: {pins: [21]}, variables: {notifier: Echo.new})
switch.start

Output:

ready to detect magnetic switches
magnetic switch sensor 1 on GPIO 21 enabled
2016-02-18 21:21:47 +0000: pi/magneticswitch/0: door closed
2016-02-18 21:22:28 +0000: pi/magneticswitch/0: door open
2016-02-18 21:22:41 +0000: pi/magneticswitch/0: door closed

Running the plugin from the HumbleRPi gem

require 'humble_rpi'
require 'humble_rpi-plugin-magneticswitch'

r = HumbleRPi.new device_name: 'ottavia', sps_address: '192.168.4.140',\
  plugins: {MagneticSensor: {pins: [21]} }
r.start

Resources

humblerpipluginmagneticswitch plugin humblerpi gem sensor