AC Project Report
AC Project Report
MATRIC NO.
MH11016
MH11023
MH11017
SECTION NO.
01
01
01
Abstract
Description:
A history monitor graph is a special idea which makes to read the current ambient
temperature and calculate an average, minimum and maximum and display all these to the LCD
display.
Block diagram:
LM35
sensor)
(Temperatur
Arduino Uno
Display (LCD)
Platforms to be used:
Hardware: Arduino board, LM35 sensor, LCD Software: Arduino IDE
TABLE OF CONTENTS
PAGES
ABSTRACT
ii
CHAPTER I
CHAPTER II
CHAPTER III
INTRODUCTION
1.1
Background intro.
1.2
Aim of the project
1.3
Problem statement
1.4
Significance of this work
1.5
Conclusion
1
1
1
1
1-2
ARDUINO
2.1
Overview
2.2
Schematic and reference design
2.3
Summary
2.4
Power
2.5
Memory
2.6
Input and Output
2.7
Communication
2.8
Programming
2.9
Automatic reset
2.10 USB Overcurrent protection
2.11 Physical Characteristics
3
4
5
5-6
7
7-8
8
8-9
9
10
10
PROJECT DESCRIPTION
3.1
Circuit diagram
3.2
Source code
3.3
Flow Chart
3.4
Program
11-12
12-20
21
22-26
REFERENCES
27
Chapter 1
INTRODUCTION
1.1
Introduction
This project is designed to be a temperature data logger measuring the following with
respects to time:
1. Current Temperature
3
2. Average Temperature
3. Rate of Change in Temperature
1.2
1.3
Problem statement
1. How can we accurately and purposefully present temperature data to a user?
2. How can we allow so many hardware components to communicate with each other?
1.4
Initial motivations were to allow the user to be able to monitor temperature conditions, both from
their computer and in person.
1.5
Conclusion
As
say
the
concluding
that--
part
of
this
project,
we
would like
to
"Without proper action at proper time, danger awaits us with a bigger face." We must act on
time when a person is injured. We must take care of person the way it is meant. otherwise, a
valuable life might be lost .We need to understand how precious lives of people are and what
importance first-aid carries in saving these precious lives.
If this project imparts this idea in even one person, I would think that the project will be
successful.
4
Chapter 2
ARDUINO
2.1
Overview
The Arduino Uno is a microcontroller board based on the ATmega328 . It has 14 digital
input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic
resonator, a USB connection, a power jack, an ICSP header, and a reset button. It contains
everything needed to support the microcontroller; simply connect it to a computer with a USB
cable or power it with a AC-to-DC adapter or battery to get started.
The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver
chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a
USBto-serial converter.
Revision3 of the board has the following new features:
1.0 pinout: added SDA and SCL pins that are near to the AREF pin and two other new pins
placed near to the RESET pin, the IOREF that allow the shields to adapt to the voltage
provided from the board. In future, shields will be compatible both with the board that use
the AVR, which operate with 5V and with the Arduino Due that operate with
3.3V. The second one is a not connected pin, that is reserved for future purposes.
Atmega 16U2 replace the 8U2.
"Uno" means one in Italian and is named to mark the upcoming release of Arduino 1.0.
The Uno and version 1.0 will be the reference versions of Arduino, moving forward. The
Uno is the latest in a series of USB Arduino boards, and the reference model for the
Arduino platform; for a comparison with previous version
2.2
The Arduino reference design can use an Atmega8, 168, or 328, Current models use an
ATmega328, but an Atmega8 is shown in the schematic for reference. The pin configuration is
identical on all three processors.
2.3
Summary
Microcontroller
Operating Voltage
ATmega328
5V
Input Voltage
(recommended)
7-12V
6-20V
40 mA
50 mA
Flash Memory
SRAM
EEPROM
1 KB (ATmega328)
Clock Speed
16 MHz
2.4
Power
The Arduino Uno can be powered via the USB connection or with an external power supply. The
power source is selected automatically.
External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The
adapter can be connected by plugging a 2.1mm center-positive plug into the board's power jack.
Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector.
The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V,
however, the 5V pin may supply less than five volts and the board may be unstable. If using more
than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7
to 12 volts. The power pins are as follows:
VIN. The input voltage to the Arduino board when it's using an external power source (as
opposed to 5 volts from the USB connection or other regulated power source). You can
supply voltage through this pin, or, if supplying voltage via the power jack, access it
through this pin.
5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied
with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of
8
the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can
damage your board. We don't advise it.
3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50
mA.
GND. Ground pins.
IOREF. This pin on the Arduino board provides the voltage reference with which the
microcontroller operates. A properly configured shield can read the IOREF pin voltage
and select the appropriate power source or enable voltage translators on the outputs for
working with the 5V or 3.3V.
2.5 Memory
The ATmega328 has 32 KB (with 0.5 KB used for the bootloader). It also has 2 KB of SRAM
and 1 KB of EEPROM (which can be read and written with the EEPROMlibrary).
2.7
Communication
The Arduino Uno has a number of facilities for communicating with a computer, another
Arduino, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial
communication, which is available on digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the
board channels this serial communication over USB and appears as a virtual com port to software
on the computer. The '16U2 firmware uses the standard USB COM drivers, and no external
driver is needed. However, on Windows, a .inf file is required. The Arduino software includes a
serial monitor which allows simple textual data to be sent to and from the Arduino board. The
RX and TX LEDs on the board will flash when data is being transmitted via the USB-to-serial
chip and USB connection to the computer (but not for serial communication on pins 0 and 1).
A Software Serial library allows for serial communication on any of the Uno's digital pins.
The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino software
includes a Wire library to simplify use of the I2C bus; see the documentation for details. For SPI
communication, use the SPI library.
2.8
Programming
11
2.9
Rather than requiring a physical press of the reset button before an upload, the Arduino Uno is
designed in a way that allows it to be reset by software running on a connected computer. One of
the hardware flow control lines (DTR) of theATmega8U2/16U2 is connected to the reset line of
the ATmega328 via a 100 nanofarad capacitor. When this line is asserted (taken low), the reset
line drops long enough to reset the chip. The Arduino software uses this capability to allow you
to upload code by simply pressing the upload button in the Arduino environment. This means
that the bootloader can have a shorter timeout, as the lowering of DTR can be well-coordinated
with the start of the upload.
This setup has other implications. When the Uno is connected to either a computer running Mac
OS X or Linux, it resets each time a connection is made to it from software (via USB). For the
following half-second or so, the bootloader is running on the Uno. While it is programmed to
ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first
few bytes of data sent to the board after a connection is opened. If a sketch running on the board
receives one-time configuration or other data when it first starts, make sure that the software with
which it communicates waits a second after opening the connection and before sending this data.
The Uno contains a trace that can be cut to disable the auto-reset. The pads on either side of the
trace can be soldered together to re-enable it. It's labeled "RESET-EN". You may also be able to
disable the auto-reset by connecting a 110 ohm resistor from 5V to the reset line.
12
2.10
The Arduino Uno has a resettable polyfuse that protects your computer's USB ports from shorts
and overcurrent. Although most computers provide their own internal protection, the fuse
provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse
will automatically break the connection until the short or overload is removed.
2.11
Physical Characteristics
The maximum length and width of the Uno PCB are 2.7 and 2.1 inches respectively, with the
USB connector and power jack extending beyond the former dimension. Four screw holes allow
the board to be attached to a surface or case. Note that the distance between digital pins 7 and 8
is 160 mil (0.16"), not an even multiple of the 100 mil spacing of the other pins.
13
Chapter 3
PROJECT DESCRIPTION
3.1
Circuit diagram
To connect and use the LCD Display with arduino we followed the Hello world example
from the Arduino Library Examples (http://arduino.cc/en/Tutorial/LiquidCrystal). While the LCD
has an 8bit parallel connection it is possible to display almost everything with just 4bits.
To wire your LED screen to your Arduino, connect the following pins:
LCD RS pin to digital pin 12
LCD Enable pin to digital pin 11
LCD D4 pin to digital pin 5
LCD D5 pin to digital pin 4
LCD D6 pin to digital pin 3
LCD D7 pin to digital pin 2
14
3.2
Source code
// Arduino LCD Ambient Temperature and temperature history graph Monitor.
// Displays Current temp, Max and Min Temperature and graph 30 logged averages of 10
temperature points sampled at defined period over time.
// Graph is created using the custom characters of an HC44780 16x2 LCD disply.
// To wire your LED screen to your Arduino, connect the following pins:
//LCD RS pin to digital pin 12
//LCD Enable pin to digital pin 11
//LCD D4 pin to digital pin 5
15
float tempCp = 0; // variable for holding Celcius last temp (floating for decimal points
precision)
int tempPin = 0; // Declaring the Analog input to be 0 (A0) of Arduino board for LM35.
float volt = 4.85; // Volts at supply pins of LM35. Need this so that LM35 can correctly
read ambient temperature.
int ledPin = 13; // define the output for red led on Arduino board in this variable. Maybe in
other pin in future.
unsigned long currentTime; // This variable is need to keep current value of milis();
function
16
unsigned long loopTime; // This variable is need to keep updated value of milis(); function
for comparison reasons.
int temp = 0;
byte grafChar[8] = { // this is the array to feed to custom HC44780 lcd characted. Initialize
as empty (nothing is displayed.)
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000
}; // this is for the graph characher created
byte degChar[8] = { // array to feed custom LCD char to create the degrees symbol
B00110,
B01001,
B01001,
B00110,
B00000,
B00000,
B00000,
B00000
};
float temparray[10]; // array to hold 10 temperature samples temperature measurements.
Evewytime is filled average of 10 is calculated and new point is added to graph.
int i=0; // counter for loops
int countcol; // column of custom character 5x8 array.
int mempos = 0; // custom LCD character number selection initialized , see setup for real
value
int glcdpos = 0; // first graph character position initialized, see setup for value real value
17
// function to set clear custom graph chararacter matrix (not an independent function, just to
make loop code neater
void clearchar() { // a quick way to set all grafChar bits back to zero so as to creat a new
one.
int countj=0;
while (countj < 8) {
grafChar[countj] = B00000;
countj++;
}
return;
} // end clear char
// function to clear range of LCD custom characters. Needs graph char to be set to nothing
first (clearchar)
void clearcustomchar (int first , int second) { // clear the custom character LCD memory at
the range given at function input.
int counter = first;
while (counter < second+1) {
lcd.createChar(counter, grafChar);
counter++;
}
return;
} // end clearcustomchar
// function to find average of temparray (not an independent function , just to clear the loop
code)
void averagecalc() {
temparraycounter = 0; // initialize counter
average=0; // set average variable back to zero
while (temparraycounter < 10) { // add the 10 temparray elements and store sum to average
average = average + temparray[temparraycounter];
temparraycounter++; // increase temparrayposition
}
average = (average / 10); // get average of 10 measurements
temparraycounter = 0; // needs to be set again to zero because it's used in various places.
19
} // end averagecalc()
// function to update min and max temp values whenever average is calculated. (not an
independent function , just to clear the loop code)
void minmaxupdate() {
if (average > maxtemp) { // update maximum temperature
maxtemp = average;
}
if (average < mintemp) { // update minimum temperature
mintemp = average;
}
} // end minmaxupdate
// END OF FUNCTIONS
void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin as output
currentTime = millis();
loopTime = currentTime;
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
lcd.createChar(0, degChar); // degrees Celcius symbol
// Intro text
lcd.setCursor(0, 0); // set LCD cursor position (column, row)
lcd.print("Gmen's second "); // print text to LCD
lcd.setCursor(0, 1);
lcd.print("Arduino project");
delay(5000); // wait 500ms
lcd.clear(); // clear LCD display
lcd.setCursor(0, 0);
lcd.print("Temp monitor with");
lcd.setCursor(0, 1);
lcd.print("6seg graph chart");
delay(5000);
20
lcd.clear();
// end intro text
clearchar(); // clear graph character array
clearcustomchar(1,6); // write the cleared grafchar array to custom LCD memory poitions
lcd.setCursor(10, 1); // set cursor to first graph LCD text elements.
lcd.write(1); // write to screen the first custom graph character.
lcd.setCursor(11, 1);
lcd.write(2);
lcd.setCursor(12, 1);
lcd.write(3);
lcd.setCursor(13, 1);
lcd.write(4);
lcd.setCursor(14, 1);
lcd.write(5);
lcd.setCursor(15, 1);
lcd.write(6);
countcol = 0;
mempos = 1; // defines first screen position for graph
glcdpos = 10; // first graph character position
lcd.setCursor(2, 1);
lcd.print((int)updatetime); // milis
} // end void setup
void loop () {
//get and print current temperature every second
tempC = ( volt * analogRead(tempPin) * 100.0) / 1024.0; // conversion math of LM35
sample to readable temperature and stores result to samples array. 1024 is the Bit depth
(quantization) of Arduino.
// 5 is the supply volts of LM35. Change appropriatelly to have correct measurement. My
case is 4.85Volts.
21
lcd.setCursor(9, 0);
lcd.print(tempC);
lcd.write(0);
lcd.print("C");
// update temparray every msec period set by updatetime constant
currentTime = millis();
if(currentTime >= (loopTime + updatetime)){
temparray[temparraycounter] = tempC; // store current temperature to temp array
digitalWrite(ledPin, !digitalRead(ledPin)); // toggles the LED on/off
lcd.setCursor(0, 1);
lcd.print(temparraycounter);
temparraycounter++; // increase temparrayposition
loopTime = currentTime; // Updates loopTime
}
23
3.3
Flow Chart
24
3.4
PROGRAM
#include <SoftwareSerial.h>
#include <TinyGPS.h>
#include "SIM900.h"
#include "sms.h" SMSGSM
sms;
boolean started= false;
// GPS parser for 406a
#define BUFFSIZ 45 // plenty big int ledpin = 13; int knockSensor = A0; // the piezo is
connected to analog pin 0 int threshold = 30; // threshold value to decide when the
detected sound is a knock or not int sensorReading = 0; char buffer[BUFFSIZ]; char
*parseptr; char buffidx; uint8_t hour, minute, second, year, month, date; int latitude,
longitude; uint8_t groundspeed, trackangle; char latdir, longdir; char status;
void setup()
{
if (ledpin)
{
pinMode(ledpin, OUTPUT);
}
pinMode(13, OUTPUT);
Serial.begin(9600); // prints title with ending line break
Serial.println("GPS parser"); digitalWrite(ledpin,
LOW); // pull low to turn on!
}
void loop()
{ int tmp; sensorReading =
analogRead(knockSensor);
if
(sensorReading >= threshold)
{
25
parseptr =
latitude +=
}
parseptr = strchr(parseptr, ',') + 1;
// read latitude N/S data
if
(parseptr[0] != ',')
{
latdir = parseptr[0];
}
Serial.print(latdir);
// longitude
parseptr = strchr(parseptr, ',')+1;
longitude = parsedecimal(parseptr);
(longitude != 0)
if
{
longitude *= 10000;
26
// groundspeed
parseptr =
strchr(parseptr, ',')+1;
groundspeed =
parsedecimal(parseptr);
// track angle
parseptr =
strchr(parseptr, ',')+1;
trackangle =
parsedecimal(parseptr);
// date
parseptr =
strchr(parseptr, ',')+1;
tmp =
parsedecimal(parseptr);
date =
tmp / 10000;
month = (tmp /
100) % 100;
year = tmp % 100;
Serial.print("\nTime: ");
Serial.print(hour, DEC); Serial.print(':');
Serial.print(minute, DEC); Serial.print(':');
Serial.println(second, DEC);
Serial.print("Date: ");
Serial.print(month, DEC); Serial.print('/');
Serial.print(date, DEC); Serial.print('/');
Serial.println(year, DEC);
27
Serial.print("Lat: ");
if (latdir == 'N')
Serial.print('+');
else
if (latdir == 'S')
Serial.print('-');
Serial.print(latitude/1000000, DEC); Serial.print('\'); Serial.print(' ');
Serial.print((latitude/10000)%100, DEC); Serial.print('\''); Serial.print(' ');
Serial.print((latitude%10000)*6/1000, DEC); Serial.print('.');
Serial.print(((latitude%10000)*6/10)%100, DEC); Serial.println('"');
Serial.print("Long: ");
if (longdir == 'E')
Serial.print('+');
else
if (longdir == 'W')
Serial.print('-');
Serial.print(longitude/1000000, DEC); Serial.print('\'); Serial.print(' ');
Serial.print((longitude/10000)%100, DEC); Serial.print('\''); Serial.print(' ');
Serial.print((longitude%10000)*6/1000, DEC); Serial.print('.');
Serial.print(((longitude%10000)*6/10)%100, DEC); Serial.println('"');
Serial.print(latitude);
Serial.print(longitude);
latitude=lati[10];
longitude=longi[10];
Serial.print(lati);
Serial.print(longi);
Serial.println(buffer);
delay(1000);
Serial.println("GSM Testing to send SMS");
if (gsm.begin(9600))
{
Serial.println("\nstatus=READY");
started=true;
}
else
{
28
Serial.println("\nstatus=IDLE");
}
if(started)
{
if (sms.SendSMS("+919052378836", "accident has occured at"))
if (sms.SendSMS("+919052378836", buffer))
Serial.println("\nSMS sent OK");
}
}
}
}
uint32_t parsedecimal(char *str)
{ uint32_t d = 0;
while (str[0] != 0)
{
if ((str[0] > '9') || (str[0]
< '0'))
return d;
d *= 10;
d += str[0] - '0';
str++;
}
return d;
}
void readline(void)
{
c;
char
buffer[buffidx] =
return;
}
29
buffer[buffidx++]= c;
}
}
BIBLIOGRAPHY
i. Intro to Embedded systems, By Shibu, 2009. ii.
GRIET Arduino manual
iii.
iv.
30
31