Stefano finished the DIY Santa Claus Singer with Flyport application and now he’s sharing with all of us.
First we need to create an automatic control which, connecting with Twitter, is able to identify those tweet with specific hashtag (#). To do this, you have to register on paraimpu.crs4.it (it’s a set cloud services for the IoT; more on paraimpu) and add a new “Sensor”: the Twitter Sensor with hashtags happynewyear,openpicus o merrychristmas,openpicus.
Important is that you put a hashtag control, ie openpicus, in fact the sensor controls in this case only the tweets with both words and that is an AND between openpicus and merrychristmas. Add an openPICUS or general type “Actuator”, by taking then the token to use on the firmware of Flyport.
You’ll need two sensors, one per pair of hashtags, and a single actuator. We connect the sensors to the actuator through the black arrow “follow” and activate the connection you just created by clicking on the “play”.
Now each time a user writes on twitter a tweet with selected hashtags, paraimpu will registrate them on the actuator.
Now, let’s see the real electronics part!
I have a Santa Claus that lights up and moves when you turn on its switch. So bypassing the switch, you can build a virtual switch with an NPN transistor. The base is controlled by the signal coming from the “out2″ of Flyport with a resistor to limit the base current. Our Santa Claus, it’s like an active load between the collector and VDD (2 AA batteries) and the emitter to ground (GND) shared by Flyport and Santa Claus.
After setting the usual Wizard on openPicus IDE (with GenericTCPClient TX: 1200 and RX: 1200), we have to import the libraries dedicated to paraimpu (still in beta) named paraimpu.h e paraimpu.c .
The feature that interests us is this:
void jsonGETPARAIMPU( char* token, char* data);
Indicating a token and a string in which write data, the function allows you to connect to the paraimpu server, query the device that has that specific token and rewrite the data received on the given string.
For each request is taken and then deleted from the server only the oldest record among those available. Other combinations are also possible by adding various parameters to the command query http.
while (WFStatus != CONNECTED);
in response we’ll have: blank page, 204 No content or the received raw data (in this case from my account with the couple hashtags #merrychristmas #openpicus):
The “if” are for distinguish the various possibilities. “Else” is important because allows us not to switch-on Santa Claus when the page is blank or when there are no data available (ie no one tweet hashtags pairs).
Now just complilate, upload the firmware on Flyport and enjoy your singer Santa!