DisplayTemp

#include // needed in Arduino 0019 or later
#include
#include
// Temp Init
#include
#include

// we need fundamental FILE definitions and printf declarations
#include

// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Super nauwkeurig
#define TEMPERATURE_PRECISION 12

// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Ethernet Shield Settings
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// If you don’t specify the IP address, DHCP is used(only in Arduino 1.0 or later).
byte ip[] = {
192, 168, 0, 250 };

// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter(“15630100-XRwPZ7YPS8lzkRslfbj0Era6qMlYov6MojZrlFUWU”);

void setup()
{
delay(1000);
Ethernet.begin(mac, ip);
// or you can use DHCP for autoomatic IP address configuration.
// Ethernet.begin(mac);
Serial.begin(9600);
Serial.println(“Dallas Temperature IC Control Library Demo”);

// Start up the library
sensors.begin();
// Convert
Serial.print(“Requesting temperatures…”);
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println(“DONE”);

float temp = sensors.getTempCByIndex(0);
Serial.println (“Temp as float, measured”);
Serial.println( temp );

// Init msg
char msg[140];

Serial.println(“Msg is: “);
char temps[10];
dtostrf(temp, 2, 2, temps);
Serial.println( sprintf(msg,”Current Temp: %d Celcius”, temps) );
Serial.println();

Serial.println(“connecting to Twitter …”);
if (twitter.post(msg)) {
// Specify &Serial to output received response to Serial.
// If no output is required, you can just omit the argument, e.g.
// int status = twitter.wait();
int status = twitter.wait(&Serial);
if (status == 200) {
Serial.println(“OK.”);
}
else {
Serial.println(); // Lege regel
Serial.println(“failed : code “);
Serial.print(status);
}
}
else {
Serial.println(“connection failed.”);
}

}

void loop()
{

}

Leave a Reply

Your email address will not be published. Required fields are marked *