Introduction: How to Share Data of Temperatura From DHT22 Over the Internet With Xively

Picture of How to Share Data of Temperatura From DHT22 Over the Internet With Xively

The web has definitely changed many things, such as the availability of data on request, quickly and easily. For example, to know the temperature that's out there, is readily available through various websites devoted, which also provide forecasts in the short and long term. For those who want to make a solution if, in style "Internet of things", as you can do it in the easiest way possible? The answer is Arduino + DHT22 + Xively!

Arduino, a microcontroller is really great because it is simple to use and, through the various transducers exist, you can create projects that truly complete.
The DHT22 is a temperature transducer, able to read the temperature and the humidity present and "communicate" to Arduino, so electric.
Xively is web service, with which you can share physical and electrical network, taking advantage of the Internet connection at home.

Requirements of the project

Hardware Components

1 x Arduino Uno
1 x DHT22
1 x 4.7 Kohm resistor
1 x Ethernet Shield
4 x Flexible cables

Software Components

DHT22 Library https://github.com/adafruit/DHT-sensor-library
Library Xively https://github.com/xively/xively_arduino
Code for Arduino


Step 1: Registration Xively

Picture of Registration Xively

In order to share the temperature on the web, you need to register a free website Xively, from this web page https://xively.com/signup/. On this page, we should insert some standard configurations, such as name, etc ...

Now that we have completed the registration, we can finally access the page control with which we manage our information coming from the Arduino. The web page is located at the following link https://xively.com/login/.

Now we can add our device, which in this is Arduino, through which the temperature sensor DHT22, is able to read the physical magnitudes, Temp and Hum. To do this we click on "Add device" in the control page https://xively.com/develop/new.

After we have completed the form above, it will open the web page from which we could see the information about the weather conditions anywhere, using an Internet connection. From this page, we should copy some data that will be included in the Arduino code:

FEED ID
API KEY

Step 2: How to Connect the Wires

Picture of How to Connect the Wires

The connection of the device to the Arduino DHT22 is quite simple:

(1) VCC -> 5V
(2) DATa -> PIN 3
(3) NULL
(4) GND -> GND

Be careful

Date between VCC and there is a resistance from 4.7 Kohm pull-up, in order to read a voltage values​​, variable according to the temperature, which is read by Arduino! Without this, you can not read the value!

Step 3: The Arduino's Code

Picture of The Arduino's Code

/**
This code let Arduino to send the values of temperature and humidity to Xively, via Ethernet Shield.
The temperature is getting from DHT22 sensor
Author Giacomo Bellazzi
*/

#include

#include
#include
#include
#include
#include "DHT.h"

#define DHTPIN 3     // PIN data of DHT22

//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);
// MAC address for your Ethernet shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// Your Xively key to let you upload data
char xivelyKey[] = "";

// Define the strings for our datastream IDs
char sensorId1[] = "Temperature";
char sensorId2[] = "Humidity";
XivelyDatastream datastreams[] = {
  XivelyDatastream(sensorId1, strlen(sensorId1), DATASTREAM_FLOAT),
  XivelyDatastream(sensorId2, strlen(sensorId2), DATASTREAM_FLOAT),
};
// Finally, wrap the datastreams into a feed. Set the Feed value insted of 12345678
XivelyFeed feed(12345678, datastreams, 2 /* number of datastreams */);

EthernetClient client;
XivelyClient xivelyclient(client);

void setup() {
  Serial.begin(9600);
  Serial.println("Starting single datastream upload to Xively...");
  Serial.println();
  dht.begin();
  while (Ethernet.begin(mac) != 1)
  {
    Serial.println("Error getting IP address via DHCP, trying again...");
    delay(15000);
  }
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  float h = dht.readHumidity(); // Value of Temp
  float t = dht.readTemperature(); // Value of Humidity
  datastreams[0].setFloat(t); // Value of Temp
  datastreams[1].setFloat(h); // Value of Humidity
  Serial.print("Read sensor value ");
  Serial.println(datastreams[0].getFloat());
  Serial.println("Uploading it to Xively");
  // Send data to Xively
  int ret = xivelyclient.put(feed, xivelyKey);
  Serial.print("xivelyclient.put returned ");
  Serial.println(ret);
  delay(15000);
}



To be able to make it work, you must enter the data FEED ID and API at their place, within the code.

Now that we have everything set up, we can finally compile and see the final result!



Comments

MoniCris made it! (author)2015-08-23

At 7:00 I've start the air conditioning on DRY.
Please see my instructables on how to switch on the AC from web

MoniCris (author)2015-08-23

I have made this some time ago. Is great project.

Gran Abuelo (author)2015-01-03

Any chance you'd be willing to help me out with using the ethercard lib, as I have a ENC28J60 ethernet module?

jackbell16 (author)Gran Abuelo2015-01-07

Hi,

the correct library to use with this card is this one: https://github.com/jcw/ethercard

In that web page you can get the information of how connect Arduino to this card. I hope you will be able to start working with this module.

psycho.maggot (author)2014-11-11

would like to share the videos of this instructions?. thanks

fiolin (author)2014-02-26

Works for me thank you to share it!!

About This Instructable

11,127views

54favorites

License:

Bio: I'm an Arduino Maker, I like technology, playing tennis
More by jackbell16:How to let comunicate Arduino with KeyPad to DB MySQL.Arduino water system to wet your plantHow to make an alarm system with Arduino
Add instructable to: