Skip to content

Instantly share code, notes, and snippets.

@jdotbdot
Created March 22, 2016 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdotbdot/3c0bbbe3e32f15512fc2 to your computer and use it in GitHub Desktop.
Save jdotbdot/3c0bbbe3e32f15512fc2 to your computer and use it in GitHub Desktop.
PIR Sensor to MQTT - Raspberry Pi, Orvibo wifi power socket

Typically this flow is used to switch lights by means of Orvibo wifi power switches.

The PIR sensor output is 1 when it sees movement and 0 when it doesnt. It has adjustable sensitivity and "on time" by means of potentiometers.

There is also a period after it goes to 0 when the sensor will not recognise movement (the "Insensitive time" or Ti). On my sensor this is about 7 seconds.

This flow seeks to avoid the lights being off and unresponsive during Ti.

[{"id":"bf156a65.c215e8","type":"mqtt-broker","z":"","broker":"192.168.1.140","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"6bc1f694.cc3348","type":"rpi-gpio in","z":"a7579327.9b853","name":"PIR on 8","pin":"8","intype":"in","debounce":"25","read":true,"x":80,"y":120,"wires":[["698c3344.b7543c","a6eebeb4.2e4168"]]},{"id":"698c3344.b7543c","type":"switch","z":"a7579327.9b853","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","outputs":2,"x":230,"y":120,"wires":[["45303c01.309ecc"],["bb367860.9e868"]]},{"id":"45303c01.309ecc","type":"trigger","z":"a7579327.9b853","op1":"reset","op2":"on","op1type":"val","op2type":"val","duration":"10","extend":false,"units":"ms","reset":"","name":"ON","x":390,"y":80,"wires":[["24980ed1.fd1d92"]]},{"id":"bb367860.9e868","type":"trigger","z":"a7579327.9b853","op1":"off","op2":"off","op1type":"nul","op2type":"val","duration":"10","extend":true,"units":"s","reset":"reset","name":"OFF","x":390,"y":200,"wires":[["64dad6d0.133088"]]},{"id":"75a9252e.ab6e64","type":"comment","z":"a7579327.9b853","name":"Jumper shoukd be set to retriggering (H?). On duration is determined by sensor pot.","info":"","x":310,"y":40,"wires":[]},{"id":"a6eebeb4.2e4168","type":"rpi-gpio out","z":"a7579327.9b853","name":"LED on 18","pin":"18","set":"","level":"0","out":"out","x":190,"y":200,"wires":[]},{"id":"9f7c86b9.2430c8","type":"comment","z":"a7579327.9b853","name":"OFF is delayed 10 sec to cover Ti the inhibited time","info":"","x":530,"y":260,"wires":[]},{"id":"62c61ebe.181f1","type":"comment","z":"a7579327.9b853","name":"Therefore need to cancel Off in case 0->1 within this time","info":"","x":550,"y":300,"wires":[]},{"id":"24980ed1.fd1d92","type":"switch","z":"a7579327.9b853","name":"Cancel Off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"reset","vt":"str"}],"checkall":"true","outputs":2,"x":410,"y":140,"wires":[["64dad6d0.133088"],["bb367860.9e868"]]},{"id":"64dad6d0.133088","type":"mqtt out","z":"a7579327.9b853","name":"","topic":"orvibo/ACCF238DA1E3","qos":"","retain":"","broker":"bf156a65.c215e8","x":690,"y":200,"wires":[]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment