Introduction: 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 in all its 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, paste 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 <SPI.h> #include <Ethernet.h> #include <Twitter.h><br><br>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 ";<br> stringMsg += analogRead(0);<br> stringMsg += " out of 1023. Dey belongs to us nao."; //Convert our message to a character array char msg[140];<br> stringMsg.toCharArray(msg, 140);<br> //Tweet that sucker! twitter.post(msg); }
Step 3: Make Some Changes of Your Own and Tweet Like Mad!
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!

Participated in the
Formlabs Contest
9 Comments
8 years ago on Introduction
Hi There,
Love the instructable! I just got my board through today and have been tinkering around with it, I have uploaded your code and used my twitter auth token, however when I press the button it doesn't tweet anything? Is there a way to view logs etc?
Thanks,
Ainsey11
Reply 8 years ago on Introduction
A few ideas:
1) Are you using the token you got from NeoCat's website or are you using one that you have gotten previously? I haven't looked too deeply into it, but I would be willing to be that your actual twitter token and the one being used for NeoCat's tweeting service are different. Since the library goes to NeoCat's twitter app, you would need his/her token for your account. You also have to give NeoCat's app the permission to post for you.
2) Have you set up your wifi? Is it still connected? You can test this by opening your Edison in an SSH terminal (like putty), logging in, and then typing "ping www.instructables.com". If you are connected to the internet, you should get a response back.
3) You are sending a lot of identical tweets back to back and Twitter is blocking them. Make sure you have a delay like I show in the code (or add more sophisticated debounce), that your button is wired correctly (you should have a 10k pull-down resistor to ground), that your button is on the correct pin, and that your button is working. To test if your button is working, open the Arduino IDE for Edison and type the following. If your button works, you should get a bunch "It works!" on your serial monitor.
void setup(){ pinMode(8, INPUT); Serial.begin(9600);}
void loop(){if(digitalRead(8) Serial.println("It works!");}
4) You can try NeoCat's code to debug the connection. Replace "twitter.post(msg)" with this:
if (twitter.post(msg)) {
int status = twitter.wait();
if (status == 200) {
Serial.println("OK.");
} else {
Serial.print("failed : code ");
Serial.println(status);
}
} else {
Serial.println("connection failed.");
}
Reply 8 years ago on Introduction
Thanks for getting back to me!
Turns out I had my button connected to the wrong connector!
DUUhhhh :D
Cheers!,
Ainsey11
Reply 8 years ago on Introduction
Heheh, glad you figured it out ^-^
Reply 7 years ago
Awesome instructable! And that identical tweets thing caught me off guard, almost made me go mad that it wasn't working even though the code was perfect!
8 years ago on Introduction
does the #include<Ethernet.h> support the Intel edison being connected to wifi instead of ethernet over usb.
In short does your code work for edison boards connected to wifi?
8 years ago on Step 3
Thanks. I made it.
Now time to read from twitter timeline.
8 years ago on Introduction
I made it. Thanks!
8 years ago on Introduction
Hi A_Steingrube,
I wanted to display a tweet in my 16*2 Grove RGB LCD Display!
Can you help me with the code!
Thanks alot !
Regards,
Geeve