1

member

Medium Basics Project 006c DHT 11 21 22 module, LCD1602 I2C module, DS1302 RTC module

of Acoptex.com in UNO

Basics: Project 006a

Project name: DHT11 Humidity and temperature module, LCD1602 I2C module, DS1302 RTC module - weather station

Tags: Arduino, Arduino Uno, DHT11 21 22, Humidity and temperature module, LCD1602 I2C module, DS1302 RTC module, weather station, LCD1602, DS1302

Attachments: libraries1, library2, library3 and sketch

In this project, you needed these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2.DHT11 or DHT21 or DHT22

3.Arduino IDE ( you can download it from here  )

4.Jumper cables

5. Resistor 1 pc 10 K Om (if 4 pin sensor used - see picture of Arduino and sensor 4 pin connections)

6.LCD 1602  I2C module

7. Breadboard

8. DS1302 RTC module with CR2030 Lithium battery 3V

Understanding DHT humidity and temperature sensor

We will use DHT11 module for this project. See more info about DHT here. Datasheet can be found here.

Understanding LCD 1602 I2C module

More information you can find here.

Understanding DS1302 RTC module

The DS1302 trickle-charge timekeeping chip contains a real-time clock/calendar and 31 bytes of static RAM.  It communicates with a microprocessor via a simple serial interface.  The real-time clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an AM/PM indicator.

Only three wires are required to communicate with the clock/RAM: CE, I/O (data line), and SCLK (serial clock). Data can be transferred to and from the clock/RAM 1 byte at a time or in a burst of up to 31 bytes. The DS1302 is designed to operate on very low power and retain data and clock information on less than 1μW.  The DS1302 has dual power pins, one for primary and another for backup.  in this example the Priamry power will be provided by the Arduino, and the back up by a CR2032 battery.

The 31 bytes of RAM is formatted as shown in the table below.  Notice that the numeric positions have their own bits to fill.  Specifically the 0-9 value of the 'ones' place have 4 bits, and the 0-9 value of the 'tens' place has 3 bits for the byte filled with the seconds value.  These values are combined to create the entire byte.

You can find DS1302 datasheet here.

Signals and contacts of LCD 1602 I2C module

As you can see on the back of LCD 1602 module there 4 connections: GND (-), VCC (+5V), Serial Data Line (SDA) and Serial Clock Line (SCL).

Signals and connections of DHT11 module

There are 3 : VCC (+5V), Data, GND (-)

Signals and connections of DS1302 RTC module


Wiring

The following picture shows the needed connections with the Arduino Uno - 3 pin DHT11 sensor module.

The following picture shows the needed connections with the Arduino Uno - 4 pin DHT11 sensor (resistor 10 K Om required).

Step by Step instruction

  1. Plug your Adruino Uno board into your PC and select the correct board and com port
  2. Open up serial monitor and set your baud to 9600 baud
  3. Modify sketch(program) for your sensor (DHT11 or DHT21 or DHT 22)
  4. Find your I2C address. Each device has an I2C address that it uses to  accept commands or send messages. Load the sketch over at http://playground.arduino.cc/Main/I2cScanner and follow the instructions to use it.  By opening up the Serial monitor window after you upload the sketch, Arduino will scan the address range looking for a reply.  Even though the documentation said it was 0x27, this scanner can detect different (in my case 0x3F
  5. Modify the sketch in attachments above (you can use the sketch below too): the line LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) (See part marked bold)
  6. Verify and upload the the sketch to your Adruino Uno.
  7. If it will be problem with compilation - remove 2 files from the library - DHT_U.cpp and DHT_U.h

 

Libraries:

  • See attachments on the begining of this project description - all libraries included.
  • DS1302 library.Download, unzip  and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. 
  • Adafruit_Sensor library included.Download, unzip  and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. 
  • DHT-sensor library included. You will need to unzip and add the DHT-sensor-library-master library to libraries in your PC, for example C:\Users\toshiba\Documents\Arduino\libraries OR
  • You can install it in Arduino IDE too: select Sketch-> Include library->Manage your libraries->type DHT in Filter your search line and you will see DHT sensor library by Adafruit->More info->select version->install
  • If it will be problem with compilation - remove 2 files from the library - DHT_U.cpp and DHT_U.h.
  • I have used the library - NewliquidCrystal_1.3.4.zip which I downloaded, unzipped, changed the name of folder to LiquidCristal and added to libraries in my PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
  • If you have LiquidCristal folder in this location already - delete this folder and copy folder, which was made by you, to this location.
  • Wire library included in Arduino IDE which is installed in your PC.

Sketch:

 

  • See attachments on the begining of this project description

 

Notes/Remarks

It was noticed that if USB cable disconnected all setting will go back to inital which you have entered here : void setup() { 

rtc.setDOW(SUN);        // Set Day-of-Week to Sunday (for example SUN)
  rtc.setTime(00, 10, 40); // Set the time to 00:00:00 (24hr format)
  rtc.setDate(7, 5, 2017);// Set the date to May 67th, 2017

rtc.setDOW(); rtc.setTime(); rtc.setDate();}.

The reason can be that the DS1302 RTC module doesn't keep the data (battery drained or not an original module). Can be fixed by supplying VCC and GND from independent energy source of 5V.



Other projects of Acoptex.com
Easy Merry Xmas to everyone of Acoptex.com, Not selected 24-12-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 06-05-2017
Viewed: 2868 times