Send Tweet Using Raspberry Pi and PIR Motion Detector

Introduction: Send Tweet Using Raspberry Pi and PIR Motion Detector

About: Working to help everyone enjoy smart connected things without having to share all of their data!

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 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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: 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

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

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.


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

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

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!

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





Be the First to Share


    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest
    • Fix It Contest

      Fix It Contest