You are on page 1of 18

ASSIGNMENT

Subject Code 19ECC214A


Subject Name Microprocessors and Microcontrollers
Programme/Course B.Tech.
Department ECE
Faculty FET

Name of the Student Abhiraman.S


Reg. No 18ETEC004001
Semester/Year 4th/2018
Subject Leader/s Mr. Vishwanath K

M. S. Ramaiah University of Applied Sciences


University House, Gnanagangothri Campus, New BEL Road,
M S R Nagar, Bangalore, Karnataka, INDIA - 560 054.
i
Declaration Sheet
Student Name Abhiraman.S
Reg. No 18ETEC004001
Programme/Course B.Tech. ECE Semester/Year 4th / 2018
Subject Code 19ECC214A
Subject Title Microprocessors and Microcontrollers
Subject Date to
Subject Leader Mr Vishwanath K

Declaration

The assignment submitted herewith is a result of my own investigations and that I have
conformed to the guidelines against plagiarism as laid out in the Student Handbook. All
sections of the text and results, which have been obtained from other sources, are fully
referenced. I understand that cheating and plagiarism constitute a breach of University
regulations and will be dealt with accordingly.

Signature of the Student Date

Submission date stamp


(by Examination & Assessment
Section)

Signature of the Subject Leader and date Signature of the Reviewer and date

ii
Faculty of Engineering and Technology
Ramaiah University of Applied Sciences
Department Electronics and Communication Programme B.Tech.
Engineering
Semester/Ba tch 4 / 2018
Course Code 19ECC214A Course Title Microprocessors and Microcontrollers

Course Leader(s) Mr. Vishwanath K and Divya Kiran

Assignment

Reg.No. 18ETEC004001 Name of Student ABHIRAMAN.S

Marks

Marking Scheme First


Examiner Moderator
Marks

A1.1 Draw the flowchart 2

A1.2 Assembly language program 6

A1.3 Validation of the results 4

A1.4 Interfacing of peripherals 6

A1.5 Demonstrating the application 7

Total Assignment
25
Marks

Course Marks Tabulation


Component-1 (B) First
Remarks Moderator Remarks
Assignment Examiner

Marks (Max 25 )

Signature of First Examiner Signature of Moderator

Please note:

<Subject Title> iii


1. Documental evidence for all the components/parts of the assessment such as the reports,
photographs, laboratory exam / tool tests are required to be attached to the assignment report
in a proper order.
2. The First Examiner is required to mark the comments in RED ink and the Second
Examiner’s comments should be in GREEN ink.
3. The marks for all the questions of the assignment have to be written only in the Component
– CET B: Assignment table.
4. If the variation between the marks awarded by the first examiner and the second examiner
lies within +/- 3 marks, then the marks allotted by the first examiner is considered to be
final. If the variation is more than +/- 3 marks then both the examiners should resolve the
issue in consultation with the Chairman BoE.

Assignment 01

Instructions to students:

1. The assignment consists of Part A- 1 Questions.

2. Maximum marks is 25.

3. The assignment has to be neatly word processed as per the prescribed format.

4. The printed assignment must be submitted to the course leader.


5. Submission Date: 20/04/2020

6. Submission after the due date is not permitted.

7. IMPORTANT: It is essential that all the sources used in preparation of the assignment
must be suitably referenced in the text.
8. Marks will be awarded only to the sections and subsections clearly indicated as per the
problem statement/exercise/question

Preamble

This course deals with the principles of Microprocessors and Microcontrollers. This subject
facilitates the students to understand the concepts of architecture and operation of
Microprocessors and Microcontrollers. Students are taught to program Microprocessors and
Micro-controllers to realize the given functionality. Students are trained to solve practical
problems involving interfacing of microprocessors and controllers with the external
peripherals.

Part A (25 Marks)


Design and develop given application using Arduino board. Carry the followings:
A 1.1 Draw the flowchart for the given scenario specifying the sensors inputs.
A 1.2 Develop the Arduino program for the given scenario.

<Subject Title> iv
A 1.3 Validate the program using Arduino IDE.
A 1.4 Interface input and output peripherals with Arduino board.
A 1.5 Implement and demonstrate the application on Arduino board.

NOTE: Contact Subject leader for the applications.

Applications and Descriptions


Note: Students can add functionality with proper justification. Minor variation of the
functionalities in consent of subject leader is permissible.

Group Application I/O Peripherals Expected Functionality


No. Name required
1 Mini Weather Temperature sensor, It should forecast the weather
Station Humidity sensor, based on the data from interfaced
Barometer, LCD sensors
2 Automatic Temperature sensor, It should start the motor value of
watering System Humidity sensor, soil input sensors increases or
moisture, servo decreases than a
motor, LCD threshold level
3 Smart Cane Ultrasonic sensor, It should detect the obstacle and
light sensor, buzzer, give warning through buzzer and
vibrating vibrating motor. It should detect
motor, GPS and GSM light, if dark then LED should
module glow.
4 Automatic Path Ultrasonic sensor, It should detect the obstacle and
Finder servomotor for using ultrasonic should find the
ultrasonic, first possible path. Servo motors
servomotor for for wheel should
wheels, buzzer, LCD move to the path direction. Buzzer
to indicate the obstacle and LCD to
display the message
5 Water leakage Water sensor, Servo It should detect the leakage of
detector and motor, Buzzer, Reset water and start buzzer. Servo
Valve control Button, LCD or GSM motor will be used to demonstrate
module controlling of Valve. Reset button
to bring all at the normal state.
6 Keyless Lock Keypad, Temperature Keypad will be used to open the
System with sensor, buzzer, LCD, lock, motor can be used to
alarm motor demonstrate opening and closing
of lock.
Temperature sensor can be used to
detect any laser or similar method
to break the lock. Buzzer for
alarming during lock breaking.

<Subject Title> v
7 Health Temperature sensor, Body parameters will be checked
monitoring Humidity sensor, and compared with a fixed
system Heart rate, LCD, threshold
Buzzer range. Buzzer will indicate the
body parameters beyond threshold
range.
8 Automatic AC Temperature sensor, Based on the number of people in
Temperature Humidity sensor, the room and temperature or
control PIR humidity
Sensor, LCD, Buzzer variations, AC temperature will be
adjusted. Buzzer can be used to
indicate if temperature goes below
or
above than the given range. Hence
can be used as fire alarm system
also.
9 Automatic Switches, Buzzer, An internal clock module will be
Alarm LCD created. Based on the choice of
System for class button controller will understand
and Examination if it is
normal class day, exam day or
leave day. Accordingly the buzzer
timings
will be adjusted. LCD will display
the running clock, day choice and
buzzer on indication.
10 Automatic Light detector, Using light the system detects if
Alarm Buzzer, Servo motor, person is awake or sleeping. If its
System for switches late night buzzer rings. Internal
sleeping and clock will also
waking up control the buzzer timing in
morning.
Servomotors can be used to detect
light from all directions. Buttons to
set the timing of alarm.
11 Sleep Temperature, light This system keeps record of the
Monitoring detector, Co2 sleep with the help of light
System detector, condition, co2
LCD and temperature. LCD will show
how
much time person has slept in 24
hrs and based on that some
sleeping suggestions can be made.

<Subject Title> vi
12 Automatic IR sensor, Keypad, Vending machine dispenses a
Vending Motors, buzzer, LCD single item, when money is
Machine detected right by
IR sensor, and cost of number of
items matches. Motors can be used
to
demonstrate working of machine.
Buzzer for completion of
dispensing and LCD for cost of
items requested
13 Numerology Keypad, LCD, servo Based on DDMMYYYY data,
based motor, buzzer destiny number can be calculated.
Personality And the
wheel servo motor will turn the pointer
to the section of wheel, where the
personality related to that number
is shown.
14 Real time clock RTC Clock module, Alarm using RTC clock module
LCD, Switches,
Buzeer

<Subject Title> vii


Mini Weather Station

Abhiraman S(18ETEC004001) | Microprocessors and Microcontrollers |


19ECC214A | ECE – A

<Subject Title> viii


Introduction:
Capturing physical data in real-time is always fascinating. Arduino board mini
weather station is a mini weather station which is able to give live updates. In
this project, we will find three fundamental physical parameters for weather
predication temperature, humidity and atmospheric pressure and also
display the real-time data on a LCD screen. In the first part an array of
libraries has been included to keep the programming short and simple. The
Wire.h and SPI.h libraries are used because Wire.h is the one that allows the
Arduino to communicate with the I2C/TWI devices such as the BMP-280 and
the ST7735 LCD and SPI.h provides the serial peripheral interface with the
ST7735 LCD. In the second part, the sensors are initialized and the layout,
font colour, etc. of the LCD are set up for displaying the data as per ou r
preferences. In the final part, the output from the sensors are obtained and
displayed with a convenient delay between each reading to keep things
stable.

Software requirements:

Arduino IDE: The Arduino Integrated Development Environment is a cross-


platform application that is written in functions from C and C++. It is used to
write and upload programs to Arduino compatible boards, but also, with the
help of 3rd party cores, other vendor development boards.

