Tweet with your Intel Edison

So, you've got this cool new Edison, but what to do with it? Well, it DOES talk to the internet fairly well, so let's make it talk to the internet!

Interestingly enough, the ethernet libraries for Arduino work just as well on the Edison, so why not use them?

I am piggybacking off of a very good tutorial found here: http://arduino-tweet.appspot.com/
As a result of my piggybacking, I am using (and trusting) NeoCat's app that gets the twitter token you will need to tweet with your Edison. While I am a rather trusting person (perhaps destructively so), you may want to dig around to get your token from https://dev.twitter.com/ . Unfortunately, at the time of writing this, the developer site is by invite only....so NeoCat's option was definitely the best.

So, to get started, visit NeoCat's website, follow his/her tutorial to get the twitter library and your twitter token: http://arduino-tweet.appspot.com/

As NeoCat mentioned on their site, please don't abuse the service. Keep your tweets sparse. If you need something that tweets every 6 seconds, you should set up your own server and twitter app.

I am also counting on the fact (it IS a fact, right?) that you have already gone through the Getting Started tutorials Intel has so kindly made for us. You can find them here: https://communities.intel.com/docs/DOC-23147


And, of course, FOLLOW ME ON TWITTER! @foxrobotics

Step 1: Let's add some sensors

A randomly tweeting Edison can be fun, but let's add some sensors to it.

For this instructable, I will be using the Grove Starter Kit for Edison to save myself a bit of time. I'm normally a proponent of breadboards and custom circuit boards, but hey, why not? You can easily replicate this by connecting a button yourself that has a 10k pull down resistor. Search for "Arduino button circuit" online to find it.

In this example, I will be connecting the button to D8. I will also be connecting a light sensor to A0 (again, search "Arduino light sensor" for explicit circuits). Connect them as shown in the picture if you have the same Grove kit.

Step 2: Let's write some code!

Your code it all it's glory! You'll notice that many bits and pieces are "missing" from NeoCat's code. The Linux kernel handles a lot of that for you. I did remove the wait command (if you saw his/her code) as it always hangs. I don't know if this is due to a change in the Twitter API, his/her site, or something in the Edison.

(Note, if the Instructables website messes up the formatting, copy and paste everything, past it in the Arduino Edison IDE, do a search and replace for "
" and replace with nothing. Then go to Tools>>Auto Format. Your code will look happy again.)

#include #include #include

void setup(){ pinMode(8, INPUT); } void loop(){ if(digitalRead(8)){ tweetMessage(); delay(1000); } } void tweetMessage(){ Twitter twitter("your token here"); //Our message (in lolcat, of course) String stringMsg = "All ur lightz be ";
stringMsg += analogRead(0);
stringMsg += " out of 1023. Dey belongs to us nao."; //Convert our message to a character array char msg[140];
stringMsg.toCharArray(msg, 140);
//Tweet that sucker! twitter.post(msg); }

Step 3: Make some changes of your own and tweet like mad!

Tweet with your Intel Edison

Click "Upload" (the right pointing arrow button) and you are done! Viola!

My code is meant to be insanely simple so it is easy to follow. But, add your own sensors, actuators, random furry animals, and make it your own!

 
 

Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel