Arduino/C2/Analog-to-Digital-Conversion/English-timed
From Script | Spoken-Tutorial
Time | Narration |
00:01 | Welcome to the Spoken Tutorial on Analog to Digital Conversion using Arduino. |
00:07 | In this tutorial, we will learn about : ADC i.e. Analog to Digital Conversion |
00:14 | ADC pins in Arduino
ADC Resolution |
00:19 | DHT11 Temperature and Humidity sensor |
00:23 | Serial Monitor and Serial Plotter |
00:27 | To follow this tutorial, you should have a basic knowledge of:
Electronics and C or C++ programming language |
00:37 | To record this tutorial, I am using:
Arduino Uno board |
00:43 | Ubuntu Linux 16.04 OS
and Arduino IDE |
00:50 | We require few external components such as
DHT11 sensor |
00:57 | Breadboard and Jumper wires |
01:02 | In this tutorial, we will detect the temperature and humidity using DHT11 sensor. |
01:09 | This sensor collects analog values and gives it to Arduino Uno. |
01:15 | Arduino ADC pins will convert these analog values to digital values. |
01:21 | Next, we will understand the concept of resolution. |
01:25 | Arduino Uno has 10-bit resolution. |
01:28 | This means, it can detect (2 to the power of 10) i.e. 1024 discrete analog levels. |
01:37 | Resolution is the smallest change that can be measured |
01:42 | Arduino gives 5 Volts output voltage, so 5 Volts divided by 1024 levels gives 4.89 miliVolts. |
01:56 | That means, Arduino Uno can be sensitive to a minimal change of 4.8 9miliVolts. |
02:04 | This shows the circuit connection for DHT11 with Arduino. |
02:10 | Arduino Uno has 6 in-built ADC channels (A0 to A5). |
02:17 | ADC channels read analog signal in the range of 0-5 Volts. |
02:23 | Pin 1 of the DHT11 sensor is connected to 5 Volts pin of Arduino. |
02:30 | Pin 2 of the DHT11 sensor is the Data pin. |
02:35 | This Data pin of the sensor is connected to analog pin A0 of Arduino. |
02:42 | Pin 3 of the DHT11 sensor is connected to the ground pin of the Arduino. |
02:48 | This is the live setup of the connection, as shown in the circuit diagram. |
02:53 | Now we will write the program in Arduino IDE. |
02:57 | Open Arduino IDE. |
03:00 | First we need to download the DHT11 arduino library to run this program. |
03:06 | Click on Sketch menu in the menu bar. |
03:10 | Select Include Library and then click on Manage Libraries option. |
03:16 | A new window will appear. |
03:19 | In the top right corner, we can see a search tab.
Here, type DHT11 and press Enter. |
03:28 | We can see various libraries for DHT11 sensor. |
03:33 | Scroll down to the bottom of the screen and select SimpleDHT by Winlin. |
03:39 | In the version drop down box, we can select the latest version of the library. |
03:45 | Click on Install button to install the library. |
03:49 | The DHT11 library is now installed in the Arduino IDE. |
03:54 | Click on the Close button at the right bottom of the window. |
03:59 | Let us add this library to the program. |
04:02 | Click on the Sketch menu and select Include Library. |
04:06 | Newly downloaded library usually appear at the end. |
04:11 | So scroll down to the bottom of the list and select SimpleDHT. |
04:17 | We can see the header file SimpleDHT.h added in the code window. |
04:24 | Type the code as shown. |
04:27 | Here we have initialized the data pin of DHT11 sensor which is connected to A0. |
04:34 | This command creates a DHT object. |
04:38 | Inside void setup function, type the code as shown: |
04:43 | Serial.begin() function initiate the serial communication. |
04:48 | It sets the data rate in bits per second for serial data transmission. |
04:54 | 9600 represents the baud rate. |
04:58 | delay(500) is the delay time for the sensor to boot. |
05:03 | Serial.print command prints the header as specified here. |
05:08 | Now we will write the code for void loop. |
05:12 | We have created two variables, temperature and humidity for DHT sensor output. |
05:20 | dht11.read, reads the data from the sensor. |
05:25 | It stores the result in microcontroller’s register. |
05:29 | These lines prints the temperature in degree Celsius and humidity in percentage. |
05:36 | delay(2000) updates the current humidity and temperature readings every 2 seconds. |
05:43 | This code is available in the Code files link of this tutorial.
You can download and use it. |
05:51 | Click on the compile button to verify your program. |
05:55 | A pop up window will appear to save the current program.
Save the program as DHT11. |
06:05 | Now click on upload button to upload the current program on Arduino. |
06:11 | We will see the output in the Serial monitor screen. |
06:15 | For this, click on the Tools menu and select Serial monitor. |
06:21 | The serial monitor window opens. |
06:25 | Temperature and humidity of the current place is displayed as expected.
Close the window. |
06:33 | Next we will see the output in the serial plotter. |
06:37 | Let us modify the program. |
06:40 | Comment the line Serial.print( “Temperature & Humidity :”); as shown. |
06:47 | This will not print the text Temperature and Humidity. |
06:52 | For plotting, we require only the values of temperature and humidity. |
06:58 | Let us upload the current program to see the results on serial plotter. |
07:04 | Click on the tools menu and select serial plotter.
The serial plotter window opens. |
07:12 | We can see two lines simultaneously plotting the points. |
07:18 | The blue line indicates the temperature which is around 28 to 30 °C. |
07:25 | The red line is the humidity reading which is near to 45%. |
07:31 | The readings will vary depending upon where the experiment is done. |
07:36 | Now cover the sensor with your hands and you will see the fluctuating readings. |
07:43 | Close the window. |
07:45 | It is useful for humidity readings between 20% to 80% with ∓5% RH i.e. (Relative Humidity) |
07:56 | It is useful for temperature readings between 0 to 50 °C with ∓2 °C |
08:06 | This brings us to the end of this tutorial. Let us summarize. |
08:12 | In this tutorial, we learnt about:
ADC i.e. Analog to Digital Conversion |
08:19 | ADC pins in Arduino
ADC Resolution |
08:25 | DHT11 Temperature and Humidity sensor
Serial Monitor and Serial Plotter |
08:33 | As an assignment:
Raise an alarm by glowing the built in LED pin 13 of the Arduino |
08:41 | Modify the above existing code.
Hint: Use If-else statement. |
08:48 | Add 1 or 2 °C to the temperature value that you get on the serial monitor. |
08:55 | To increase the temperature reading, cover the DHT11 sensor with your hands. |
09:02 | Refer to the Assignment link of this tutorial for the source code. |
09:07 | The video at the following link summarizes the Spoken Tutorial Project
Please download and watch it. |
09:15 | The Spoken Tutorial Project Team conducts workshops and gives certificates. |
09:21 | Please post your timed queries in this forum |
09:27 | Spoken Tutorial Project is funded by MHRD, Government of India |
09:34 | This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, IIT Bombay.
And this is Saurabh signing off. Thanks for joining. |