Use Arduino to send tweets

Use Arduino to send tweets

One of the most useful things I see in free hardware is the ability to get solutions to everyday problems without having to shell out a lot of money. In a search for solutions for my everyday problems I have seen this curious tutorial that has surprised me since I did not expect that Arduino could work directly with Twitter since among other things, Arduino is not an SBC board. With this tutorial we will be able to obtain an automatic tweet publication system and what is better, a useful code to insert in any program and that publishes a tweet for each correct action that our arduino board does.

For this we will need an arduino board with Ethernet shield or, failing that, an arduino Yún. Through these boards, we will be able to connect our board with the internet and with our Twitter account to be able to send tweets.

In order to make operate this tweet posting system, we will need an internet connection and in the case of using an ethernet board, we will need a network cable to connect our board to the internet.

With Arduino Yún we will have an automatic tweet system

Once all this is achieved, now we will need a token or code so that our arduino board can work with our Twitter account, something like an authorization for our account. This token or permission can be obtained through this link, popping up something like that.

Twitter Token

Once we have the token, we copy the code it offers us and save it as it will be more useful later. Now we have to work with the Arduino IDE. We go to the ide and create a file that we will upload to our arduino board. But before we get off this bookstore and we will load it previously with the Arduino IDE. Now we create a file with the following code:

#include // Necesario en Arduino 0019 o posterior

// Configuracion de la Ethernet Shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// Si no se especifica la IP, se utiliza DHCP (solo para Arduino 1.0 o superior).
byte ip[] = { 192, 168, 0, 250 };

Twitter twitter("INTRODUCIR TOKEN AQUI");

// Mensaje
char msg[] = "¡Publicando en Twitter desde #Arduino gracias a este tweet";

void setup()
Ethernet.begin(mac, ip);
// Si usamos DHCP no hace falta incluir la IP.
// Ethernet.begin(mac);

Serial.println("Estableciendo conexion con Twitter ...");
if ( { // Publicamos el mensaje en Twitter. Devuelve true o false.
int status = twitter.wait(&Serial);
if (status == 200) { // Conexion exitosa
} else { // Error en la conexion
Serial.print("Error : code ");
} else {
Serial.println("Conexion fallida.");

void loop()

Once we have loaded this file, without it working we will see how tweets appear in our account with the message that we have marked in the code. Even if beforehand It may not seem very useful, it can always be used as a robot to program a tweet or simply be part of a more complex code.

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

3 comments, leave yours

Leave a Comment

Your email address will not be published.



  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   rehmmaster said

    Do not copy. not knowing. include are missing. Clown

    1.    John Louis Groves said

      Hello Rehmaster,

      There are many ways to comment on this news and better yet, to help our community continue to grow than to use insults.

      As the entry says, you have the library to download and in any high-level compiler, for example Eclipse, all you have to do is attach it to the project so that it is available and the program itself automatically gives you the option to import it. when you are going to use a library's own function.

      As you can see, it is not necessary to specify this type of thing since, understanding what the program does, what we want to achieve, surely you know this type of thing beforehand and you do not need to be told how to enter an import specific.


  2.   Gustavo said

    Hi, I have not been able to implement this code to do it wirelessly using a wifi network. with a WiFly.
    apparently the library does not allow it.
    Do you have any idea how to solve this?
    I have seen some projects on the internet but they only do searches or twitter counts, but not publish a tweet.
    Thank you!

Spanish quizTest Catalanspanish quiz