Strange Problem | Arduino | Forum


Please consider registering

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Strange Problem
No permission to create posts
July 22, 2011
5:48 pm
New Member
Forum Posts: 2
Member Since:
June 28, 2011
sp_UserOfflineSmall Offline

I've run into a strange problem involving trying to integrate the thingsTweet app into my program. The arduino basic example seems to work well when using one analoge input to update a graph.


I tried adding the updateTwitterStatus function into the mix (yes I've defined the thingsTweet api variable) and it consistently gives me a 400 bad request. I'm not even calling the function yet from the loop. Simply having the function in my sketch causes the 400 bad request. The sketch compiles fine with no errors. Here's the function:


void updateTwitterStatus(String msg)


if (client.connect() && msg.length() > 0)  {     // Create HTTP POST Data    

msg = "api_key="+thingtweetAPIKey+"&status="+msg;        Serial.println("Connected to ThingTweet...");    Serial.println();            client.print("POST /apps/thingtweet/1/statuses/update HTTP/1.1\n");    client.print("Host:\n");

client.print("Connection: close\n");

client.print("Content-Type: application/x-www-form-urlencoded\n");    client.print("Content-Length: ");    




}  else  {    

Serial.println("Connection Failed.");     





While trying to debug this problem I removed the client.print commands from this function but left everything else in and then the sketch started working properly. If I left even just one line of client.print in the updateTwitterStatus function the sketch fails. I also tried creating a new instance of client called clientTwitter leaving client for the  updateThingSpeak function. Still caused problems.


I'm kind of stumped here. Is this an arduino ethernet library bug or is it a thingspeak problem?

July 22, 2011
6:19 pm
Natick, MA

Forum Posts: 396
Member Since:
January 18, 2011
sp_UserOnlineSmall Online

This does not solve the imediat issue, but you can post and Tweet at the same time if you want.

example: field1=6&twitter=(twitter username linked with ThingTweet)&tweet=(your tweet)

You would only want to do this occasionally and not with every insert to your ThingSpeak channel. Twitter would rate limit you.

We will check into the other sketch. Can you send us the PDE your using?

July 24, 2011
1:00 am
Natick, MA

Forum Posts: 396
Member Since:
January 18, 2011
sp_UserOnlineSmall Online

I have written a new Arduino sketch that combines the Thing Channel update and ThingTweet sketch into one.

You can download it here:

Try this and see if this works for you and your situation.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: Hans, agrisensezm
37 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

Archieter, JamesExedo, IrbosHich, brodi, kasko, franklin castro

Administrators: Hans: 387, lee: 457