Introduction: Send Tweet Using Raspberry Pi and PIR Motion Detector

Picture of Send Tweet Using Raspberry Pi and PIR Motion Detector

We love the idea of using signals from sensors to kick off all sorts of different processes.

We use NodeCode to orchestrate many different signals from many different devices and direct them to perform actions. In this case, a simple signal from a motion detector will be sent to a Service that has the ability to convert the true/false signal from the motion detector into a text signal that is then passed to another Service that is able to Tweet.

To get started with NodeCode, go to http://www.nodecode.io download the installer and then try the LED tutorial. If you are able to get through that then you should be able to set this up (as well as anything else you can imagine) very easily.

Step 1: Wire Up Our PIR Sensor

Picture of Wire Up Our PIR Sensor

We wire up the positive of the PIR Motion Detector to the 3.3v pin on the Raspberry Pi and then negative to negative as well.
We then hook up the Out of the Motion Detector to GPIO pin 17 on the board.

Step 2: Add GPIO Service and Node

Picture of Add GPIO Service and Node

We will need a RPiGpio Service Pack downloaded and added to the Raspberry Pi with the Motion Detector hooked up.
We can then drag-n-drop an Interrupt Pin Reader onto the Program Canvas and set the Pin Number to 0. NodeCode uses the excellent Wiring Pi library and has inherited the Wiring Pin numbering scheme. We've renamed the Pin to 'Motion Detector' here as well.

Step 3: Add Transform Service and Node

Picture of Add Transform Service and Node

We then need the Transform service pack downloaded and added to any device that has a NodeCode Agent installed. The same machine that is running NodeCode Studio works in this case. We've added a Bool To Signal Node as well as a Constant Signal To Text node from the Transform Service. The Constant Signal To Text Node has one property that you need to set. This will be the text value that is sent to the Twitter Service.

Note:

You can also use the Dynamic Signal to Text node if you would like to auto update the text that is tweeted via another service or view.

Step 4: Add Twitter Service and Node

Picture of Add Twitter Service and Node

We now need the Twitter service pack downloaded and added to the same machine that NodeCode Studio is running on (or any other Windows machine.. a Debian/Raspbian service pack is coming soon).

The Twitter service has two properties for you to fill out. They are the Username and the Password for the twitter account that you wish to use.

Hit save when finished.

Once we have that, back on the Program Canvas, we can drag-n-drop a Send Public Status node from the Twitter service.

Step 5: Optional Step - Add a View and Use Mobile App

Picture of Optional Step - Add a View and Use Mobile App

We've added a simple view that allows us to see the state of the pin in real-time but this is optional as is using the companion app, NodifyMe (currently being alpha tested in the play store, sign up here)

Step 6: Make Motion!

Picture of Make Motion!

That's it! Make some motion and send a tweet!

There is a limitation on sending duplicate tweets (this is a Twitter thing) but you can use Dynamic Signal To Text along with any other text nodes to generate new text to tweet each time motion is detected.

Follow us on

NodeCode.io

YouTube

Google+

Facebook

Twitter

Comments

About This Instructable

472views

11favorites

License:

Bio: Working to help everyone enjoy smart connected things without having to share all of their data!
More by jaybirdlabs:Send Tweet using Raspberry Pi and PIR Motion Detector Motion Alerts From Anywhere in the World
Add instructable to: