Go Down

Topic: Twitter and NTP Time (Read 904 times) previous topic - next topic

arduinocc

Dec 09, 2011, 02:32 pm Last Edit: Dec 21, 2011, 08:12 am by arduinocc Reason: 1
Hello all together

I have a question for the forum community
Is it possible to send a Tweet with the current time?
I guess that i must use udp ntp required at the time of a server on the network.
Just as it is possible to add this time to the Twitter message using this code below.

Message should look like so after, for example, on Twitter

User post: The weather is beautiful at 15:23:34

Hope Finally somebody has an idea or usable code

thanks for read and help
from Germany
:smiley-fat:

arduinocc

is it possible , has anybody an idea ?

dxw00d

Does this help at all? I don't have a net shield yet, so I can't try it myself.

http://arduino.cc/en/Tutorial/UdpNtpClient

PeterH

You could go and hit NIST (or whatever other servers you can find) but I suspect you'll find it easier just to plug in a real time clock. Don't forget to address timezone and daylight saving time adjustment issues if you're displaying timestamps within your message.
I only provide help via the forum - please do not contact me for private consultancy.

James C4S

The Time library simplifies the task of tracking the current time.  Additionally, the library comes with an example, called "TimeNTP", that shows how to connect to a NTP server and update the time.  A RTC is helpful but not necessary in this case.

http://www.arduino.cc/playground/Code/Time
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

arduinocc

OK thanks that helps me a lot, but the main problem is to add the time to the message. can there anybody help me ?

why can i add there the ntp time ?
Code: [Select]
char msg [] = "message to send"; 

or add there ?
Code: [Select]
twitter.post( (msg)) ...

can anyone help me, much thanks too all

regards from germany arduino club


PaulS

Code: [Select]
char msg [] = "message to send"; 
msg is a fixed size array. There is no room to add more data to the array (the time).

If you create a larger array, fixed size, initialized properly, you could append the time to, and send, the larger array.
Code: [Select]
char msgToSend[80];
msgToSned[0] = '\0';
strcat(msgToSend, msg);
strcat(msgToSend, " ");
strcat(msgToSend, timeString);
twit.post(msgToSend);


This presumes that you have a string called timeString that contains the tine, of course.

arduinocc


this error  for this line from you msgToSend[0] = '\0';
how can i fix it ?


try:35: error: expected constructor, destructor, or type conversion before '=' token
try:36: error: expected constructor, destructor, or type conversion before '(' token
try:37: error: expected constructor, destructor, or type conversion before '(' token
try:38: error: expected constructor, destructor, or type conversion before '(' token
Try.cpp: In function 'void loop()':
try:156: error: 'timString' was not declared in this scope

Catcher

You should post all your code.

I'm not sure if you have msgToSend[0] or msgToSned[0], both versions of which have appeared in this thread.
I am also unsure whether you have timString or timeString, reasoning from the error output you posted.

James C4S

You can't run instructions outside of a function.  The code you added, the strcats, needs to be moved to a function...
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Go Up