I am try to add random number with the tweet message but i am failed to add this function by use analog read to the message can any one help be with code ...
#include <EtherCard.h>
// OAUTH key from http://arduino-tweet.appspot.com/
#define TOKEN ""
// ethernet interface mac address, must be unique on the LAN
byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const char website[] PROGMEM = "arduino-tweet.appspot.com";
static byte session;
byte Ethernet::buffer[700];
Stash stash;
static void sendToTwitter () {
Serial.println("Sending tweet...");
byte sd = stash.create();
const char tweet[] = "My Message here"; / i want to add analog reading to my message every time tweet.
stash.print("token=");
stash.print(TOKEN);
stash.print("&status=");
stash.println(tweet);
stash.save();
int stash_size = stash.size();
// Compose the http POST request, taking the headers below and appending
// previously created stash in the sd holder.
Stash::prepare(PSTR("POST http://$F/update HTTP/1.0" "\r\n"
"Host: $F" "\r\n"
"Content-Length: $D" "\r\n"
"\r\n"
"$H"),
website, website, stash_size, sd);
// send the packet - this also releases all stash buffers once done
// Save the session ID so we can watch for it in the main loop.
session = ether.tcpSend();
}
void setup () {
Serial.begin(57600);
Serial.println("\n[Twitter Client]");
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println(F("Failed to access Ethernet controller"));
if (!ether.dhcpSetup())
Serial.println(F("DHCP failed"));
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
if (!ether.dnsLookup(website))
Serial.println(F("DNS failed"));
ether.printIp("SRV: ", ether.hisip);
sendToTwitter();
}
void loop () {
ether.packetLoop(ether.packetReceive());
const char* reply = ether.tcpReply(session);
if (reply != 0) {
Serial.println("Got a response!");
Serial.println(reply);
}
}
i want my tweet to be different every time cos twitter reject's the identical content so i think about the random message number to add every time arduino tweet.
i want my tweet to be different every time cos twitter reject's the identical content so i think about the random message number to add every time arduino tweet.
I know that you do, and I know that that stupid system rejects duplicate tweets.
But, you claimed that you tried to add a random number, but the code you posted says that you didn't.
What have you tried?
It is the value in tweet that needs to change, but it can't because there is no more room AND it is const(ant).
const char website[] PROGMEM = "arduino-tweet.appspot.com";
int analogzero;
static byte session;
byte Ethernet::buffer[700];
Stash stash;
static void sendToTwitter () {
Serial.println("Sending tweet...");
byte sd = stash.create();
analogzero=analogRead(A0);
char tweet[]="MY Message ";
stash.print("token=");
stash.print(TOKEN);
stash.print("&status=");
stash.println(tweet),analogzero;
stash.save();
int stash_size = stash.size();
// Compose the http POST request, taking the headers below and appending
// previously created stash in the sd holder.
Stash::prepare(PSTR("POST http://$F/update HTTP/1.0" "\r\n"
"Host: $F" "\r\n"
"Content-Length: $D" "\r\n"
"\r\n"
"$H"),
website, website, stash_size, sd);
// send the packet - this also releases all stash buffers once done
// Save the session ID so we can watch for it in the main loop.
session = ether.tcpSend();
}
I try this on it's compile no problem but not working ..
i try by another way which as below also compile no problem not working
int analogZero;
char tweet[140];
static byte session;
byte Ethernet::buffer[700];
Stash stash;
static void sendToTwitter () {
Serial.println("Sending tweet...");
byte sd = stash.create();
stash.print("token=");
stash.print(TOKEN);
stash.print("&status=");
stash.println(tweet);
stash.save();
int stash_size = stash.size();
// Compose the http POST request, taking the headers below and appending
// previously created stash in the sd holder.
Stash::prepare(PSTR("POST http://$F/update HTTP/1.0" "\r\n"
"Host: $F" "\r\n"
"Content-Length: $D" "\r\n"
"\r\n"
"$H"),
website, website, stash_size, sd);
// send the packet - this also releases all stash buffers once done
// Save the session ID so we can watch for it in the main loop.
session = ether.tcpSend();
}
void setup () {
Serial.begin(57600);
Serial.println("\n[Twitter Client]");
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println(F("Failed to access Ethernet controller"));
if (!ether.dhcpSetup())
Serial.println(F("DHCP failed"));
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
if (!ether.dnsLookup(website))
Serial.println(F("DNS failed"));
ether.printIp("SRV: ", ether.hisip);
sendToTwitter();
}
void loop () {
ether.packetLoop(ether.packetReceive());
analogZero=analogRead(A0);
sprintf(tweet, "my message: %d. @username.", analogZero);
delay(60000);
}
The "random" number generator on the Arduino always returns the same sequence of values, unless you call randomSeed(). This is actually useful for testing purposes.
If you are not getting the second and subsequent tweets, you need to determine whether they are being blocked by twitter.
Serial.print() the string uselessTweet to see whether the random number actually changes. It should. If it does, the messages are still be blocked by twitter (and I wouldn't blame them).