Project equipment:

Following are the key components which will be used for our project:

1. Arduino NANO development board: The Arduino Nano is a small,


complete, and breadboard-friendly board based on the ATmega328
(Arduino Nano 3.x). It is used to process all the information of various
sensors connected to it for weather updates.
2. DHT-11 Temp Sensor: The DHT11 is a low-cost digital temperature and
humidity sensor with a single wire digital interface. It uses a
capacitive humidity sensor and a thermistor to measure the
surrounding air and spits out a digital signal on the data pin (no
analog input pins needed). The sensor is calibrated and doesn’t
require extra components so you can get the right to measuring
relative humidity and temperature. It is quite simple to use but
requires careful timing to grab data. You can only get new data from
it once every 2 seconds.
3. BMP-280 barometric sensor: It is an absolute barometric pressure sensor,
which is especially feasible for mobile applications. Its small dimensions

<Subject Title> ix
and its low power consumption allow for the implementation in battery-
powered devices.
4. 1.44” ST7735 series TFT LCD screen: It is used for the display of our
output.

Circuit and block diagram:


A combination of circuit diagram and block diagram has been provided
below. Tables for pin-out of the components is also mentioned in the
diagram. The 5V and GND pins of the ICSP header on Arduino NANO has been
utilised for supplying power to the components along with the on-board
power and ground pins. This has been done to do away with any additional
power source which will make the system bulky.

Block Diagram:

ALGORITHM:

I. Add serial peripheral interface, DHTXX sensor and Adafruit graphics


library.
II. Initialize serial peripheral interface, DHTXX sensor and Adafruit graphics
library.
III. Synchronize DHT sensor.

<Subject Title> x
IV. Initialize a ST7735S chip and set the background black.
V. Draw horizontal separation line at position (0, 15).
VI. Read temperature, humidity and pressure from the BMP280 sensor.
VII. Print temperature from BMP-280 sensor and print the Celsius symbol.
VIII. Set the value approximation and print the percentage symbol.
IX. Print humidity from DHT-11 sensor and move cursor to position (75,74)
pixel.
X. Print atmospheric pressure from BMP-280 and move cursor to
position (91,112) pixel.
XI. Print unit of atmospheric pressure as hector .
XII. Delay the program by 1 second before taking the next sensor.
XIII. Display the required output with the help of a ST7735 LCD.

Code:
#include <SPI.h> //include Serial Peripheral Interface library
#include <Wire.h> //include Two Wire Interface library
#include <Adafruit_GFX.h> // include Adafruit graphics library
#include <Adafruit_ST7735.h> // include Adafruit ST7735 TFT library
#include <Adafruit_BMP280.h> // include Adafruit BMP280 sensor library
#include "DHT.h" //include DHTXX sensor library
#define DHTPIN 2 //DHT11 data pin connected to arduino pin D2
#define DHTTYPE DHT11 //specifying the type of DHT sensor used
#define TFT_RST 8 // TFT RST pin is connected to arduino pin D8
#define TFT_CS 10 // TFT CS pin is connected to arduino pin D9
#define TFT_DC 9 // TFT DC pin is connected to arduino pin D10
// initialize ST7735 SERIES TFT library
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

// define device I2C address: 0x76 or 0x77 (0x77 is the library default address)
#define BMP280_I2C_ADDRESS 0x76

Adafruit_BMP280 bmp280; // initialize Adafruit BMP280 library


DHT dht(DHTPIN, DHTTYPE); // initialize DHT sensor

