{"id":108,"date":"2015-09-19T15:57:48","date_gmt":"2015-09-19T15:57:48","guid":{"rendered":"https:\/\/einhugur.com\/blog\/?page_id=108"},"modified":"2016-05-01T19:30:37","modified_gmt":"2016-05-01T19:30:37","slug":"f85-vibration-sensor","status":"publish","type":"page","link":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/f85-vibration-sensor\/","title":{"rendered":"F85 Vibration sensor"},"content":{"rendered":"<p>In this example we are going to connect to\u00a0vibration sensor.<\/p>\n<p>This example is super easy after doing the infrared motion detection with the HC-SR501 in a previous example, since basically same code will work.<\/p>\n<p><span style=\"color: #808080;\">I found this sensor to be excellent, it gives readings when I expect it to and not readings when I don&#8217;t expect it to. And you can configure the sensitivity of it a bit with the settings screw on it.<\/span><\/p>\n<p><strong>Disclaimer:<br \/>\n<\/strong>We do not take any responsibility for possible errors in the guide or errors that you might do wiring it up. Incorrect wiring can result in damaged sensor or damaged Raspberry PI.<\/p>\n<p><strong>Pieces we use are:<\/strong><\/p>\n<ul>\n<li>Raspberry PI 2<\/li>\n<li>Cobbler and Cobbler cable<\/li>\n<li><span style=\"color: #999999;\"><span style=\"color: #000000;\">F85 Vibration sensor<\/span>\u00a0(They cost $5.18\u00a0Aliexpress for 10 pieces, ($0.52 a piece) where I got this one ,same one is about $5.99 a piece on Amazon)<\/span><\/li>\n<li><a href=\"https:\/\/github.com\/xojo\/GPIO\">Wiring PI Xojo module from\u00a0Paul Lefebvre<\/a><\/li>\n<\/ul>\n<p><strong>First thing is connecting the sensor:<\/strong><\/p>\n<figure id=\"attachment_110\" aria-describedby=\"caption-attachment-110\" style=\"width: 180px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/i2.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/VibrationSensor.jpg?ssl=1\"><img data-attachment-id=\"110\" data-permalink=\"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/f85-vibration-sensor\/vibrationsensor\/\" data-orig-file=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/VibrationSensor.jpg?fit=290%2C482&amp;ssl=1\" data-orig-size=\"290,482\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;2.2&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;iPhone 6&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1442677035&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.15&quot;,&quot;iso&quot;:&quot;32&quot;,&quot;shutter_speed&quot;:&quot;0.033333333333333&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}\" data-image-title=\"F85 vibration sensor\" data-image-description=\"\" data-medium-file=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/VibrationSensor.jpg?fit=180%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/VibrationSensor.jpg?fit=290%2C482&amp;ssl=1\" loading=\"lazy\" class=\"size-medium wp-image-110\" src=\"https:\/\/i2.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/VibrationSensor-180x300.jpg?resize=180%2C300&#038;ssl=1\" alt=\"F85 vibration sensor\" width=\"180\" height=\"300\" srcset=\"https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/VibrationSensor.jpg?resize=180%2C300&amp;ssl=1 180w, https:\/\/i1.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/VibrationSensor.jpg?w=290&amp;ssl=1 290w\" sizes=\"(max-width: 180px) 100vw, 180px\" data-recalc-dims=\"1\" \/><\/a><figcaption id=\"caption-attachment-110\" class=\"wp-caption-text\">F85 vibration sensor<\/figcaption><\/figure>\n<p>This sensor comes with good markings so its very easy to wire it.<\/p>\n<ul>\n<li><span style=\"color: #808080;\">(5V)<\/span>\u00a0Red is the 5V input &#8211;<span style=\"color: #808080;\"> I always use red for the power input.<\/span><\/li>\n<li><span style=\"color: #808080;\">(GPIOX)<\/span>\u00a0Yellow is the Data pin.<\/li>\n<li><span style=\"color: #808080;\">(GND)<\/span>\u00a0Blue is the ground, <span style=\"color: #808080;\">I always use blue for ground.<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #808080;\">Spec on this sensor is:\u00a0<\/span><\/p>\n<ul>\n<li><span style=\"color: #808080;\">The working voltage of 3.3V to 5V<\/span><\/li>\n<li><span style=\"font-family: Verdana; font-size: small; color: #808080;\">Product no vibration, vibration switch is closed on state, the output terminal output low level, the green light is lit<\/span><\/li>\n<li><span style=\"font-family: Verdana; font-size: small; color: #808080;\">Product vibration, the vibration switch instantaneous disconnection, output the output high level, the green light is not bright<\/span><\/li>\n<\/ul>\n<p><strong>Connecting to the Cobbler:<\/strong><\/p>\n<p>Make sure your Raspberry PI is not powered on when you do the connections.<\/p>\n<figure id=\"attachment_80\" aria-describedby=\"caption-attachment-80\" style=\"width: 225px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/Sensor-connection-e1442664059628.jpg?ssl=1\"><img data-attachment-id=\"80\" data-permalink=\"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/hc-sr501-sensor\/sensor-connection\/\" data-orig-file=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/Sensor-connection-e1442664059628.jpg?fit=480%2C640&amp;ssl=1\" data-orig-size=\"480,640\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;2.2&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;iPhone 6&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1442662628&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.15&quot;,&quot;iso&quot;:&quot;64&quot;,&quot;shutter_speed&quot;:&quot;0.033333333333333&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;6&quot;}\" data-image-title=\"Cobbler\" data-image-description=\"\" data-medium-file=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/Sensor-connection-e1442664059628.jpg?fit=225%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/Sensor-connection-e1442664059628.jpg?fit=474%2C632&amp;ssl=1\" loading=\"lazy\" class=\"size-medium wp-image-80\" src=\"https:\/\/i1.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/Sensor-connection-e1442664059628-225x300.jpg?resize=225%2C300&#038;ssl=1\" alt=\"Cobbler for Raspberry PI\" width=\"225\" height=\"300\" srcset=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/Sensor-connection-e1442664059628.jpg?resize=225%2C300&amp;ssl=1 225w, https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/Sensor-connection-e1442664059628.jpg?w=480&amp;ssl=1 480w\" sizes=\"(max-width: 225px) 100vw, 225px\" data-recalc-dims=\"1\" \/><\/a><figcaption id=\"caption-attachment-80\" class=\"wp-caption-text\">Cobbler for Raspberry PI<\/figcaption><\/figure>\n<p><a href=\"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header.png?ssl=1\"><img data-attachment-id=\"82\" data-permalink=\"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/hc-sr501-sensor\/gpio-header\/\" data-orig-file=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header.png?fit=440%2C870&amp;ssl=1\" data-orig-size=\"440,870\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"GPIO Header\" data-image-description=\"\" data-medium-file=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header.png?fit=152%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header.png?fit=440%2C870&amp;ssl=1\" loading=\"lazy\" class=\"size-medium wp-image-82 alignnone\" src=\"https:\/\/i1.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header-152x300.png?resize=152%2C300&#038;ssl=1\" alt=\"GPIO Header\" width=\"152\" height=\"300\" srcset=\"https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header.png?resize=152%2C300&amp;ssl=1 152w, https:\/\/i2.wp.com\/einhugur.net\/blog\/wp-content\/uploads\/2015\/09\/GPIO-Header.png?w=440&amp;ssl=1 440w\" sizes=\"(max-width: 152px) 100vw, 152px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p style=\"text-align: left;\"><strong>In my example then I have it connected as follows:<\/strong><\/p>\n<ul>\n<li style=\"text-align: left;\">Red to pin 2 (5V)<\/li>\n<li style=\"text-align: left;\">Blue to pin 25 (GND)<\/li>\n<li style=\"text-align: left;\">Yellow to GPIO 5 which is pin 29.<\/li>\n<\/ul>\n<p><strong>The Xojo code:<\/strong><\/p>\n<p>I have a timer to poll the sensor. we set the timer up and the pin mode in the Window Open event.<\/p>\n<pre lang=\"xojo\">Sub Open()\r\n\r\nConst kVibrationSensorPin = 5\r\n\r\nGPIO.SetupGPIO\r\n\r\nGPIO.PinMode(kVibrationSensorPin, GPIO.INPUT)\r\n\r\nTimer1.Mode = Timer.ModeMultiple\r\nTimer1.Enabled = true\r\n\r\nEnd Sub<\/pre>\n<p>In the Timer.Action event I got the following code:<\/p>\n<p>(If you want it more responsive then you can increase the cycles of the for loop)<\/p>\n<pre lang=\"xojo\">Sub Action()\r\nDim i as Integer\r\nConst kVibrationSensorPin = 5\r\n\r\nfor n as Integer = 1 to 10\r\ni = GPIO.DigitalRead(kVibrationSensorPin)\r\n\r\nif i = 1 then\r\nListbox1.AddRow \"Shaking detected\"\r\nreturn\r\nend if\r\nApp.DoEvents(1)\r\nnext\r\n<\/pre>\n<p style=\"text-align: left;\">End Sub<\/p>\n<p>Thats all there\u00a0is to it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this example we are going to connect to\u00a0vibration sensor. This example is super easy after doing the infrared motion detection with the HC-SR501 in a previous example, since basically same code will work. I found this sensor to be excellent, it gives readings when I expect it to and not readings when I don&#8217;t &hellip; <a href=\"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/f85-vibration-sensor\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">F85 Vibration sensor<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":94,"menu_order":10,"comment_status":"closed","ping_status":"closed","template":"","meta":{"spay_email":""},"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/Pd75nk-1K","jetpack-related-posts":[{"id":113,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/flame-sensor\/","url_meta":{"origin":108,"position":0},"title":"Flame sensor","date":"September 19, 2015","format":false,"excerpt":"In this example we are going to connect to flame\u00a0sensor. Programming for this sensor works on exactly the same principle as the\u00a0HC-SR501 infrared sensor and the F85 vibration sensor except the signal from this sensor comes inverted. As in it will send 1 when everything is all right and zero\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/FlameSensor-e1442681877884-225x300.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":137,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/ir-infrared-obstacle-reflection-photoelectric-sensor\/","url_meta":{"origin":108,"position":1},"title":"IR Infrared Obstacle Reflection Photoelectric Sensor","date":"September 20, 2015","format":false,"excerpt":"In this example we are going to connect to infrared obstacle reflection photoelectric sensor motion detection sensor. I am not going to deny it, I find this sensor to be awful rubbish. Without reading the data you can hook it up and see it when the 2nd green lights goes\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/IRSensor-e1442754741492-225x300.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":128,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/dht11-and-dht22-humidity-temperature-sensors-3-pin-version\/","url_meta":{"origin":108,"position":2},"title":"DHT11 and DHT22 humidity & temperature sensors (3 pin version)","date":"September 20, 2015","format":false,"excerpt":"In this example we are going to connect\u00a0to DHT11 and or DHT22 humidity & temperature sensor. This sensor reads both the humidity and temperature. (This guide was updated on 24. Oct 2015, greatly improving the DHT11 device driver code and added DHT22 device driver code and wiring pictures for the\u2026","rel":"","context":"Similar post","img":{"alt_text":"DHT22 sensor","src":"https:\/\/i0.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/DHT22.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":94,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/","url_meta":{"origin":108,"position":3},"title":"Xojo GPIO","date":"September 19, 2015","format":false,"excerpt":"Guides for GPIO in Xojo \u00a0Infrared motion detection (Updated 1. May 2016) Shows\u00a02 ways of coding: Using Interrupts or simple polling. Sensors: \u00a0HC-SR501,\u00a0ST-00082 Mini,\u00a0Mini IR Pyroelectric Infrared PIR Motion Human Sensor Detector Module Uses:\u00a0Basic GPIO Relay board In this example we \u00a0wire up a relay board and let your Xojo\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":617,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/bmp180-barometer-sensor\/","url_meta":{"origin":108,"position":4},"title":"BMP180 Barometer sensor","date":"May 22, 2016","format":false,"excerpt":"In this example we are going to connect to BMP180 barometer sensor, we will be using brake-out board called GY-68. This sensor is really small even the full brake-outboard is only size of a fingernail. The board does not come with the header pins soldered on, but with mine the\u2026","rel":"","context":"Similar post","img":{"alt_text":"BMP180Soldered","src":"https:\/\/i1.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2016\/05\/BMP180Soldered.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":165,"url":"https:\/\/einhugur.net\/blog\/index.php\/xojo-gpio\/hc-sr04-ultrasonic-sensor\/","url_meta":{"origin":108,"position":5},"title":"HC-SR04 and US-015 - Ultrasonic sensors","date":"September 22, 2015","format":false,"excerpt":"In this example we are going to connect to HC-SR04 and or US-015\u00a0ultrasonic sensor. (Updated 18. Oct 2015, adding US-015 sensor and sensor specs) (Updated 18. Apr 2016, adding more info for accuracy for the HC-SR04 sensor) A ultrasonic sensor will send ultrasonic sound out which will echo on objects\u2026","rel":"","context":"Similar post","img":{"alt_text":"Ultrasonic wiring","src":"https:\/\/i1.wp.com\/einhugur.com\/blog\/wp-content\/uploads\/2015\/09\/Screen-Shot-2015-09-22-at-00.01.38.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages\/108"}],"collection":[{"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":6,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages\/108\/revisions"}],"predecessor-version":[{"id":279,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages\/108\/revisions\/279"}],"up":[{"embeddable":true,"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/pages\/94"}],"wp:attachment":[{"href":"https:\/\/einhugur.net\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}