-
1Step 1
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 https://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.
First, we need to wire up our PIR sensor.
-
2Step 2
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 (https://projects.drogon.net/raspberry-pi/wiringpi/pins/). We've renamed the Pin to 'Motion Detector' here as well.
-
3Step 3
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.
-
4Step 4
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.
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).
-
5Step 5
Once you've added the Twitter service pack, set your Username and Password and then click save.
Once we have that, we can drag-n-drop a Send Public Status node from the Twitter service.
We've also added a simple view that allows us to see the state of the pin in real-time but this is optional as is the companion app, NodifyMe. Play Store
The final program canvas with the View and View Window should look something like the following:
Now when you get motion for the first time, you will instantly tweet the text that was set in the Constant Signal to Text node.
Twitter has a duplicate message policy that prevents a duplicate message to be sent unless x number of other messages have been sent first.. changing a character is sufficient to allow the next tweet to go through.
That's it for this NodeCode project! Thank you and we hope you enjoy!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.