void setup(void)
{
dht.begin(); // synchronizing DHT sensor
tft.initR(INITR_144GREENTAB); // initialize a ST7735S chip, black
tab
tft.fillScreen(ST77XX_BLACK); // setting black background
tft.drawFastHLine(0, 15 , tft.width(), ST77XX_CYAN);// draw horizontal
seperation line at position (0, 15)

<Subject Title> xi
tft.setTextColor(ST77XX_CYAN, ST77XX_BLACK); // set text color to white
and black background
tft.setTextSize(1); // setting text size to 1
//tft.setCursor(4, 0); // move cursor to position (4, 0) pixel
//tft.print("ARDUINO + ST7735 TFT");
tft.setCursor(25, 5); // move cursor to position (25, 5) pixel
tft.print("WEATHER BUDDY");

// initialize the BMP280 sensor


if( bmp280.begin(BMP280_I2C_ADDRESS) == 0 )
{ // connection error or device address wrong!
tft.setTextColor(ST77XX_RED, ST77XX_CYAN); // set text color to red and
black background
tft.setTextSize(2); // setting text size to 2
tft.setCursor(5, 76); // move cursor to position (5, 76) pixel
tft.print("Connection");
tft.setCursor(35, 100); // move cursor to position (35, 100) pixel
tft.print("Error");
while(1); // stay here
}

tft.drawFastHLine(0, 55, tft.width(), ST77XX_CYAN); // draw horizontal


seperation line at position (0, 55)pixel
tft.drawFastHLine(0, 95, tft.width(), ST77XX_CYAN); // draw horizontal
seperation line at position (0, 195)pixel
tft.setTextColor(ST77XX_RED, ST77XX_BLACK); // set text color to red and
black background
tft.setCursor(30, 20); // move cursor to position (30, 20) pixel
tft.print("TEMPERATURE "); // setting heading for first section
tft.setTextColor(ST77XX_CYAN, ST77XX_BLACK); // set text color to cyan
and black background
tft.setCursor(40, 60); // move cursor to position (40, 60) pixel
tft.print("HUMIDITY "); // setting heading for second section
tft.setTextColor(ST77XX_GREEN, ST7735_BLACK); // set text color to green
and black background
tft.setCursor(40, 100); // move cursor to position (40, 100)
pixel
tft.print("PRESSURE "); // setting heading for third section
tft.setTextSize(2); // setting text size to 2
}

<Subject Title> xii


// main loop
void loop()
{

char _buffer[8];
// read temperature, humidity and pressure from the BMP280 sensor
float temp = bmp280.readTemperature(); // get temperature in °C
float hum = dht.readHumidity(); // get humidity in rH%
float pres = bmp280.readPressure(); // get pressure in hPa

// print temperature (in °C)


if(temp < 0) // if temperature < 0
sprintf( _buffer, "-%02u.%02u", (int)abs(temp), (int)(abs(temp) * 100) % 100 );
else // if temperature >= 0
sprintf( _buffer, " %02u.%02u", (int)temp, (int)(temp * 100) % 100 );// setting
the value approximation
tft.setTextColor(ST77XX_YELLOW, ST77XX_BLACK); // set text color to yellow
and black background
tft.setCursor(11, 34); // move cursor to position (11,34) pixel
tft.print(_buffer); // print temperature from BMP-280 sensor
tft.drawCircle(89, 34, 2, ST77XX_YELLOW); // print the degree symbol ( °
)(can be omitted if * is used instead)
tft.setCursor(95, 34); // move cursor to position (95,34) pixel
tft.print("C"); // print the Celcius symbol

// 2: print humidity (in %)


sprintf( _buffer, "%02u ", (int)(hum)); // setting the value approximation
tft.setTextColor(ST77XX_MAGENTA, ST77XX_BLACK); // set text color to
magenta and black background
tft.setCursor(45, 74); // move cursor to position (45,74) pixel
tft.print(_buffer); // print humidity from DHT-11 sensor
tft.setCursor(75, 74); // move cursor to position (75,74) pixel
tft.print("%"); // print the percentage symbol

// 3: print pressure (in hPa)


sprintf( _buffer, "%04u.%02u", (int)(pres/100), (int)((uint32_t)pres % 100) ); //
setting the value approximation
tft.setTextColor(ST77XX_ORANGE, ST77XX_BLACK); // set text color to orange
and black background
tft.setCursor(3, 112); // move cursor to position (3,112)pixel
tft.print(_buffer); // print atmospheric pressure from BMP-280

<Subject Title> xiii


tft.setCursor(91, 112); // move cursor to position (91,112)pixel
tft.print("hPa"); // print unit of atmospheric pressure as hecto
pascal

delay(1000); // wait 1 second before taking next sensor


reading
}

Output:
/home/builder/opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware
/home/builder/opt/arduino-builder/hardware -hardware /home/builder/.arduino15/packages -tools
/home/builder/opt/arduino-builder/tools -tools /home/builder/.arduino15/packages -built-in-libraries
/home/builder/opt/libraries/latest -logger humantags -fqbn arduino:avr:uno -build-cache /tmp -build-path
/tmp/466184284/build -verbose -prefs
runtime.tools.arduinoOTA.path=/home/builder/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -
prefs runtime.tools.avr-gcc.path=/home/builder/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-
atmel3.6.1-arduino5 -prefs
runtime.tools.avrdude.path=/home/builder/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -
prefs runtime.tools.arc-elf32.path=/home/builder/.arduino15/packages/Intel/tools/arc-elf32/1.6.9+1.0.1 -
prefs runtime.tools.core2-32-poky-linux.path=/home/builder/.arduino15/packages/Intel/tools/core2-32-
poky-linux/1.6.2+1.0 -prefs
runtime.tools.linuxuploader.path=/home/builder/.arduino15/packages/arduino/tools/linuxuploader/1.5.1 -
prefs runtime.tools.CMSIS-Atmel.path=/home/builder/.arduino15/packages/arduino/tools/CMSIS-
Atmel/1.2.0 -prefs runtime.tools.xtensa-lx106-elf-
gcc.path=/home/builder/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9 -prefs
runtime.tools.openocd.path=/home/builder/.arduino15/packages/Intel/tools/openocd/0.9.0+0.1 -prefs
runtime.tools.arm-linux-gcc.path=/home/builder/.arduino15/packages/arduino/tools/arm-linux-gcc/4.9.3 -
prefs runtime.tools.nrf5x-cl-tools.path=/home/builder/.arduino15/packages/arduino/tools/nrf5x-cl-
tools/9.3.1 -prefs
runtime.tools.esptool.path=/home/builder/.arduino15/packages/esp8266/tools/esptool/2.5.0-3-20ed2b9 -
prefs runtime.tools.mkspiffs.path=/home/builder/.arduino15/packages/esp8266/tools/mkspiffs/2.5.0-3-
20ed2b9 -prefs runtime.tools.dfu-util.path=/home/builder/.arduino15/packages/arduino/tools/dfu-
util/0.9.0-arduino1 -prefs
runtime.tools.CMSIS.path=/home/builder/.arduino15/packages/arduino/tools/CMSIS/4.5.0 -prefs
runtime.tools.bossac.path=/home/builder/.arduino15/packages/industruino/tools/bossac/1.7.0-
industruino -prefs runtime.tools.arm-none-eabi-
gcc.path=/home/builder/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4 -prefs
runtime.tools.sketchUploader.path=/home/builder/.arduino15/packages/Intel/tools/sketchUploader/1.6.2
+1.0 -prefs runtime.tools.x86-linux-gcc.path=/home/builder/.arduino15/packages/arduino/tools/x86-linux-
gcc/7.2.0 -prefs
runtime.tools.arduino101load.path=/home/builder/.arduino15/packages/Intel/tools/arduino101load/2.0.1
-prefs runtime.tools.flashpack.path=/home/builder/.arduino15/packages/Intel/tools/flashpack/2.0.0 -prefs

<Subject Title> xiv


runtime.tools.i586-poky-linux-uclibc.path=/home/builder/.arduino15/packages/Intel/tools/i586-poky-linux-
uclibc/1.6.2+1.0 -libraries /tmp/466184284/custom -libraries /tmp/466184284/pinned
/tmp/466184284/sketch_may15a

Sketch uses 22524 bytes (69%) of program storage space. Maximum is 32256 bytes.

Global variables use 737 bytes (35%) of dynamic memory, leaving 1311 bytes for local variables.
Maximum is 2048 bytes.

Conclusion
In conclusion it can be said that this project is quite economical and a handy
weather station that fits right in your pocket.

<Subject Title> xv
COURSE
CERTIFICATE

05/22/2020

Abhiraman S
N FO R E V
IO E
has successfully completed T

R
CA

YO
E DU
Introduction to the Internet of Things and

NE
Embedded Systems

TE
CO
an online non-credit course authorized by University of California, Irvine and offered

A
R

U
through Coursera S

C
E I
F
CERTI

Ian Harris
Professor
Department of Computer Science

Verify at coursera.org/verify/YMGFVDAUWBSB
Coursera has confirmed the identity of this individual and
their participation in the course.
COURSE
CERTIFICATE

05/22/2020

Abhiraman S
N FO R E V
IO E
has successfully completed T

R
CA

YO
E DU
The Arduino Platform and C Programming

NE
an online non-credit course authorized by University of California, Irvine and offered

TE
CO
through Coursera

A
R

U
S

C
E I
F
CERTI

Ian Harris
Professor
Department of Computer Science

Verify at coursera.org/verify/W3S5UWTDBKGJ
Coursera has confirmed the identity of this individual and
their participation in the course.
COURSE
CERTIFICATE

05/27/2020

Abhiraman S
N FO R E V
IO E
has successfully completed T

R
CA

YO
E DU
Interfacing with the Arduino

NE
an online non-credit course authorized by University of California, Irvine and offered

TE
CO
through Coursera

A
R

U
S

C
E I
F
CERTI

Ian Harris
Professor
Department of Computer Science

Verify at coursera.org/verify/N46FHZS85S4E
Coursera has confirmed the identity of this individual and
their participation in the course.

You might also like