Duplicate Twitter Status work around

Hi

I've just bought an Uno with my pocket money and I'm trying to wire up my door to post messages to twitter. I can't seem to get around the duplicate twitter status block. I would love to tweet "door open :" datetime. So basically just append the date and time to the status door open, but I don't know how and don't know how to append a datetime to a char... sorry not experienced enough yet :astonished:

My code (taken from instructables) is below and I was hoping someone with more experience could help me out...

/* Example 30.2 - tweeting digital event status
Use the ethernet shield and your Arduino board to send tweets
Big thanks to @neocat and Georg Kaindl Arduino Tutorials | tronixstuff.com > chapter thirty */
// necessary libraries#if defined(ARDUINO) && ARDUINO > 18
// If using Arduino 0019 or later, include SPI.h
#if defined(ARDUINO) && ARDUINO > 18
#include <SPI.h>
#endif
#include <Ethernet.h>
#include <Twitter.h>

char b1[]="Door Open";

byte mac[] = { 0x92,0xA5,0xDA,0x00,0x7E,0x48 };

byte ip[] = { 192,168,1,8 };

Twitter twitter("#####################");

void setup()
{
delay(5000);
Ethernet.begin(mac);
Serial.begin(9600);
pinMode(2, INPUT);
}
void tweet(char msg[])
{
Serial.println("connecting ...");
if (twitter.post(msg))
{
int status = twitter.wait(&Serial);
if (status == 200)
{
Serial.println("OK.");
} else
{
Serial.print("failed : code ");
Serial.println(status);
}
} else
{
Serial.println("connection failed.");
}
}
void loop()
{
if (digitalRead(2)==HIGH)
{ tweet(b1); delay(2000); }
}

Search the forum. This is a regular topic.

Thank you but I'm stuck. I started looking for this over 6 hours ago (it's all I've done) and I can't seem to find the proper solution, I've looked up and down this forum and see it all over the place but can't see a complete solution that I can use for my door project.

I really didn't want to ask for help, but I'm at the point of giving up

found this common one but it doesn't work at it looks like twitter function only allows chars? could someone please help me?

#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>
#include <util.h>

#include <SPI.h>

#include <Udp.h>

#include <Twitter.h>
#include <Client.h>
#include <Server.h>

String dataString;
const int buttonPin = 2;
int buttonState = 0;

byte mac[] = {0x92,0xA3,0xDA,0x00,0x7E,0x48}; // arbitrary mac address for ethernet shield

Twitter twitter("############################");
char msg[] = ("Mail");

void setup()
{
pinMode(buttonPin, INPUT);
Ethernet.begin(mac);
Serial.begin(9600);

delay(1000);

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

void loop(){
dataString = "Mail";
long timeStamp = millis();
dataString += timeStamp;
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
twitter.post(dataString);
int status = twitter.wait();
delay(10000);
}
}

The first thing you need to have is a date and time to append to the tweet message. I don't see that your sketch has a clue what time it is.

The tweet function is passed a string to send. It is easy to add to that string.

char buffer[128]; // Could be smaller
sprintf(buffer, "%s  %d:%d:%d", msg, hour, minute, second);

Now, post() buffer, instead of message (assuming you figure out how to get hour, minute, and second as integers).

Oh boy...

Sorry I'm 13... this is too hard for me

Thanks PaulS... think I sorted it out... hour and minutes and seconds are a bit screwy, but it works.

reposting to help others:

#include <Time.h>
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>
#include <util.h>

#include <SPI.h>

#include <Udp.h>

#include <Twitter.h>
#include <Client.h>
#include <Server.h>

String dataString;
const int buttonPin = 2;
int buttonState = 0;

byte mac[] = {0x92,0xA3,0xDA,0x00,0x7E,0x48}; // arbitrary mac address for ethernet shield

Twitter twitter("#################################");
char msg[] = ("Door Open");

//char buffer[128]; // Could be smaller
//sprintf(buffer, "%s %d:%d:%d", "mail", hour, minute, second);

void setup()
{
pinMode(buttonPin, INPUT);
Ethernet.begin(mac);
Serial.begin(9600);

delay(1000);

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

void loop(){
dataString = "Mail";
long timeStamp = millis();
dataString += timeStamp;
char*(dataString);

//String dataString = "Hello";
//long timeStamp = millis();
//dataString += timeStamp;
//int n = dataString.length()+1;
//char st[n];
//dataString.toCharArray(st,n);

// String str = "Hello World";
// int n = str.length()+1;
// char st[n];
// str.toCharArray(st,n);

char buffer[128]; // Could be smaller
sprintf(buffer, "%s %d:%d:%d", msg, hour(), minute(), second());

buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
twitter.post(buffer);
int status = twitter.wait();
delay(10000);
}
}

hour and minutes and seconds are a bit screwy, but it works.

You, in effect, got an electric clock, and plugged it in. You expect it to set itself. That rarely happens.