Академический Документы
Профессиональный Документы
Культура Документы
Practicals Objective:
To capture data from different sensors used in Best cold chain and display the same on LCD using
Arduino UNO.
A Temperature sensor (Sensor name: LM35D) is used to monitor the temperature of the material
inside the Best Cold Chain truck.
A Humidity sensor (Sensor name: DHT11)is used to monitor the humidity levels of the container in
the truck. We have materials like fish, pharmaceuticals, etc which has to be maintained at
predefined temperature and humidity.
A Light Dependant Resistor ((Sensor name: LDR) is used to know the amount of light present in
the truck. We have materials like storage foods and pharmaceuticals which get damaged when
exposed to sunlight.
A magnetically operated Reed Switch is used to know the status of the truck door, as open or
close.
An opto-coupler is used as Power sensing to know the cold storage container is powered ON all
the time, otherwise the material may damage.
Note: As per its names, the technical datasheets of the sensors can be found in the internet for
more information.
Aurdino1.0.6 - Required if you have not gone through these steps already
http://arduino.cc/en/Main/OldSoftwareReleases
Please refer the MANUAL FOR ANDROID SOFTWARE & DRIVER INSTALLATION for installing
the Arduino software and its drivers.
Insert the LCD shield in the Arduino UNO Board as shown below LCD shield covers Pin 2-AREF on
left side and Pin Analog5 3V3 on right side, while connecting make sure you are matching the
gaps between male connectors back of LCD Shield.
Caution:
While connecting, be sure that the brown wire within the two pin connector must be
connected to the 5v supply (which is named as +5v on the board) in the Arduino UNO board and
black to the Ground (which is named as GND on the board)on the Arduino UNO Board.
Wrong power connection will damage the sensors.
Note: Before getting started, check that the Arduino software is installed. When connected for the
first time, check the Arduino UNO board USB driver software is updated as per the Installation
document.
Programming:
1. Start Arduino IDE by selecting the program in the windows start menu. You will get the Window as
below.
Step2: Include the header file LiquidCrystal.h at the start of the program, to use the functions
related to LCD
#include<LiquidCrystal.h>
Step3: Make the global declaration of the LCD pins with the microcontroller pins of the Arduino
board, i.e., RS, E, D4, D5, D6, D7, with pins 8, 9, 10, 11, 12, 13 using LiquidCrystal.
LiquidCrystal lcd(8,9,10,11,12,13);
Step4: Initialize a variable as integer with the pin number to which the digital sensor is connected.
Step5: Initialize a variable as integer with the Analog pin number to which the analog sensor is
connected.
int T= A2; // A2 has already been defined as Analog Pin 2 in arduino lib
Step6: Write a setup function and initialize the LCD as 16 columns with 2 rows with the help of
lcd.begin function.
void setup()
{
lcd.begin(16,2);
pinMode(P, INPUT);
7.1 Start a void TEMPERATURE function and with the help of analogRead function to read the
value from the Analog variable and store it to an integer variable. This gets the Temperature from
the sensor and prints the actual value by converting analog voltage to the temp. Refer to data
sheet for temp in manual
7.2 Divide the obtained value with the resolution of the ADC (i.e., 1023.0) and multiply the result
with reference milli volts. (5V = 5000mV) and save it to a float variable.
7.3 Divide the above result by 10 because there will be 1C change for every 10mV of output and
save it to another float variable.
void Temperature()
8.1 Start a void POWER function and check the concerned digital pin/variable is LOW.
8.2 If it is LOW, display the status on the LCD with the help of lcd.print function and
lcd.setCursor functions respectively.
void POWER()
if(digitalRead(P)==LOW)
{
lcd.setCursor(0,0); // column, row
lcd.print("P:");
lcd.print("OFF");
}
else
{
lcd.setCursor(0,0); // column, row
lcd.print("P:");
lcd.print("ON ");
}
}
Step9:
9.1 Start a function with the name loop. This is the Main loop/function of the whole
code/program. As the name indicates, this function is called in a continuous loop by Arduino
library.
9.2 Call the above Analog and Digital functions simultaneously with sufficient delays, using
delay function in milliseconds.
void loop()
{
Temperature ();
POWER();
delay(2000);
}
Step10:
Now save the project : Go to File menu, you can find save option as the windows shown below
Click on save, give a File name and click ok.
Now go to the File menu, click on Upload option. Then the code is compiled and loaded in to
Arduino UNO board.
After uploading, data from different sensor will be displayed on the LCD.
**************************************************
You might want to check the Arduino UNO R3 Overview Document to understand where else the
analog pins are located.
1. Interface the "Light Sensor" and see the output. (assign the Light sensor output to an
analog pin, define the pin name and write the function similar to Temperature function)
Hint: LIGHT=milivolts_lig /10; Make sure that you print on the right cursor location
2. Interfacing the"DHT11(Humidity sensor)", add DHT11 library (dht11 library and steps will
be provided)
after that Copy the code From "Sensor practical_code.txt" see the output. Make sure that
you print on the right cursor location
1. Interface the "Reed Switch" and see the output. (assign the reed switch output to a digital
pin, define the pin name and write the function Similar to POWER function)
Refer the picture for connecting all sensors to Arduino UNO board & "Sensor practical_code.txt" in
"Code" folder for complete code
A2 Analog input pin for the output pin (T) of Temperature sensor
A4 Analog input pin for the output pin (L) of Light sensor (LDR)
A5 Analog input pin for the output pin (H) of Humidity sensor
5 Digital input pin for the output pin (R) of Reed switch
6 Digital input pin for the output pin (P) of Power switch
7 Digital input pin for the output pin (X) of PIR sensor
R 5
P 6
X 7