Well after quite a few hours of struggle (yes I know its character building) I got my Arduino to tweet changes in temperature reading (don't want to know every few seconds/minutes). Perhaps this might be useful to someone or perhaps someone will say "what a fool - there's a much easier way to do that" hey ho - my shoulders are broad! In practice I will reduce the frequency of update by some margin - but this is a test program after all. I did search the forums and did not find what I wanted but perhaps I searched using the wrong search criteria? My program uses the simple 3 pin semiconductor temperature device as included in the Arduino kit.
#include <SPI.h>
#include <Ethernet.h>
#include <Twitter.h>
const int sensorPin = A0;
byte mac[] = { my stuff };
byte ip[] = { 192, 168, 0, 40 };
// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("my stuff in here");
char Text[80];
int num;
int tempold = 20;
void setup()
{
delay(3000);
Ethernet.begin(mac, ip);
Serial.begin(9600);
}
void loop()
{
delay(10000);
int sensorval = analogRead(sensorPin);
float voltage = (sensorval/1024.0) * 5.0;
int temp = (voltage - 0.5) * 100;
if (temp != tempold)
{
tempold = temp;
++num;
sprintf(Text, "Temperature %1d Centrigrade %2d", temp, num);
Serial.println(Text);
Serial.println("connecting ...");
delay(3000);
if (twitter.post(Text)) {
int status = twitter.wait();
if (status == 200) {
Serial.println("OK.");
} else {
Serial.print("failed : code ");
Serial.println(status);
}
} else {
Serial.println("connection failed.");
}
}
}