loading

These 7 steps will drive you through the "construction" of a thermo-hygrometer with clock on Arduino UNO.

Data and time, humidity and temperature will be shown on a LCD 16x2 display .If you have purchased a LCD display and want to know how to properly solder a pin header to it, take a look at our tutorial "Yet another tutorial on how to solder".

Each step of this tutorial is independent from the others. So, if you are looking for an easy way to make your DS3231 work (for example) this tutorial is also suitable for you.

What you need to follow all steps of this tutorial is:

    • Arduino UNO
    • A USB cable
    • The Arduino IDE installed on your computer
    • A MB-102 breadboard
    • Set of Dupont cables
    • DHT22(humidity and temperature sensor)
    • DS-3231 (A cheap but accurate real time clock)
    • LCD 16x2 display
    • A 10k Ohm linear potentiometer
    • A 2N3904 transistor (or a 2N2222)
    • Number 3 10k Ohm resistors (1/4 Watt)
    • A pushbutton
    • Preferably, a better text editor than Arduino IDE

    Another very useful thing (but not strictly required) is a small wooden board where fixing Arduinio and breadboard. Get some short self tapping screws if you decide to follow this advice.

    Even if this tutorial seems to be not easy, it can be done by newbies as well if followed step-by-step,

    YOUR COMMENTS AND SUGGESTIONS ARE WELCOME!

    Step 1: Make Your DHT22 Work

    Downloading and installing the DHT22 library

    The first step is downloading and installing the library needed by DHT22 sensors.

    Download the zip file attached in this step. Into this folder there are two files which have to stay into the sub-folder \DHT. If you are on Windows, install the library by putting the \DHT folder into the directory:

    C:\Program Files (x86)\Arduino\libraries

    So, the two files dht.cpp and dht.h have to be contained in a folder named DHT and no other sub-folders have to be made. Click here for more info about adding new libraries.

    DHT22 connections

    Before uploading the code to your Arduino, you need to connect the DHT22 sensor properly.

    Vcc ---> 10k Ohm resistor ---> 5V

    DATA ---> 10k Ohm resistor ---> Pin 9

    NC (not connected)

    GND ---> GND

    Anyway, see the Fritzing scheme attached above for a better understanding.

    ALWAYS CHECK TWICE YOUR CONNECTIONS BEFORE TURNING ON ARDUINO!

    TIP: If you want to recognize quickly the function of a wire, use a standard for colours. Red and black should be respectively associated to Vcc and GND. We use a white Dupont cable for the DATA pin of the DHT22.

    Put the components exactly as we do, later there won't be too much space on your breadboard!

    Uploading the code

    Now, download the file dht22.ino and then double click on it. Arduino IDE will ask you to save the new sketch into a folder whose name will be the same used for the .ino file. Save the file where you prefer.

    Take a look at our code. What's the difference between the code on Arduino's official website (available here) and ours? First of all, we deleted all the lines which are not needed: 15 and 16...

    	#define DHT11_PIN 4
    	#define DHT21_PIN 5
    

    ...and the lines from 55 to 105:

    	// READ DATA
      Serial.print("DHT21, \t");
      chk = DHT.read21(DHT21_PIN);
      switch (chk)
      {
        case DHTLIB_OK:  
    		Serial.print("OK,\t"); 
    		break;
        case DHTLIB_ERROR_CHECKSUM: 
    		Serial.print("Checksum error,\t"); 
    		break;
        case DHTLIB_ERROR_TIMEOUT: 
    		Serial.print("Time out error,\t"); 
    		break;
        default: 
    		Serial.print("Unknown error,\t"); 
    		break;
      }
      // DISPLAY DATA
      Serial.print(DHT.humidity, 1);
      Serial.print(",\t");
      Serial.println(DHT.temperature, 1);
    
      delay(1000);
    
      // READ DATA
      Serial.print("DHT11, \t");
      chk = DHT.read11(DHT11_PIN);
      switch (chk)
      {
        case DHTLIB_OK:  
    		Serial.print("OK,\t"); 
    		break;
        case DHTLIB_ERROR_CHECKSUM: 
    		Serial.print("Checksum error,\t"); 
    		break;
        case DHTLIB_ERROR_TIMEOUT: 
    		Serial.print("Time out error,\t"); 
    		break;
        default: 
    		Serial.print("Unknown error,\t"); 
    		break;
      }
     // DISPLAY DATA
      Serial.print(DHT.humidity,1);
      Serial.print(",\t");
      Serial.println(DHT.temperature,1);
    
      delay(1000)
    

    In fact, they are only needed if you have a different sensor from the DHT22.

    The second difference consists of the changing of the DATA pin used. We set the 9 instead of the 6, chosen by default (because the 6 pin is used by the LCD display).

    Upload the code to your Arduino and then open the system monitor (magnifying glass on the Arduino IDE toolbar). The system monitor should print these lines as an output (see also the screenshot above):

    DHT TEST PROGRAM
    LIBRARY VERSION: 0.1.14
    
    Type, status, Humidity (%), Temperature (C) 
    DHT22, OK, 52.4, 25.9
    

    Congratulations, your DHT22 is working!

    If you don't get this output, check your connections and repeat the whole procedure again.

    Step 2: Setting Date and Time on DS3231

    The best way to keep date and time is using an external device. In this case, we'll use an DS3231 with rechargeable 3.6V battery (model lir2032). In this way, we'll be able to keep date and time even if our Arduino is powered off.

    Downloading and installing the DS3231 library

    In order to install the library needed, do the same procedure as described in the previous step.

    DS3231 connections

    The DS3231 has six pins. Connect them as shown below:

    SCL ---> A5

    SDA ---> A4

    Vcc ---> 5V

    GND ---> GND

    Ignore 32K and SQW, they are not going to be plugged in this case.

    No resistor is needed.

    NOTE:We have always supplied 5V to the ds3231 without any problem. In effect, as we read in its datasheet it can work within a range of 2.3 to 5.5V and 3.3V is the voltage suggested. So you can get 3.3V from the Arduino.

    You can find the DS3231 datasheet here: DS3231 datasheet

    Setting date and time
    Now, download the file ds3231.ino and then double click on it. Arduino IDE will ask you to save the new sketch into a folder whose name will be the same used for the .ino file. Save the file where you prefer.

    Go to the line 19 and uncomment it by deleting the two slashes at the beginning of the function.

    	//setDS3231time(30,12,21,6,1,05,15);
    

    Replace the numbers into the brackets with "seconds, minutes, hours, day, date, month, year" respectively. Remember:

    1. The day 1 corresponds to Sunday and 7 to Saturday
    2. The 24-hour clock is the convention used by DS3231

    Upload the code. Now, open the system monitor, you should see something like this output (see also the screenshot):

    17:53:16 13/5/15 Day of week: Wednesday
    
    

    Well done, date and time have been set!

    If you don't get this output, check your connections and repeat the whole procedure again.

    Once you set date and time, comment the 19th line again or your values are going to be overwrite every time you upload it.

    Step 3: Cleaning the DS3231 Code

    Before combining the DS3231 real time clock and DHT22, it's better to delete all the lines we don't need into the ds3231.ino file previously used.

    As usual we attached the code ready for use but anyway it's better to understand how it works.

    Deleting what we don't need

    Open the DS3231 code and delete the lines from 3 to 7:

    	// Convert normal decimal numbers to binary coded decimal
    byte decToBcd(byte val)
    {
      return( (val/10*16) + (val%10) );
    }
    

    They are not needed any more because converting numbers from decimal to binary is only useful when you are setting date and time.

    For the same reason as above, delete the lines from 17 to 19 located into the void setup function....

    // set the initial time here:
    // DS3231 seconds, minutes, hours, day, date, month, year
    //setDS3231time(30,12,21,6,1,05,15);
    

    ..and the lines from 21 to 35:

    	void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte
    dayOfMonth, byte month, byte year)
    {
      // sets time and date data to DS3231
      Wire.beginTransmission(DS3231_I2C_ADDRESS);
      Wire.write(0); // set next input to start at the seconds register
      Wire.write(decToBcd(second)); // set seconds
      Wire.write(decToBcd(minute)); // set minutes
      Wire.write(decToBcd(hour)); // set hours
      Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
      Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
      Wire.write(decToBcd(month)); // set month
      Wire.write(decToBcd(year)); // set year (0 to 99)
      Wire.endTransmission();
    }
    

    The file ds3231_bis.ino contains the lightened code.

    Step 4: Combining DS3231 and DHT22

    Okay, it's time to combine the two devices previously seen!

    This procedure consists of making a "patchwork" between the two codes previously seen.

    Open both codes and copy&past the code of DHT22 in the one of DS3231 (ds3231_bis.ino).

    Libraries, variables and constants

    In the ds3231_bis.ino code add the library needed by the dht22, define what pin it's going to use and set the variable used to read and write the values of temperature and humidity detected. Here is how the beginning of code should look like:

    #include "Wire.h"
    #include <dht.h>
    
    #define DHT22_PIN 9
    #define DS3231_I2C_ADDRESS 0x68
    
    dht DHT;
    

    Functions

    Just after the two main functions (void loop and void setup), we are going to put the "secondary" ones:

    • bcdToDec --- as said before, it's required to convert binary numbers to decimals
    • readDS3231time --- required to read data from DS3231
    • displayTime --- required to print data and time on the serial monitor

    In order not to mess up anything, we made another function named dht22. It contains all the lines into the setup function of our dht22.ino. Thanks to this, our loop and setup are going to be clean and tidy.

    // Convert binary coded decimal to normal decimal numbers
    byte bcdToDec(byte val)
    {
      return( (val/16*10) + (val%16) );
    }
    void readDS3231time(byte *second,
    byte *minute,
    byte *hour,
    byte *dayOfWeek,
    byte *dayOfMonth,
    byte *month,
    byte *year)
    {
      Wire.beginTransmission(DS3231_I2C_ADDRESS);
      Wire.write(0); // set DS3231 register pointer to 00h
      Wire.endTransmission();
      Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
      // request seven bytes of data from DS3231 starting from register 00h
      *second = bcdToDec(Wire.read() & 0x7f);
      *minute = bcdToDec(Wire.read());
      *hour = bcdToDec(Wire.read() & 0x3f);
      *dayOfWeek = bcdToDec(Wire.read());
      *dayOfMonth = bcdToDec(Wire.read());
      *month = bcdToDec(Wire.read());
      *year = bcdToDec(Wire.read());
    }
      // READ DATA
    void dht22 ()
    {
      // READ DATA
      Serial.print("DHT22, \t");
      int chk = DHT.read22(DHT22_PIN);
      switch (chk)
      {
        case DHTLIB_OK:
    		Serial.print("OK,\t");
    		break;
        case DHTLIB_ERROR_CHECKSUM:
    		Serial.print("Checksum error,\t");
    		break;
        case DHTLIB_ERROR_TIMEOUT:
    		Serial.print("Time out error,\t");
    		break;
        default:
    		Serial.print("Unknown error,\t");
    		break;
      }
      Serial.print(DHT.humidity, 1);
      Serial.print(",\t");
      Serial.println(DHT.temperature, 1);
    }
    
    void displayTime()
    {
      byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
      // retrieve data from DS3231
      readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
      &year);
      // send it to the serial monitor
      Serial.print(hour, DEC);
      // convert the byte variable to a decimal number when displayed
      Serial.print(":");
      if (minute<10)
      {
        Serial.print("0");
      }
      Serial.print(minute, DEC);
      Serial.print(":");
      if (second<10)
      {
        Serial.print("0");
      }
      Serial.print(second, DEC);
      Serial.print(" ");
      Serial.print(dayOfMonth, DEC);
      Serial.print("/");
      Serial.print(month, DEC);
      Serial.print("/");
      Serial.print(year, DEC);
      Serial.print(" Day of week: ");
      switch(dayOfWeek){
      case 1:
        Serial.println("Sunday");
        break;
      case 2:
        Serial.println("Monday");
        break;
      case 3:
        Serial.println("Tuesday");
        break;
      case 4:
        Serial.println("Wednesday");
        break;
      case 5:
        Serial.println("Thursday");
        break;
      case 6:
        Serial.println("Friday");
        break;
      case 7:
        Serial.println("Saturday");
        break;
      }
    }
    
    

    Setup function

    The most important functions are Wire.begin() and Serial.begin(). They initialize the DS3231 and the serial monitor, respectively. The other lines print not strictly required information about DHT22.

    void setup()
    {
      Wire.begin();
      Serial.begin(115200);
      Serial.println("DHT TEST PROGRAM ");
      Serial.print("LIBRARY VERSION: ");
      Serial.println(DHT_LIB_VERSION);
      Serial.println();
      Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
    }
    

    Loop function

    The loop function is pretty simple: it only calls two functions delaying the operation of 2 seconds. Why two seconds? Because DHT22s needs two seconds to do a detection.

    #include "Wire.h"
    void loop()
    {
      displayTime(); // display the real-time clock data on the Serial Monitor,
      dht22 (); // display the value of humidity and temperature detected
    
      delay(2000);
    }
    

    As usual we attached the code ready for use.

    Step 5: Connecting the LCD Display

    Now it's time to connect the LCD display to our Arduino. As seen in the Introduction, you'll also need some other things: a breadboard, some Dupont cables, a 10 KOhm linear potentiometer (for adjusting the contrast) and a header - 16 pins long (if you want to know how to properly solder this header to it, take a look at our tutorial "Yet another tutorial on how to solder").

    First connect your LCD display to the breadboard, as shown in the picture. Then connect +5V to the red rail, and GND to the blue rail. Connect the upper rail to the lower one as shown in the picture. Remember to use red wires for +5V and black wires for GND.

    Now we'll connect the backlight for the LCD and the potentiometer for contrast setting. Put the potentiometer as shown on picture, connect the central pin to the V0 pin of the display and the other pins to GND. Connect pin 16 of the display to ground and pin 15 to +5V. Connect the Arduino up to power, you'll notice the backlight lights up. Now turn Arduino off and connect the other wires.

    You can follow either the picture or the scheme below:

    LCD			Power supply
    
    VSS (pin1)		GND
    VDD (pin2)		+5V
    RW  (pin5)		GND
    
    LCD			ARDUINO
    
    RS  (pin4)		pin2
    E   (pin6)		pin3
    D4  (pin11)		pin4
    D5  (pin12)		pin5
    D6  (pin13)		pin6
    D7  (pin14)		pin7
    
    LCD                     power supply for backlight
    
    A (pin 15)              +5V
    K (pin 16)              GND
    

    It's time to upload the sketch HelloWorld.ino and test the circuit. If there is no error you should see a message on display's screen.

    Note: this sketch comes with the Arduino IDE but we changed the row "LiquidCrystal lcd(12, 11, 5, 4, 3, 2);" into "LiquidCrystal lcd(2, 3, 4, 5, 6, 7);" to adapt it to our wiring.

    Step 6: Controlling the LCD Display Backlight

    Since the LCD display brightness consumption is very high, you may need to control it, especially if you are planning to supply your thermo-hygrometer with a battery.

    In order to light on the display, you only need to press a button. The display will turn on for 8 seconds (more or less).

    We achieved this result by controlling the backlight LEDs with a PWM signal generated by Arduino.

    Since PWM outputs don't supply enough electricity to control the backlight, we can't connect it directly. We can simply solve this problem using a 2N3904 transistor and 10k Ohm resistor connected as shown on the Fritzing scheme attached above.

    The necessary current will flow from collector to emitter instead of flowing through the PWM output.

    The sketch

    First, let's define the pins required:

    • the pin 11 as an output of PWM signal
    • the pin 10 as an input to detect the button status
    #define LUMIN 11
    #define BUTTON 10
    

    then, declare these two variables...

    int  val = 0; 
    int counter = 0;
    

    ...which are needed to set the button status and the lighting time of the LCD respectively.

    Into the setup function we have to define the pin used as an input and the other one, a PWM output signal.

    pinMode(BUTTON, INPUT);
    pinMode(LUMIN, OUTPUT);
    

    Into the loop function we have the brightness control

          val = digitalRead(BUTTON);
         
           if (val == HIGH) { 	
    	 counter = 1000;	 
    	 analogWrite(LUMIN, 255);  // turns on the led  
           }  
    
           if (val == LOW) {
    	 if (counter > 0) {
    	  counter--;
    	 }
          }
    
          if (counter <= 0) {
    	 analogWrite(LUMIN, 0);  // turns off the led
         }
    

    Controlling the LCD display brightness is pretty easy.

    At the beginning, the counter is set to 0, which means that the backlight display is turned off.
    But when you press the button, the first “if” condition becomes true and the counter value is set to 1000 and the output to the highest level (255).

    The backlight display will stay turned on as long as you keep the button pressed down.

    When you stop pressing the button, the second "if" condition* becomes true (and the first one becomes false) and the counter begins to decrease itself. Each loop decreases the counter of an unit.

    The last "if" condition turns the backlight off when the counter value is 0.

    *Note that the second "if" has two conditions:

    1. the pin has to be set on LOW (unpressed button)
    2. the counter value has to be higher than 0.

    Step 7: Thermoigrometer

    This procedure also consists of making a "patchwork" between two codes.
    Open both codes and copy&past the code of LCD_display_control.ino in the one of dht22andDS3231.ino.

    In this step we are going to make a sketch which shows values detected by DHT22 and time&date on the LCD display. Of course, we have to replace all Serial.print() with lcd.print() functions. This operation is very simple if you use a text editor which has the automatic find and replace function (Notepad++, for example). So, look for Serial and replace all of them with lcd.

    The header of the sketch

    Now, add the library required by the LCD display and declare the two variables and constants used to light it off and on.

    Just after this part you have to declare two arrays made of bytes. These two arrays, drop and temp, draw the icons displayed on the LCD. If you'd like to draw your own icons, you can use the following web editor: LCD font editor.

    Then, in order to initialize the LCD we have to use the function LiquidCrystal(). Inside the brackets there are the pins used.

    Functions

    Scrolling down the sketch we find several functions:

    • bcdToDec --- as said before, it's required to convert binary numbers to decimals
    • readDS3231time --- required to read data from DS3231
    • displayTime --- required to print data and time on the LCD display
    • dht22 --- required to detect and print values of temperature and humidity

    For a better visualization, we have done some changes in displayTime and dht22. Basically we need to show on the first row date and time and in the second one temperature and humidity. An LCD display only has 16 digits per row so if you want it to show everything you must organize the output.

    First of all, we shortened the names of the days of the week, as you can see into the first switch/case instruction. Then we added another switch/case for the shortened names of the months. We also deleted the current year and seconds.

    For the same reason, we did some changes in the dht22 function. This sketch won't print any info about the dht22 library as well as the line "Type, status, Humidity (%), Temperature (C)" but it only prints the two icons (drop and temp) and temperature value followed by "°C" (because we used Celsius degrees) and humidity followed by "%". Since there is not enough space we also decided to delete the second decimal digit from temperature and humidity.

    Setup function

    The first two lines in the setup function initialize the pin BUTTON and LUMIN. They are used to control the LCD display backlight.

    The third line initializes the DS3231.

    The forth and fifth lines create the two custom icons.

    The last one initializes the LCD display.

    Loop function

    Into the loop function we find the instructions required to control the LCD backlight. We are not going to repeat how they work because we did it in the previous step.

    The last two instructions recall those functions which display date&time and humidity&temperature.

    The only difference consists of changing the value of the counter from 1000 (as we saw previously) to 5 because now we inserted a two seconds delay.

    <p>Great Explanation, great tutorial.</p><p>Its much easier to use the board <a href="http://www.arduIoT.com/U1." rel="nofollow"> www.arduIoT.com/U1.</a></p><p>you olny have to connect the DHT22 and you are done. </p>
    <p>Great tutorial.</p><p>Thanks.</p><p>Keep up the good work.</p>
    <p>Hi Misticspell, Congratulations for your work.</p><p>Thanks a lot for your comment :)</p>
    <p>Thanks. I didn't made the entire project, just the parts i was interested on.</p><p>Here's a picture of all i made.</p>
    <p>hello, can you send me this your project code?</p>
    <p>Hi, here is the code I used.</p><p>Hope it helps you.</p><p>//Carrega librarias<br>#include &lt;dht.h&gt;<br>dht DHT;<br>#include &lt;Wire.h&gt;<br>#include &lt;LCD.h&gt;<br>#include &lt;LiquidCrystal_I2C.h&gt;</p><p>//Define variaveis </p><p>#define I2C_ADDR 0x27 //Define endere&ccedil;o I2C onde o PCF8574A est&aacute;<br>#define BACKLIGHT_PIN 3<br>#define En_pin 2<br>#define Rw_pin 1<br>#define Rs_pin 0<br>#define D4_pin 4<br>#define D5_pin 5<br>#define D6_pin 6<br>#define D7_pin 7<br>#define DHT22_PIN 9</p><p>//Inicializa o LCD<br>LiquidCrystal_I2C lcd(I2C_ADDR, En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);</p><p>void setup()<br> {<br> //Define o LCD como 20 colunas por 4 linhas<br> lcd.begin (20,4);<br> <br> //Liga ilumina&ccedil;&atilde;o do LCD<br> lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);<br> lcd.setBacklight(HIGH);<br> <br> <br> <br> }<br> <br> <br>void loop(){<br> <br> <br> // READ DATA<br> Serial.print(&quot;DHT22, \t&quot;);<br> int chk = DHT.read22(DHT22_PIN);<br> switch (chk)<br> {<br> case DHTLIB_OK: <br> //Serial.print(&quot;OK,\t&quot;); <br> break;<br> case DHTLIB_ERROR_CHECKSUM: <br> //Serial.print(&quot;Checksum error,\t&quot;); <br> break;<br> case DHTLIB_ERROR_TIMEOUT: <br> //Serial.print(&quot;Time out error,\t&quot;); <br> break;<br> default: <br> //Serial.print(&quot;Unknown error,\t&quot;); <br> break;<br> }<br> //ir para primeira coluna (coluna 0) e primeira linha (Linha 0)<br> lcd.setCursor(0,0);<br> lcd.print(&quot;Humidade (%)&quot;);<br> <br> lcd.setCursor(0,1);<br> lcd.print(DHT.humidity, 1);</p><div> lcd.setCursor(0,2);<br> lcd.print(&quot;Temperatura (C)&quot;);<br> <br> lcd.setCursor(0,3);<br> lcd.print(DHT.temperature, 1);<br> <br> delay(1000);<br> }</div>
    <p>Great job!</p>
    <p>Hi, great Tutorial, been looking for something just like this.</p><p>ive made it all up but have some problems, with the code, i used yours, i have an error compiling with the line </p><p>dht DHT;</p><p>and further down in the void dht22() its not compiling</p><p>lcd.print(DHT.temperature, 1);</p><p>and</p><p>lcd.print(DHT.humidity, 1);</p><p>any help here would be greatly appriciated</p>
    <p>Hi TaylorL27, seems the compiler does not see the DHT library.</p><p>Did you installed it?</p>
    <p>i hav installed a DHT library yes. i am using the DHT 11 but i think i have made all the riht chnges, i dont know if ive missed a line of code or something.</p>
    <p>can you attach the error log here?</p>
    <p>Arduino: 1.6.5 (Windows 8.1), Board: &quot;Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)&quot;</p><p>thermohygrometer:18: error: 'dht' does not name a type</p><p>thermohygrometer.ino: In function 'void dht11()':</p><p>thermohygrometer:177: error: request for member 'temperature' in '11', which is of non-class type 'int'</p><p>thermohygrometer.ino: In function 'void loop()':</p><p>thermohygrometer:218: error: 'dht22' was not declared in this scope</p><p>'dht' does not name a type</p><p> This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences.</p>
    <p>thermohygrometer:18: error: 'dht' does not name a type says that the compiler can not see the library</p><p>there is anothe error: thermohygrometer:218: error: 'dht22' was not declared in this scope . If you are using a DHT11 you must put dht11, not dht22</p>
    <p>ok, the compiler has moved on to he problems in the void dht()</p><p>Arduino: 1.6.5 (Windows 8.1), Board: &quot;Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)&quot;</p><p>In file included from thermohygrometer.ino:1:0:</p><p>C:\Users\System-1\Documents\Arduino\libraries\DHT-sensor-library-master/DHT.h:32:15: error: expected unqualified-id before numeric constant</p><p> #define DHT11 11</p><p> ^</p><p>thermohygrometer.ino:20:5: note: in expansion of macro 'DHT11'</p><p>thermohygrometer.ino: In function 'void dht11()':</p><p>thermohygrometer:179: error: request for member 'temperature' in '11', which is of non-class type 'int'</p><p>thermohygrometer:184: error: request for member 'humidity' in '11', which is of non-class type 'int'</p><p>thermohygrometer.ino: In function 'void loop()':</p><p>thermohygrometer:220: error: 'dht22' was not declared in this scope</p><p>request for member 'temperature' in '11', which is of non-class type 'int'</p><p> This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences.</p>
    <p>Maybe there is some syntax error in your code</p>
    <p>Great tutorial! I managed to fit it all on the breadboard I got with the Arduino starter kit (sorry for the grainy picture, it's pretty late). Only I don't think the part where you explain how to connect the DHT22 is correct:</p><p>&quot;Vcc ---&gt; 10k Ohm resistor ---&gt; 5V</p><p>DATA ---&gt; 10k Ohm resistor ---&gt; Pin 9</p><p>NC (not connected)</p><p>GND ---&gt; GND&quot;</p><p>This didn't work for me. The Fritzing picture did though, just thought I'd let you know!</p>
    <p>Hi MrDam404, thanks a lot for your comment. We connected the pin1 of the DHT22 to Vcc, the pin2 to the Arduino DATA input and the pin4 to GND. Between pin1 and pin2 we put a 10KOhm resistor. </p><p>Congratulations for your work.</p>
    <p>Awesome instructable,by installing a battery,you can actually take it along and go out^_^</p>
    <p>The DS3231 runs fine on 3.3 Volt from the Arduino. It is 4am in the morning and I have finally found this Instructable. Just what I was looking for. Good work.</p>
    <p>Hi arduinomaster, thanks a lot for your comment. We have always supplied 5V to the ds3231 without any problem. Actually, as we read in its datasheet it can work within a range of 2.3 to 5.5V and 3.3V is the voltage suggested. We are going to write an annotation about.</p>
    <p>Nice job, thanks for sharing! </p>
    <p>thank you! ;)</p>
    <p>Excellent tutorial, thank you!</p>
    <p>thank you! ;)</p>

    About This Instructable

    18,886views

    164favorites

    License:

    More by techrm:A Simple Hydroponic System With MediaTek LinkIt™ ONE Getting started with BTE13-010 - Arduino Mini clone Simple calculator based on Arduino MEGA 
    Add instructable to: