Вы находитесь на странице: 1из 15

User Manual

Sensor Data Displaying on LCD using Arduino UNO


Table of Contents

1) End-End IoT Flow diagram


2) Sensor Practical Hardware flow Diagram
3) Sensor Practical To Do
4) H/w and s/w requirements
5) Connecting Sensors to Arduino UNO-R3 Board
6) Programming
7) Save the Project

Practicals Objective:

To capture data from different sensors used in Best cold chain and display the same on LCD using
Arduino UNO.

Description of Sensor Board Elements:

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.

A PIR(Passive infrared sensor) is used to detect the presence of person.

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.

All Rights Reserved-Axelta 2014


1. End-End IoT Flow diagram:

2. Sensor Practical Hardware flow Diagram:

All Rights Reserved-Axelta 2014


3. Sensor Practical To Do:

4. H/w & S/w Requirements:


Hardware required:
Arduino UNO Board
Sensor board
Connectors
USB cable

All Rights Reserved-Axelta 2014


Software Requirement:

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.

Connecting LCD to Arduino UNO Board:


Insert the LCD in the LCD shield as shown below.

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.

All Rights Reserved-Axelta 2014


5. Connecting Sensors to Arduino UNO Board:
Connect Power supply to sensor Board using a 2 pin wire connector from the LCD Shield
connected to Arduino UNO board as shown in picture below.

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.

All Rights Reserved-Axelta 2014


Sensor Board notations:
T Temperature Sensor
L Light Dependent Resistor (LDR)
R Magnetically operated Reed Switch
H Humidity Sensor
P Power Switch based on Optocoupler
X PIR(Passive Infrared Sensor)

Connecting Sensors to Board:

Sensor Board LCD Shield


T A2
P 6

All Rights Reserved-Axelta 2014


Connect Temperature sensor Output pin (which is named as T on Sensor board), to A2 pin on the
LCD Shield placed on Arduino UNO Board using a single pin wire.
Also, connect Power Switch Output (which is named as P on Sensor board), to Pin6 (top-down
approach) of the 3pin black berg receptacle connector provided on the LCD Shield placed on the
Arduino UNO board.
Now place back the LCD shield in the same manner you had done earlier. In case you have taken
out the shield
Connect USB cable from Arduino UNO board to PC.

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.

All Rights Reserved-Axelta 2014


2. Steps for constructing a simple C program in Arduino.

Step1: Create a new sketch [program]

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.

int P=6; //POWER SWITCH

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);

/*********** Analog Read function*********/

Step7: Capture Temperature and display

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.

All Rights Reserved-Axelta 2014


7.4 Set the cursor position by column and row numbers using lcd.setCursor function.

7.5 Display the value on the LCD using lcd.print function.

void Temperature()

{ int value_temp = analogRead(T); // reading from A2 pin


float millivolts_temp= ((value_temp/1023.0)*5000);
float CELSIUS = millivolts_temp/10;
lcd.setCursor(0,1); // column, row
lcd.print("T:");
lcd.print(CELSIUS);
}

/*********** Digital Read function*********/

Step8: Capture Power Status and display

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.

8.3 Else, display its status.

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 ");
}
}

All Rights Reserved-Axelta 2014


/*********** Main function*********/

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.

All Rights Reserved-Axelta 2014


If you get any issues with the uploading there might be a problem in the selection of COM port or
with the drivers. Refer to the Ardunio environment set up manual to make sure that there are no
issues.

After uploading, data from different sensor will be displayed on the LCD.

All Rights Reserved-Axelta 2014


Output on serial Monitor

Set baud rate to 9600

**************************************************

All Rights Reserved-Axelta 2014


Overall code:
Exercise practical's for (Analog inputs):

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

Exercise practical for (Digital inputs):

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

All Rights Reserved-Axelta 2014


Arduino UNO Board notations:

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

Sensor Board LCD Shield


T A2
L A4
H A5

R 5
P 6
X 7

All Rights Reserved-Axelta 2014


All Sensor code Output on serial Monitor

Set baud rate to 9600

All Rights Reserved-Axelta 2014

Вам также может понравиться