Go Down

Topic: Send dynamic tweet strings via the Twitter library (Read 1 time) previous topic - next topic


Hello everyone!

I use the Twitter library that supports OAuth http://www.arduino.cc/playground/Code/TwitterLibrary and i want to post the values from a temperature sensor along with some additional text, in the same tweet.

As such, a tweet should contain a static text as well as the dynamic temperature value taken from the temp sensor.

So here is my question:

How can i concatenate a static text with a dynamic value in order to send the entire string via a single tweet ?

I test the following code taken from the Twitter library page:

Code: [Select]
/* Post a simple message to Twitter  */
#include <Ethernet.h>
#include <Twitter.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
byte gateway[] = { 10, 0, 0, 1 };
byte subnet[] = { 255, 255, 0, 0 };

Twitter twitter("YOUR-TOKEN");
char msg[] = "Hello, World! I'm Arduino!";

void setup()
 Ethernet.begin(mac, ip, gateway, subnet);


 Serial.println("connecting ...");
 if (twitter.post(msg)) {
   int status = twitter.wait();
   if (status == 200) {
   } else {
     Serial.print("failed : code ");
 } else {
   Serial.println("connection failed.");

void loop()

In the example code above, the string array variable contains a static string
Code: [Select]
char msg[] = "Hello, World! I'm Arduino!";

The "post" function of the twitter library
Code: [Select]
twitter.post(msg) expects a const char *message variable.

What do i need to do to concatenate a static text and a dynamic value ?

Any help to the right direction is much appreciated!



Something like this:
Code: [Select]
char buffer[80];
sprintf(buffer, "Current temp: %d", tempC);

The art of getting good answers lies in asking good questions.


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131