This is a simple, fun project that will introduce you to Arduino boards, as well as Octoblu's IoT platform and messaging service, Meshblu.
With this you will be able to see how positive or negative the Tweets are for a specified hashtag on Twitter. We will see either a red, blue, or green LED get powered based on the sentiment analysis performed by Octoblu.
Octoblu is an Internet of Things platform that allows you to connect your devices to it, then send messages from one device to another, using Meshblu.
Throughout this guide, we will be setting up an Arduino, creating a custom Meshblu device, and then creating an Octoblu Flow.
For the setup of the LEDs on your board, please look at this Fritzing Schematic:
Now all you need to do is burn standard firmata to it!
If you are unsure about how to burn firmata to your board, here is a great guide for Arduino beginners.
Now that you have standard firmata on your board, we can control the pins via Octoblu by creating a custom Meshblu device.
There is a meshblu-custom-device-boilerplate, which I recently added an arduino branch to. This branch already has everything you need for this project...
Clone the repository, switch to the arduino branch, and install dependencies:
git clone firstname.lastname@example.org:ASteinheiser/meshblu-custom-device-boilerplate.git cd meshblu-custom-device-boilerplate git checkout arduino npm install
Now we will need to create a meshblu.json file with meshblu-util. This is Meshblu's way of creating credentials for your new device.
Install meshblu-util, then register the device:
npm install --global meshblu-util meshblu-util register -o > meshblu.json
Note: We pass the -o or --open flag, is so that it creates a v1 device in Meshblu. We are currently working on the transition to v2 devices, however, for now custom devices need to be v1.
Claiming your device with meshblu-util should open up a browser window asking you to login and then claim the device to your account:
And with that, you have your device on your Octoblu account. Now we can design a flow to use your new device!
I recommend importing my example Flow for this project:
So, when you hit the Trigger on this Flow, it will do a number of things:
- Gets Tweets that contain a specified hashtag
- Breaks the Tweets into individual messages
- Throttles each Tweet by 3 seconds
- Performs sentiment analysis on each Tweet
- Decides which LED to turn on based on the results of the analysis
Note: You will also notice another instance of our custom Meshblu device, called Turn off Leds. This will do exactly that, and I made sure to connect it to the trigger and the throttle. This is so each time you trigger the flow, it will turn the LEDs off. Also, if you have, for example, two positive Tweets in a row, the LED will flicker off briefly to show that multiple Tweets were analyzed.