#include #include #include #include #include dht11 DHT11; // MAC address for your Ethernet shield byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // Your Xively key to let you upload data char xivelyKey[] = "4rqhlqO3la7pTi3340dv0ZFQGcgOt4w0IOjiAU9mQHdpQsEF"; // Analog pin which we're monitoring (0 and 1 are used by the Ethernet shield) #define DHT11PIN 2 //DHT11's data pin is attached to PWM pin 2 // Define the strings for our datastream IDs char sensorId[] = "sensor_reading"; XivelyDatastream datastreams[] = { XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT), }; // Finally, wrap the datastreams into a feed XivelyFeed feed(966061885, datastreams, 1 /* number of datastreams */); EthernetClient client; XivelyClient xivelyclient(client); void setup() { // put your setup code here, to run once: Serial.begin(9600); Serial.println("Starting single datastream upload to Xively..."); Serial.println(); while (Ethernet.begin(mac) != 1) { Serial.println("Error getting IP address via DHCP, trying again..."); delay(15000); } } void loop() { float chk = DHT11.read(DHT11PIN); // int sensorValue = analogRead(sensorPin); datastreams[0].setFloat((float)DHT11.temperature); Serial.print("Read sensor value "); Serial.println(datastreams[0].getFloat()); Serial.println("Uploading it to Xively"); int ret = xivelyclient.put(feed, xivelyKey); Serial.print("xivelyclient.put returned "); Serial.println(ret); Serial.println(); delay(1000); }