CC3000 SendTweet programming help

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
quade
 
Posts: 61
Joined: Sat Dec 14, 2013 5:03 pm

CC3000 SendTweet programming help

Post by quade »

My CC3000 is working great! No worries there.
I've set up a Twitter dev account. I've even posted a couple of test tweets.

AWESOME!

However, where I'm stuck is coding it up to do something actually useful as opposed to the same message once an hour.

At the start of the void loop is where the example code has a place to enter in that single message. It also has a comment about if you wanted to add a sensor, you'd need to "then nicely format the results into a buffer to be passed to the sendTweet() function."

Ah, see, there is my issue. I can easily read a sensor (I'm using the BMP180) and turn that value into a String that says;
"Temp 70F"

Code: Select all

//*** BMP180 stuff
  tF = ((bmp.readTemperature()*9/5)+32); //Note tF is an int variable.
  stringTwo = "Temp "  + tF + 'F';
//*** End BMP180 stuff
  
  sendTweet(stringTwo);
But sendTweet() doesn't want a String. It wants a char*.

Dang.

How can I "nicely format the results into a buffer to be passed to the sendTweet() function"?

User avatar
adafruit_support_mike
 
Posts: 67391
Joined: Thu Feb 11, 2010 2:51 pm

Re: CC3000 SendTweet programming help

Post by adafruit_support_mike »

Personally, I use 'sprintf()' and a global char array for most IO.

Creating formatted text is a complex problem, so any utility that does it has to choose between "powerful but complex" and "simple but limited". The String class leans toward the "simple but limited" side, and is good for basic diagnostic messages. 'sprintf()' uses the most commonly accepted "powerful but complex" syntax, and isn't that bad once you've become used to it.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”