Finally got temperature readings to twitter

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
Twitter twitter("my stuff in here");
char Text[80];
int num;
int tempold = 20;
void setup()
  Ethernet.begin(mac, ip);

void loop()
 int sensorval = analogRead(sensorPin);
 float voltage = (sensorval/1024.0) * 5.0;
 int temp = (voltage - 0.5) * 100;
 if (temp != tempold)
  tempold = temp;
  sprintf(Text, "Temperature  %1d Centrigrade %2d", temp, num);
  Serial.println("connecting ...");
  if ( {
    int status = twitter.wait();
    if (status == 200) {
    } else {
      Serial.print("failed : code ");
  } else {
    Serial.println("connection failed.");