Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
31 views7 pages

Temperature Sensor Using Arduino

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 7

PART – II

ELECTIVE I

Internet of Things and Embedded Systems

ASSIGNMENT NO: 02

Title: Understanding the connectivity of Raspbeery pi/Adurnio board circuit with temperature
sensor. Write an application to read the environment temperature. If temperature crosses a threshold
value, generate alerts using LEDs.

Objectives:

- To demonstrate connectivity of temperature sensor LM35 and Arduino board


- To implement a program in which temperature beyond 26 degree Celsius would be indicated by
LED.

Outcomes:

Temperature is observed using temperature sensor and display the result on serial monitor.

Hardware : MicroATmega328 Microcontroller development Board.

Software: Arduino IDE

Theory:

Introduction To Arduino

Arduino is an open-source platform used for building electronics projects. Arduino consists of both a
physical programmable circuit board (often referred to as a microcontroller) and a piece of software,
or IDE (Integrated Development Environment) that runs on your computer, used to write and upload
computer code to the physical board. Accepts analog and digital signals as input and gives desired
output.

MicroATmega328-ATmega328 Microcontroller Development Board

The MicroATmega328 is a Arduino compatible Hardware Development Platform from


MicroEmbedded Technologies. It is a full featured board for the beginner as well as the expert user
who is accustomed to the Arduino platform and or the ATmega series microcontroller development.
The MicroATmega328 development board retains all the features of the Arduino Uno board and adds
to it additional interfaces like the 16x2 character LCD, on-board LED’s, USB-to-Serial adaptors, 16
key keypad arranged in 4x4 matrix circuit, on-board Temperature sensor, I2C interface Real Time
Clock, external interrupt, Stepper Motor / DC Motor, SPI based flash programming interface, dual
power source, header for accelerometer and also a Arduino Uno board compatible Header to
interface the easily available Arduino Shield boards. All these features make the MicroAtmega328 a
very versatile and a more robust educational tool for the learner as well as the trainer.

Figure 1 Block Diagram of the MicroATmega328 Board

The ATmega328 is a high-performance 8-bit AVR RISC-based microcontroller. It combines 32KB


ISP flash memory with read-while-write capabilities, 1KB EEPROM, 2KB SRAM, 23 general
purpose I/O lines, 32 general purpose working registers, three flexible timer/counters with compare
modes, internal and external interrupts, serial programmable USART, a byte-oriented 2-wire serial
interface, SPI serial port, 6-channel 10-bit A/D converter, programmable watchdog timer with
internal oscillator, and five software selectable power saving modes. The device operates between
1.8-5.5 volts.

The ATmega328 AVR Microcontroller


Figure 2 ATmega328 AVR Microcontroller

Hardware: Functional Description and Interfacing

Light Emitting Diode (LED)


Light Emitting Diode (LED) is a semiconductor device which emits light at a very low power. They
are highly efficient devices and require very low current in order to operate. A voltage of 5v and
current of 10mA is enough to turn the LED on. The LED has a positive side called the Anode and a
negative side called the Cathode. The current must flow from the Anode to Cathode for the LED to
turn on. On the MicroATmega328 board there are 4 LEDs. The LED’s are connected in the common
cathode method, i.e. all the cathodes are connected together and grounded. The individual Anodes
are connected to the individual Pins of the microcontroller. To turn the LED “ON” the user has to
program the port pin to “HIGH” i.e.”1”.
Note: switch SW20 must be in position 2-3 to operate the LED’s.
Figure 3 LED

Table 1 LED Interfacing Details

LED
Device ATmega328 Pin Arduino Pin Description
LED1 PB2 10 Common Cathode
LED
LED2 PB3 11 Common Cathode
LED
LED3 PB4 12 Common Cathode
LED
LED4 PB5 13 Common Cathode
LED

LM35 Temperature Sensor.

The LM35 is an integrated circuit sensor that can be used to measure temperature with an
electrical output proportional to the temperature (in oC), i.e. it generates a electrical
voltage which is proportional to temperature. The LM35 does not require any calibration
or trimming. The LM35 gives a linear output of 10 mV per degree Centigrade (10mV/ oC)
change in temperature. It operated from -55 oC to 155 oC temperature range. Note: To
use the LM35 temperature sensor on the MicroATmega328 board the switch SW23
must be connected in position 1-2.

Figure 4 Temperature Sensor


LM35 Temperature sensor
Device ATmega328 Pin Arduino Pin Description
LM35 PC0 A0 LM35 sensor
output

ARDINO IDE OVERVIEW

1. To create a new sketchFile -> New


• To open an existing sketch File -> open ->
• There are some basic ready-to-use sketches available in the EXAMPLES section
• File -> Examples -> select any program

Program coded in Arduino IDE is called a SKETCH
2. Verify: Checks the code for compilation errors
3. Upload: Uploads the final code to the controller board
4. New: Creates a new blank sketch with basic structure
5. Open: Opens an existing sketch
6. Save: Saves the current sketch

Serial Monitor: Opens the serial console


All the data printed to the console are displayed here
Figure 5 Structure of Sketch

A sketch can be divided into two parts:


Setup ()
Loop()
The function setup() is the point where the code starts, just like the main() function in C and C++
I/O Variables, pin modes are initialized in the Setup() function Loop() function, as the name
suggests, iterates the specified task in the program
DATA TYPES:
Void ,Long, Int ,Char ,Boolean, Unsigned char ,Byte, Unsigned int, Word ,Unsigned long ,Float,
Double, Array ,String-char array, String-object, Short
Arduino Function libraries
Input/Output Functions:
The arduino pins can be configured to act as input or output pins using the pinMode() function
Void setup ()
{
pinMode (pin , mode);
}
Pin- pin number on the Arduino board Mode- INPUT/OUTPUT
digitalWrite() : Writes a HIGH or LOW value to a digital pin
analogRead() : Reads from the analog input pin i.e., voltage applied across the pin
Character functions such as isdigit(), isalpha(), isalnum(), isxdigit(), islower(), isupper(), isspace()
return 1(true) or 0(false)
Delay() function is one of the most common time manipulation function used to provide a delay of
specified time. It accepts integer value (time in miliseconds)

Program

Write down code which we have implemented in practical and paste screenshot which we have done
in practical.

You might also like