Introduction: Tweeting Temp Sensor

Make your own Tweeting Temperature Sensor that can work anywhere with WiFi.

Step 1: Step 1: Build Your Temperature Sensor

Required Parts:

1 - Photon

1 - dht22 Temperature Sensor

1 - Breadboard

1 - 10K Resistor

5 - Wires

1 - USB to Mini-USB Cord

1 - Wall Plug

Set up your photon like shown in the Fritzing Diagram above :)

Step 2: Step 2: Create a Twitter Account and Set Up Arduino-tweet.appspot.com

Create the twitter you want to tweet from the Photon. After creating the twitter go to arduino-tweet.appspot.com and put in your twitter token. This site will give you a new token which you will put into the code in the next step. This allows you to tweet from the photon.

Step 3: Step 3: Push Your Code on Build.particle.io (Code Below and in Picture)

// This #include statement was automatically added by the Particle IDE.

#include

// OAuth Key #define TOKEN "825469186306617344-sDdIZblaYgQhyNLGgIuk1p4a5yuFytD"

// Twitter Proxy #define LIB_DOMAIN "arduino-tweet.appspot.com"

TCPClient client; #define DHTPIN 0 // what pin we're connected to #define DHTTYPE DHT22 // which sensor we are using: DHT 22

DHT dht(DHTPIN, DHTTYPE);

double curr_hum; // current hum double curr_temp; // current temp void checkHum() { curr_hum = dht.getHumidity(); }

void checkTemp() { curr_temp = dht.getTempFarenheit(); } void setup() { pinMode(DHTPIN, INPUT); checkTemp(); char[] msg = "Hello!" + String(curr_temp); // msg = "Hello!" + char(curr_temp); delay(1000); client.connect(LIB_DOMAIN, 80); client.println("POST /update HTTP/1.0"); client.println("Host: " LIB_DOMAIN); client.print("Content-Length: "); client.println(strlen(msg)+strlen(TOKEN)+14); client.println(); client.print("token="); client.print(TOKEN); client.print("&status="); client.println(msg); } /*void tweetOut(String message){ // char[] msg = message.toCharArray(); delay(1000);

client.connect(LIB_DOMAIN, 80); client.println("POST /update HTTP/1.0"); client.println("Host: " LIB_DOMAIN); client.print("Content-Length: "); client.println(strlen(msg)+strlen(TOKEN)+14); client.println(); client.print("token="); client.print(TOKEN); client.print("&status="); client.println(msg); } */ void loop() { /* checkHum(); // check humidity. Sets the local variables curr_hum and curr_hum str checkTemp(); char[] msg = "Good afternoon! The current temperature is: "+Char(curr_temp)+". The current humidity is: "+ Char(curr_hum)+"."); delay(1000); client.connect(LIB_DOMAIN, 80); client.println("POST /update HTTP/1.0"); client.println("Host: " LIB_DOMAIN); client.print("Content-Length: "); client.println(strlen(msg)+strlen(TOKEN)+14); client.println(); client.print("token="); client.print(TOKEN); client.print("&status="); client.println(msg); delay(60000); */ }

Step 4: Step 4: Build an Enclosure and Get Tweeting!

Build an enclosure, plug into a wall where you want the tempature and humidity and push the code from build.particle.io!