You are on page 1of 51

A

PROJECT REPORT ON

Dashboard Online Connectivity


SUBMITTED IN
PARTIAL FULFILLMENT OF

DIPLOMA IN EMBEDDED SYSTEM DESIGN (PG-DESD)

BY

Siddhi Pratap Ghosalkar

AT
SUNBEAM INSTITUTE OF INFORMATION TECHNOLOGY,
HINJAWADI

1
SUNBEAM INSTITUTE OF INFORMATION TECHNOLOGY,
HINJAWADI.

CERTIFICATE
This is to certify that the project

Dashboard Online Connectivity


Has been submitted by

Siddhi Pratap Ghosalkar

In partial fulfillment of the requirement for the Course of PG Diploma in


Embedded System Design (PG-DESD AUG2019) as prescribed by The
CDAC ACTS, PUNE.

Place: Hinjawadi Date: 30-JAN-2020

Authorized Signature

2
ACKNOWLEDGEMENT

I take this opportunity to express my profound gratitude and deep


regard to Mr.Nilesh Ghule for their guidance, monitoring and constant
encouragement throughout the course of this project.Specially I want to
thank to Mr.Ganesh Gundre for the guidance throughout our project.The
blessing, help and guidance given by them from time totime shall carry us a
long way in the journey of life on which we are about to embark. I want to
thank all the teachers for providing a solid background for our studies and
research thereafter. They have been great sources of inspiration to us and I
thank them from the bottom of my heart. I am highly indebted to all lab
faculty of Sunbeam Institute Of Information Technology,
Hinjewadi for all the valuable suggestions and information given by them in
their respective field.
I would like to thank my project partner to believe in us and for
doing all the hard work throughout the project.I would like to thank all my
friends, specially my classmates who have supported much throughout these
six months of our journey in Sunbeam, through their true friendship and
companionship. I will miss all the time which we had spent together which
creates blossom of happy memories. I also like to thank our respective
families. Finally, I humbly bow our head with utmost gratitude before the
God who gives me strength to make all this possible.

Siddhi Pratap Ghosalkar


Sunbeam Institute Of Information
Technology,
Hinjewadi .

3
ABSTRACT
Present Automobiles are being developed by more of electrical parts
for efficient operation. Generally a vehicle was built with an analog driver-
vehicle interface for indicating various vehicle status like speed, fuel level,
Engine temperature etc., This project presents the development and
implementation of a digital driving system for a semi-autonomous vehicle to
improve the driver-vehicle interface. It uses an AVR based data acquisition
system that uses ADC to bring all control data from analog to digital format
and visualize through LCD. The communication module used in this project
is embedded networking by CAN which has efficient data transfer. It also
takes feedback of vehicle conditions like Engine temperature etc., and
controlled by main controller. Additionally this unit equipped with android
application which helps to access data on owners mobile.
Keywords: ECU (Engine Control Unit), CAN (Controller Area Network),
Embedded C, Android application.

4
INDEX
1. INTRODUCTION 8
1.1 Introduction 8
1.2 Overview of Project 10
2. LITERATURE SURVEY 11
2.1 Analysis of operating parameters of vehicles by CAN bus. 12
2.2 . Design of Vehicle Bus Data Acquisition and Fault Diagnosis 13
System using CAN
2.3 . Implementing a Distributed High-Resolution Real-Time Clock 14
using the CAN-Bus
2.4 . Modular CAN-Bus-System for small vehicles 15
2.5 IoT System for Anytime/Anywhere Monitoring and Control of 16
Vehicles’ Parameter
3. PROJECT ARCHITECTURE 18
3.1 Block diagram 20
3.2 Flowchart 21
4. HARDWARE DESCRIPTION 24
4.1 AVR board 24
4.2 LCD 25
4.3 LM35 26
4.4 MCP2515 28
4.5 NodeMCU 30
4.6 RTC-DS1307 31
5. SOFTWARE REQUIREMENTS AND SPECIFICATIONS 32
5.1 Android studio 32
5.2 Arduino IDE 33
5.3 Pycharm community 34
5.4 Minicom 34
5.5 Eclipse 35
5.6 AVRdude Toolchain 36
5.7 Arduino Toolchain 36

5
6. SOURCE CODE EXPLAINATION 37
6.1 CAN functions 37
6.2 UART functions 38
6.3 LCD functions 39
6.4 SPI functions 39
6.5 RTC functions 40
6.6 I2C functions 41
6.7 LM35 functions 42
6.8 NodeMCU functions 43
7. TESTING 44
7.1 CAN Transmitter output 44
7.2 CAN Receiver output 45
7.3 Application output 47
8. FUTURE SCOPE 48
9. CONCLUSION 49
10 REFERNCES 50
.

6
LIST OF TABLES
Section Table Title Page
1. Literature Survey 11

LIST OF FIGURES

Section Figure Title Page


1 Block diagram 20
2 Flowchart 21
3 Intefacing of AVR and LM35 22
4 Interfacing of AVR and NodeMCU 22
5 Interfacing of AVR and LCD 23
6 ATMega32 pins 25
7 Embedded market board 25
8 16 x 2 LCD 26
9 LM35 sensor 26
10 MCP2515 module 29
11 NodeMCU 30
12 DS1307 module 31
13 Android studio logo 32
14 Arduino IDE logo 33
15 Pycharm logo 34
16 Eclipse logo 35
17 CAN transmitter output 44
18 CAN receiver output 45
19 Dashboard output 46
20 Application output 47

7
INTRODUCTION

With rapidly changing computer and information technology and


much of the technology finding way into vehicles. They are undergoing
dramatic changes in their capabilities and how they interact with the drivers.
Although some vehicles have provisions for deciding to either generate
warnings for the human driver or controlling the vehicle autonomously, they
usually must make these decisions in real time with only incomplete
information. So, it is important that human drivers still have some control
over the vehicle.

Advanced in-vehicle information systems provide vehicles with


different types and levels of intelligence to assist the driver. The introduction
into the vehicle design has allowed an almost symbiotic relationship
between the driver and vehicle by providing a sophisticated & intelligent
driver-vehicle interface through an intelligent information network.

A vehicle was generally built with an analog driver vehicle interface


for indicating various parameters of vehicle status like temperature, pressure
and speed etc. To improve the driver-vehicle interface, an interactive digital
system is designed. A microcontroller-based data acquisition system that
uses ADC to bring all control data from analog to digital format is used.
Since the in-vehicle information systems are spread out all over the body of
a practical vehicle, a communication module that supports to implement a
one stop control of the vehicle through the master controller of the digital
driving system.

In Vehicle system automotive electrical architectures consists of


electronic control units (ECU) carries a variety of control functions. In
vehicle system greater safety, more comfort, convenience, pollution control
and less fuel consumption are main concern. In modern vehicle many
electronic control units (ECU) are present for various subsystems. these are
airbags, antilock braking, engine control, audio systems, windows, doors,
mirror adjustment etc.

8
Subsystems are independent or dependent & communications among
dependent sub systems is essential.Traditional systems also satisfy the main
need of vehicle automation but they lag to reduce wiring complexity &
reliability issue. In vehicles networking protocols must satisfy requirements
which include, significant reduction of wiring complexity, reducing body
weight and costs, improving the efficiency of fault diagnosis, low latency
times and configuration flexibility and enhancing the level of intelligent
control.

Different protocols are being used in vehicle automation like Zigbee,


LIN, CAN. They vary in speed, reliability & flexibility. CAN is the
differential bus protocol therefore the overall noise introduced in the bus is
gets eliminated. LIN is a serial network protocol in which single wire is
used. Due to one wire protocol its difficult to eliminate the noise from data.
Therefore, it is better to use two wire protocol like CAN where elimination
of the noise is possible and easy. The cost of this bus is higher than LIN but
still worth of using it. The arbitration is done at bus where LIN supports the
master slave protocol.

9
OVERVIEW
This project is about a dashboard of a vehicle. The dashboard of a
vehicle shows parameters like date, time, humidity, temperature, speed, etc.

The aim of this project is to create the dashboard of a vehicle by using


ATmega32 and LCD through CAN bus. And connecting that dashboard
online by using IoT.

In this project, CAN Bus is used to communicate between two


ATmega32 microcontrollers. One ATmega32 acts as a transmitter which
transmits data from sensor to other ATmega32 which acts as a receiver. On
the receiver side, data is displayed on LCD. Real Time Clock is used to get
date and time.

In this project we use CAN protocol. A Controller Area Network bus


is a robust vehicle bus standard designed to allow microcontrollers and
devices to communicate with each others applications without a host
computer. We use CAN Bus to communicate between two ATmega32
microcontrollers. One acts as a transmitter which transmits data to other
which acts as a receiver. We display that data on LCD. We use Real Time
Clock to get date and time.By using IoT, we upload the data on MySQL
database and using the android application, owner of vehicle can access that
data.

10
LITERATURE SURVEY
From going through various research papers, we can establish that
significance work has been done in this field of research.Various methods
are used in them are as follows.

Sr. No. Title Technology


1. Analysis of operating CAN, Electronic Control
parameters of vehicles via Units (ECU).
can bus.

2. Design of Vehicle Bus ARM7, CAN protocol, GSM


Data Acquisition and technology, Sensor
Fault Diagnosis System
using CAN.

3. Implementing a CAN,GPS satellite receive


Distributed High-
Resolution Real-Time
Clock using the CAN-
Bus.

4. Modular CAN-Bus- Modular CAN Bus.


System for small
vehicles.

5. IoT System for Internet of Things, Bluetooth


Anytime/Anywhere Low Energy, Wireless Sensor
Monitoring and Control Networks
of Vehicles’ Parameter.

Table 1 : Literature Survey

Lets go through all the research papers one by one and what they have done.

11
1, Analysis of operating parameters of vehicles via can bus :

Intensive electronification and higher complexity of vehicles


necessitates the use of data buses in vehicles. These buses are used for
information exchange between control units. Information on the bus is in the
form of data messages whose structure is defined by the relevant standards.
In the data contained on the communication line there is commonly
information about a vehicle operating parameters such as vehicle speed,
engine speed, fuel consumption etc. The aim of this paper is to analyze the
data communication on the CAN-Bus of a truck.

For the analysis of the data communications bus CAN-Bus was used
truck DAF XF 105.460 EEV. Selected technical parameters of the vehicle
are shown in Tab. 1: DAF XF 105.460 engine parameters. The car has
several mutually independent communication networks CAN-Bus, namely
the V-CAN 1 (Vehicle) and V-CAN 2, the I-CAN (Instrument), the D-CAN
(Diagnosis) and BB-CAN (Body Builder).

All these CAN data buses are connected in central processing unit
MENDELNET 2013 .VIC-3 (Vehicle Intelligence Centre), where all
information are coordinated. Data bus systems in this truck meet worldwide
standard for communication (SAE J1939/21 – cabling + network, and SAE
J1939/71.

Reading of data messages has been implemented using LabVIEW


software and measurement software NI MAX (Measurement and
Automation Explorer) from National Instruments (NI). As a hardware was
used CAN-Bus interface NI USB-8473. This interface was connected via
auxiliary cable directly to the OBD connector. After connecting the
hardware to the OBD diagnostic connector was set up the software. In the
next step, after preparation of measuring device has been switched on the
ignition of the truck. At this moment has been triggered messages recording
from CAN-Bus in the program NI MAX. It was also possible to observe
messages directly in the list of messages (see Figure 4). Here you can find
basic information about the messages on the bus. In the first column of the
overall view of messages are message identifiers (Arb.ID) in the hexagonal
form.

12
After conversion to decimal form it could be found appropriate
message and information contained therein in datasheet for SAE J1939
standard. File with messages was saved to HDD in „csv“ format. After
starting the engine of the vehicle subsequently was higher number of
messages which was available on the bus.

2. Design of Vehicle Bus Data Acquisition and Fault Diagnosis System


using CAN :

The vehicle bus data acquisition and fault diagnosis system, focusing
on its lower computer system and the upper computer system is designed.
This system is based on the widely used CAN bus technology, to extract the
vehicle's status or fault information. When the vehicle breaks down, the
status of vehicle will be sent as SMS to the control system using GSM
technology. In automotive electronics, engine fault detect units, engine
temperature sensors, air bag release-systems and battery low level detect
system etc. are connected using CAN with bit rates up to 1 M bit/s

With the continuous development of industrial, automotive


technology and electronics technology has also made great progress. The
structure of vehicles become more complex, increasing the degree of
automation is increasing, and the network of the body are also increasing in
the major car manufactures. This system is based on the widely used CAN
bus technology, to extract the vehicle's status or fault information. The
increasing complexity of automotive electronic control system makes
automotive fault diagnosis and maintenance work more difficult. In the way,
we need more skilled technicians and more advanced device to detect and
maintain fault. They are also using GSM technology for sending information
of BUS status when fault is detected.

In the implementation of our prototype system, vehicle interior


network structure can use topology bus network, all the electrical systems
nodes inside the bus vehicle are attached to the CAN bus through their own
respective CAN communication module. Here we are using one slave and
one master. CAN/SMS Wireless Gateway not only be used to organize and
coordinate all the interior electrical systems nodes, but also can be used as

13
internal and external communications data interface. It gathered up the
information from all the interior electrical systems nodes sent to the remote
monitoring service center computer via SMS wireless module. This paper
focuses on bus data acquisition and remote monitoring system based on
CAN bus and SMS, which can be used to improve the efficiency of
monitoring, to maintain the system security, to lower the maintenance costs
as well as the operating expensed. With the development of the mobile
technology, the design will be made better; the data transmission based on
wireless communication will be used more widely. The communication
network designed is able to stay stable in a long run in the experiment and
meets the expected target. Here, Keil cross compiler will be used for
building the applications. LPC2148 development board will be used to test
the built application. Flash magic software is used to dump the .Hex file in
to the Microcontroller.

3. Implementing a Distributed High-Resolution Real-Time Clock using


the CAN-Bus :

Many time critical applications, e.g. measurement devices, require a


real-time clock with an accuracy in the order of microseconds. In a
centralised system this is easy to implement with standard timer devices, but
in a distributed system (like a number of sensor and actor nodes connected
via the CAN-bus) this is more difficult as there is no global system tick. This
problem can be solved by synchronising the local clocks of all nodes with a
sufficient accuracy. The tight timing guaranties of a CAN-network offer a
simple and cheap possibility to provide such a global clock without
additional hardware. The real-time group of GMDs CREW Project has
designed and implemented a clock synchronisation protocol on the CAN-bus
that provides a global time base with an accuracy of about 20 microseconds.
The protocol is simple and hardware-independent. It uses only a small
amount of bandwidth (< 20 messages/second) and works with a single,
arbitrary CAN-object. If necessary, e.g. in large scale networks, the protocol
can be synchronised with an external time-base, like a GPS satellite receiver.

This paper proposes a simple protocol that synchronises the local


clocks of nodes connected to a field bus, especially a CAN-bus. All
participating nodes have local clocks with possibly different accuracies. The
local clocks are probably implemented using the usual timer facilities of the

14
standard microcontrollers. Thus, the typical accuracy of these clocks is in the
order of microseconds.

One clock on the network is assumed to be the dedicated 'master'


clock. The remaining clocks in the network, called 'slaves', are synchronised
to the value of the master clock. The master can be a free running clock if
only an internal synchrony of the connected nodes is desired.
If instead synchrony with the absolute time of the real world is
needed, the master has to be synchronised to an external time provider, like
e.g. a GPS satellite receiver.

The protocol relies on three basic assumptions about the network, the
controller hardware, and the involved software. The presented approach is
not restricted to the CAN-bus, but it can be used on every network that
fulfils the following requirements:

1. A successfully sent frame arrives at all nodes with a fixed and known
delay. This means, the underlying network has to be a broadcast
network. The delay may be approximated as zero, constant, or even a
function of the receiving node.
2. The delay from the transmission and reception of a frame to an interrupt
service routine that timestamps this event is known and has only a very
small variance. Again, this delay and its variance may be functions of
the receiving node.
3. A time bound for the maximum time between two valid synchronisation
messages tmax can be guaranteed.

4. Modular CAN-Bus-System for small vehicles :

One of the expensive parts in a 2- or 3-wheeler vehicle is the cable


tree for the electric equipment including modern information displays.
Actors and sensors have to be placed in different locations within the
vehicle. Until now, the use of modern communication hardware was not
useful in small vehicles due to the high costs. This paper will show that the
use of a CAN-Bus-System leads under certain circumstances also in small
vehicles to a cost reduction in the production and for maintenance.

15
The implementation of a cable tree into small vehicles can be more
complex than into a normal car. Small vehicles have less space but an
increasing amount of electric actors and sensors. The employment of fast
communication lines (e.g. CAN-Bus) seemed to be not cost-effective up to
now due to the expensive hardware. But the use of the CAN-Bus for small
vehicles has the same advantages as for a normal car: Advantages of a CAN-
Bus environment are:

 extremely free of electromagnetical interference (because of


differential signals) and automatic failure protocols,

 very high flexibility for the control electronics and for further
modifications,

 high speed applications (up to 1MBit/s),

 possible cost and weight reductions because of non-complex cable


tree and connectors (2 cables for CAN-Bus signals, 2 cables for the
power supply),

 higher service comfort and less maintenance costs due to the module
structure,

The higher costs of a Modular CAN-Bus-System depend on the


necessary development of new hardware components. By the utilization of
all advantages of the Modular CAN-Bus-System it will be possible to get a
higher quality of the performance of small vehicles and at the same time get
a reduction / compensation of the increase of costs.

5. IoT System for Anytime/Anywhere Monitoring and Control of


Vehicles’ Parameter :

This paper presents an IoT (Internet of Things) system designed to


allow the monitoring and control of parameters of the users’ vehicles,
anytime and anywhere in the world, through the Internet. The system
prototype was developed and tested using an electric vehicle (EV) and the
respective sensor systems. The main components of the proposed IoT

16
system are: a Bluetooth Low Energy (BLE) intra-vehicular wireless sensor
network (IVWSN); a mobile device that acts both as the vehicle’s gateway,
connecting the IVWSN to the Internet, and as the vehicle’s human machine
interface (HMI); an online server/database, based on Firebase; a client,
which can be either a mobile device or a personal computer; and a
residential wireless sensor network (WSN). The use of a wireless network to
collect sensor data inside of the vehicle introduces some advantages when
compared with conventional wired networks, whereas the inclusion of a
residential WSNs in the proposed IoT architecture allows the provision of
additional features, such as automatic control of the EV battery charging
process. Experimental results are provided to assess the performance of the
developed IVWSN and HMI.

The main components of an IoT system usually are [4]: 1) Embedded


sensor/actuator devices (the “things” in IoT); 2) A gateway (also called hub),
which is required when the embedded devices do not have native IP
connectivity; 3) An Internet service/database running on an online Web
server; 4) One or more clients (either app or browser-based), for the users to
interact with the service via mobile phones, tablets or personal computers
(PCs). The gateway has two main functions: 1) Translate the packets
between the embedded device protocols (e.g., ZigBee, Z-Wave and/or
Bluetooth) and the TCP/IP protocol; 2) Provide access to the Internet. In
many cases the gateway can be co-located with the local Internet router,
sharing the utilization with conventional (non IoT) traffic such as Web
browsing.

The main components of the proposed IoT system for vehicles (Fig. 2)
are an intra-vehicular wireless sensor network (one per vehicle), the
vehicle’s gateway and HMI, which connects to the Internet, an online
server/database (which may serve several users/vehicles), a client mobile
app and the user’s home WSN, which is also connected to the Internet

All the above papers have their respective pros and cons.After
refering and studying above research papers,we had idea of how to do the
project,what we can use in this project.After studying above research papers,
we decided to use CAN protocol for transferring data, RTC to get the date
and time and IoT to connect our dashboard online.

17
PROJECT ARCHITECTURE

The architecture of the project is quite simple. As shown below every


node is connected to CAN bus trough the MCP2515 CAN-SPI module. This
module is connected to AVR ATMega32 through the SPI bus because CAN
port is not available on Atmega32. The temperature sensor LM35 is
connected to AVR through ADC which converts the analog temperature into
digital temperature reading and transmit it over the CAN bus using
MCP2515. Also RTC-DS1307 module is connected to the same AVR
through I2C. Using that date and time are transmitted over CAN bus using
MCP2515. Main controller is in the receiver mode where it receives the data
from CAN bus and differentiate it by using the ID of the received message.
Every Message ID is unique and having its own unique functionality. This
make controlling action simpler for main controller. In project that data is
displayed on the LCD and also send to NodeMCU. From NodeMCU data is
uploaded on MySQL database. Using android application, we can access the
data anywhere.

The NodeMCU(ESP8266) post request data to website, for this


HTTP(The Hypertext Transfer Protocol) protocol is used. HTTP works as a
request-response protocol between a client and server. Each Hypertext
Transfer Protocol (HTTP) message is either a request or a response. A server
listens on a connection for a request, parses each message received,
interprets the message semantics in relation to the identified request target,
and responds to that request with one or more response messages. A client
constructs request messages to communicate specific intentions, examines
received responses to see if the intentions were carried out, and determines
how to interpret the results. For this, there are two commonly used methods
GET and POST for request and respond between client and server. GET

18
Requests data from a specified resource and POST  Submits data to be
processed to a specified resource. MYSQL is used as a database at the
webserver and PHP is used to fetch data from the database.

Our application will communicate with the PHP page with necessary
parameters and PHP will contact MYSQL database and will fetch the result
and return the results to us.

To access data from MySQL database to android application we created


REST API's using Python language. After writing API query them using
HTTP GET request and parse the result.For returning the data we are using
JSON format.

To access data on android application following steps are done:

Used Android studio IDE to create an Android application and name it as


PHPMYSQL under a package com.example.sunbeam

Modify src/MainActivity.java file to add Activity code.

Create src/LoginActivity.java file to add MYSQL code.

Modify layout XML file res/layout/activity_main.xml add any GUI


component if required.

Modify res/values/string.xml file and add necessary string components.

Modify AndroidManifest.xml to add necessary permissions

Run the application and choose a running android device and install the
application on it and verify the results.

19
Block Diagram :

Fig 1: Block diagram

The overall connections of project are as above.Two ATMega32 are


connected through CAN bus.One ATMega32 is connected to LM35 sensor
and RTC module.Other one is connected to LCD and NodeMCU.The data
from NodeMCU is updated on MySQL database and that data is accessed
through android application.

20
Flowchart :-

Fig 2: Flowchart

21
The pins connections of a project is as follows.

1. AVR to LM35 and RTC module interfacing :

LM35 sensor is connected to ATMEGA32’s PA0 pin.


SDA pin of RTC DS1307 is connected to PC1 pin and
SCL is connected to PC0.

Fig 3: Interfacing of AVR and LM35 and RTC

2. AVR to NodeMCU interfacing :

ATMega32 is connected to NodeMCU through


UART.TXD pi n of ATMega32 is connected to
RX pin of NodeMCU.

Fig 4: Interfacing of AVR and NodeMCU

22
3. AVR to LCD interfacing :

LCD pins are connected to ATMega32 as given below:

RS ---PA5
RW---PA6
E---PA7
D4---PA0
D5---PA1
D6---PA2
D7---PA3

Fig 5: Interfacing of AVR and LCD

23
HARDWARE DESCRIPTION
AVR BOARD:
AVR Development Board is an exclusive general-purpose development
board for the AVR family. The intention of the design is to endorse the
engineers and scholars to exercise and explore the capabilities of AVR
microcontrollers with many communication protocol ease. It uses AVR
studio for design and development .It integrates on board USARTs, LEDs,
keypads, an ADC input and LCD Display to create a stand-alone versatile
test platform. User can easily engage in development in this platform, or use
it as reference to application development.

Key Features of AVR Development Board :

40pin-ZIF Socket
8 Nos. Point LEDs (Logic Output)
8 Nos. Digital Input (DIP Switch)
4x4 Matrix Keypad
2X16 Character LCD (Background Light)
4 No's of Seven Segment Display
ADC with Analog Input Test (Potentiometer)
Stepper Motor Interface
DS1307 RTC with Batter-Backup
USART(RS232) for serial programming
ISP Device Programmer
Buzzer (Alarm), 3 Interrupts , Reset Button
EEPROM (SPI and I2C)
Digital Temperature Sensor(DS18S20)
PS/2

Study of Communication Protocols :

SPI
I2C
1-Wire
RS-232

Benefits of AVR Development Board :

24
Evaluate Real Time Applications
Supports Embedded C, ASM
ISP Programming | SPI | I2C Communications

Devices: ATMEGA8535, 8515, ATMEGA16, 32


Memory: 4-32KB FLASH - Program
Clock: 8MHz crystal, Max = 20 MHz

Fig 6: ATMega32 pins Fig 7: Embedded market board

LCD:

LCD modules are very commonly used in most embedded projects,


the reason being its cheap price, availability and programmer friendly. Most
of us would have come across these displays in our day to day life, either at
PCOs or calculators. The appearance and the pinouts have already been
visualized above now let us get a bit technical.

16A—2 LCD is named so because; it has 16 Columns and 2 Rows.


There are a lot of combinations available like, 8A—1, 8A—2, 10A—2, 16A
—1, etc. but the most used one is the 16A—2 LCD. So, it will have (16A—

25
2=32) 32 characters in total and each character will be made of 5A—8 Pixel
Dots.

Features of 16A—2 LCD module:

Operating Voltage is 4.7V to 5.3V


Current consumption is 1mA without backlight.
Alphanumeric LCD display module, meaning can display alphabets and
numbers.
Consists of two rows and each row can print 16 characters.
Each character is build by a 5Ak—8 pixel box.
Can work on both 8-bit and 4-bit mode.
It can also display any custom generated characters.
Available in Green and Blue Backlight.

Fig 8: 16 * 2 LCD

LM35:

LM35 is a temperature sensor that outputs an analog signal which is


proportional to the instantaneous temperature. The output voltage can easily
be interpreted to obtain a temperature reading in Celsius. The advantage of
lm35 over thermistor is it does not require any external calibration. The
coating also protects it from self-heating. Low cost (approximately $0.95)

26
and greater accuracy make it popular among hobbyists, DIY circuit makers,
and students.
Many low-end products take advantage of low cost, greater accuracy
and used LM35 in their products. Its approximately 15+ years to its first
release but the sensor is still surviving and is used in any products.

LM35 Temperature sensor Features:

Calibrated Directly in Celsius (Centigrade)


Linear + 10-mV/°C Scale Factor
0.5°C Ensured Accuracy (at 25A°C)
Rated for Full 55A°C to 150A°C Range
Suitable for Remote Applications
Low-Cost Due to Wafer-Level Trimming
Operates From 4 V to 30 V
Less than 60-I¼A Current Drain
Low Self-Heating, 0.08A°C in Still Air
Non-Linearity Only A±A¼A°C Typical
Low-Impedance Output, 0.1 I for 1-mA Load.

Fig 9: LM35 sensor

27
MCP2515:

MCP2515 Module adopts CAN controller MCP2515, and high-speed


CAN transceiver. Onboard independent key. Microchip MCP2515
independent CAN protocol controller, support CAN V2.0B regulation. The
connection between MCP2515 and MCU is through SPI.

Easily implement CAN Bus interface with any microcontroller having


SPI interface.

CAN SPI board is ideal for industrial automation, home automation as


well as in automotive and mobile machine industry. Board is designed to use
5V power supply only. Be careful to use voltage translators on
communication lines when connecting it to 3.3V systems.

CAN-BUS is a common industrial bus because of its long travel


distance, medium communication speed and high reliability. It is commonly
found on modern machine tools and as an automotive diagnostic bus. This
CAN-BUS module adopts MCP2515 CAN Bus controller with SPI interface
and TJA1050 CAN Bus transceiver to give your controller such as Arduino
CAN-BUS capability. For those who want to learn CAN Bus, this module is
your best choice to step into the CAN Bus world, please note that at least 2
pcs of CAN-BUS module are need to finish the CAN Bus Communication.

Specifications:

Support CAN 2.0B protocol


Use High-speed CAN transceiver TJA1050
Dimension: 40×28mm
SPI control for expand Multi CAN bus interface
8MHZ crystal oscillator
120Ω terminal resistance
Use serial port could view the communication data
With independent key, LED indicator, Power indicator
With power pin

28
Pinouts:

VCC :5V power input pin


GND : power ground pin
CS : SPI SLAVE select pin (Active low)
SO : SPI master input slave output lead
SI : SPI master output slave input lead
SCLK: SPI clock pin
INT: MCP2515 interrupt pin

Features:

Implements ISO-11898 standard physical layer requirements


Supports 1 Mb/s CAN operation
High speed SPI Interface (10 MHz)
Low current standby operation
Detection of ground fault on TXD input
An unpowered node or brown-out event will not disturb the CAN bus
Up to 112 nodes can be connected
Protection against damage due to short-circuit conditions
Affordable solution for adding CAN connectivity to any microcontroller
with SPI interface.

Fig 10: MCP2515 module

29
NodeMCU:

NodeMCU is an open source LUA based firmware developed for


ESP8266 wifi chip. By exploring functionality with ESP8266 chip,
NodeMCU firmware comes with ESP8266 Development board/kit.

Since NodeMCU is open source platform, their hardware design is


open for edit/modify/build.

NodeMCU Dev Kit/board consist of ESP8266 wifi enabled chip.


The ESP8266 is a low-cost Wi-Fi chip developed by Espressif Systems with
TCP/IP protocol. For more information about ESP8266, you can refer
ESP8266 WiFi Module.

There is Version2 (V2) available for NodeMCU Dev Kit i.e.


NodeMCU Development Board v1.0 (Version2), which usually comes in
black colored PCB.

NodeMCU Dev Kit has Arduino like Analog (i.e. A0) and Digital
(D0-D8) pins on its board.

It supports serial communication protocols i.e. UART, SPI, I2C etc. 

Using such serial protocols we can connect it with serial devices like


I2C enabled LCD display, Magnetometer HMC5883, MPU-6050 Gyro
meter + Accelerometer, RTC chips, GPS modules, touch screen displays, SD
cards etc.

30
Fig 11: NodeMCU

RTC-DS1307:

Real time clocks (RTC), as the name recommends are clock modules.
The DS1307 real time clock (RTC) IC is an 8 pin device using an I2C
interface. The DS1307 is a low-power clock/calendar with 56 bytes of
battery backup SRAM. The clock/calendar provides seconds, minutes,
hours, day, date, month and year qualified data. The end date of each month
is automatically adjusted, especially for months with less than 31 days.

Features:

 Programmable square wave output signal


 Automatic power-fail detect and switch circuitry
 Consumes less than 500nA in battery backup mode with oscillator
running
 Available in 8-pin DIP or SOIC
 Underwriters Laboratory (UL) recognized
 Real-time clock (RTC) counts seconds, minutes, hours, date of the
month, month, day of the week, and year with leap-year compensation
valid up to 2100
 56-byte non-volatile RAM for data storage
 Two-wire interface (I2C)

Fig 12: DS1307 module

31
SOFTWARE REQUIREMENTS AND
SPECIFICATIONS

ANDROID STUDIO:

Android Studio is an integrated development environment (IDE) from


Google that provides developers with tools needed to build applications for
the Android OS platform. Android Studio is available for download on
Windows, Mac and Linux.

The Android Studio IDE is free to download and use. It has a rich UI
development environment with templates to give new developers a
launching pad into Android development.

Android SDK Tools is a component for the Android SDK. It includes


the complete set of development and debugging tools for Android. It is
included with Android Studio.

Fig 13: Android studio logo

32
ARDUINO IDE:
Arduino IDE is an open source software that is mainly used for
writing and compiling the code into the Arduino Module.

It is easily available for operating systems like MAC, Windows,


Linux and runs on the Java Platform that comes with inbuilt functions and
commands that play a vital role for debugging, editing and compiling the
code in the environment. The main code, also known as a sketch, created on
the IDE platform will ultimately generate a Hex File which is then
transferred and uploaded in the controller on the board.

The IDE environment mainly contains two basic parts: Editor and
Compiler where former is used for writing the required code and later is
used for compiling and uploading the code into the given Arduino Module.
This environment supports both C and C++ languages.

Fig 14: Arduino IDE logo

33
PYCHARM Community:

PyCharm Community Edition is totally free and open-source,


available under the Apache 2.0 license. The feature set of this edition is
limited to support pure Python coding, while the major functionality and
complementary tooling is still there. Community Edition provides core
Python language support with code completion, one-the-fly code analysis,
refactorings, local debugger, test runner, virtualenv, version control
integrations, etc.

Fig 15: Pycharm logo

MINICOM:

Minicom is a communication program which somewhat resembles the


shareware program TELIX but is free with source code and runs under most
Unices. Features include dialing directory with auto-redial, support for
UUCP-style lock files on serial devices, a separate script language
interpreter, capture to file, multiple users with individual configurations, and
more.

minicom Common features:

=> Setting up a remote serial console


=> Access a computer / server if the LAN is down
=> Connect to embedded Linux / BSD device via null modem cable

34
=> Connect to Cisco routers for configuration
=> Connect to dump device i.e. device w/o keyboard and mouse
=> Dialing directory with auto-redial
=> Support for UUCP-style lock files on serial devices
=> Separate script language interpreter
=> Capture to file
=> Multiple users with individual configurations.

ECLIPSE:

Eclipse is an integrated development environment (IDE) used in computer


programming.  It contains a base workspace and an extensible plug-
in system for customizing the environment. Eclipse is written mostly
in Java and its primary use is for developing Java applications, but it may
also be used to develop applications in other programming languages via
plug-ins,including Ada, C, C++, C#,COBOL,
Fortran, Groovy, Haskell, JavaScript.

Fig 16: Eclipse logo

35
AVRdude TOOLCHAIN :

The AVR Toolchain is a collection of tools/libraries used to create


applications for AVR microcontrollers. This collection includes compiler,
assembler, linker and Standard C and math libraries.

ARDUINO TOOLCHAIN :

Arduino IDE distribution contains complete set of compilers, libraries and


tools to build any AVR firmware. For debugging purposes one can use this
with powerful open source, cross platform, free C, C++.

36
SOURCE CODE EXPLANATION

 CAN functions: -
1. INT8U begin(INT8U speedset, const INT8U clockset =
MCP_8MHz): -
This is the setup function of the CAN module. The
speed and the controller CPU clock speed are given as
parameter to the function. This function sets the register
of the MCP2515 and confirms the setting through
register and returns the status code.
2. INT8U sendMsgBuf(INT32U id, INT8U ext, INT8U len, INT8U
*buf)

This function is use to send message string over the bus. The id
defines the message id and also where id filter is used then it acts as
differentiator for receivers. If single receiver receives the messages then id is
use to differentiate the message. Ext is flag bit which defines whether the
CAN frame will be simple or extended. Buffer is a string message buffer
which contains the readings of temperature sensor.

3. INT8U readMsgBuf(INT8U *len, INT8U *buf)

This function is receiving the message from MCP2515 through SPI


into the controller. Buffer contains the message that has been send by
transmitter.

4. INT8U checkReceive(void)

37
This check the buffers of the MCP2515 and returns the status of the
message i.e. buffer has message or it is empty. This function is used for the
polling for the message at the receiver side.

5. INT8U checkError(void)

CAN frame contains CRC code at the end of the frame. This code is
use to detect whether received message is error-free or it gets corrupted. If
message is corrupted then that message has been discarded and receiver can
ask for retransmission of the message.

6. INT32U getCanId(void)

This function is use at receiver side to determine the ID of the


received message. According to the ID necessary action will performed by
the controller of receiver.

 UART Functions: -

1. void uart_init(uint32_t baud);

The very first thing needed to do is initialization of the UART


module.This function does the UART initialization. We just have to pass the
baud rate to the function.The rest of the configuration parameters are the
most common UART configuration - 8N1 - 8 data bits, no parity and one
stop bit. uart_init() sets the baud rate and enable transmitter and receiver.

Argument: Baud rate which we want to set. It returns void.

2. void uart_puts(char str[]);

To write the data on UART, this function is used. The data is written
char by char till the null char on UDR register. The UDR register contains
the data to be transmitted or the data that has been received.
Argument: String which we want to write. It returns void.

38
 LCD Functions:-

1. void lcd_init(void);

This function is used to initialize the LCD. This function sets the data
pins and control pins as output. It sets 4-bit mode, 2 line, 5x10 font LCD by
sending command. It also turns on the display, turn off the cursor and turn of
the blink of LCD. Last thing it does, is clear the LCD display.

2. void lcd_puts(uint8_t line, char *str);

This function is used to write the data on LCD. It sets the line address
which we have passed and write the char data one by one.

Argument 1: The line address of LCD on which we want to write.


Argument 2: The data in the form of string which we want to write. It returns
void.

3. void lcd_print_xy(char row, char pos, char* str);

This function is also writing the data on LCD. But this is basically to
mention the specific line number and position on that line, on which we
want to write.
This function will write the data on given position of given line number.

Argument 1: Number of rows on which we want to write the data.


Argument 2: Position of the row on which we want to write the data.
Argument 3: The data in the form of string which we want to write. It returns
void.

39
 SPI Functions :-

1. void spi_init_master(void);
This function is used for initialized the SPI master and the MCP2515
as a slave. This init the SPI buffer and the speed of the transmission is set.

2. unsigned char spi_tranceiver(unsigned char);

This function is used to transmit and receive the data over SPI bus.
SPI has single buffer therefore it works as trans receiver in the case of
transmission.

Argument 1: Data in byte format.

 RTC Functions:-

1. RTC_Init();

This function is used to Real Time Clock module DS1307


initialization.It initializes the I2C module and starts the I2C
communication.It connect to DS1307 by sending its ID on I2C bus.It select
the DS1307 control register to configure DS1307.It disables the SQW-OUT.

Prototype:
void RTC_Init(void);

2. RTC_SetDateTime(&rtc);

This function is used to set date and time in RTC.It starts the I2C
communication and connect to DS1307 by sending its ID on I2C bus.Then it
writes sec,min,hour,week day,date,month and year on I2c. It stops the I2C
communication.

Prototype:
void RTC_SetDateTime(rtc_t *rtc);
Argument 1:Pointer to the object of a structure.
It returns void.

40
3. RTC_GetDateTime(&rtc);

This function is used to get date and time in RTC.It starts the I2C
communication and connect to DS1307 by sending its ID on I2C bus.Then it
reads sec,min,hour,week day,date,month and year from I2c. It stops the I2C
communication after reading the date and time.

Prototype:
void RTC_GetDateTime(rtc_t *rtc);
Argument 1:Pointer to the object of a structure.
It returns void.

 I2C Functions:-

1. I2C_Init();

This function is used to initialize the I2C module.It sets the prescalar
bits to zero and sets the SCL frequency.Also it enables the TWI module;

Prototype:
void I2C_Init();

2. I2C_Start();

This function is used to generate I2C Start Condition. The I2C start
condition is SDA goes low when SCL is High.

Prototype:
void I2C_Start();

3. I2C_Stop();

This function is used to generate I2C Stop Condition. The I2C stop
condition is SDA goes High when SCL is High.

Prototype:
void I2C_Stop(void);

41
4. I2C_Write(0x80);

This function is used to send a byte on SDA line using I2C


protocol.The 8bit data is sent bit-by-bit on each clock cycle.MSB(bit) is sent
first and LSB(bit) is sent at last.Data is sent when SCL is low.

Prototype:
void I2C_Write(uint8_t v_i2cData_u8);
Argument 1:uint8_t-->8bit data to be sent.
It returns void.

5. rtc→month=I2C_Read(1);

This fun is used to receive a byte on SDA line using I2C protocol.The
8bit data is received bit-by-bit each clock and finally packed into
Byte.MSB(bit) is received first and LSB(bit) is received at last.

Prototype:
uint8_t I2C_Read(uint8_t v_ackOption_u8);
Argument 1:Acknowledgement.
It returns uint8_t(received byte).

 LM35 Functions:

1. lm35_Init();

This function is used to initialize ADC.It makes ADC port as a input.It


enables ADC and selects the channel.

Prototype:
void lm35_Init(void);

2. temp = lm35_Read(0);

42
This function is used to read the input data.It sets input channel to
read.It reads the bytes and return digital value.

Prototype:
int lm35_Read(int channel);
Argument 1:Channel number from which we want to
read the data.
It returns digital value of input data.

 NodeMCU (UART ) Functions :-

1. Serial.begin(9600);

This function sets the data rate in bits per second (baud) for serial data
transmission. For communicating with Serial Monitor, make sure to use one
of the baud rates listed in the menu at the bottom right corner of its screen.
You can, however, specify other rates - for example, to communicate over
pins 0 and 1 with a component that requires a particular baud rate.

Prototype:
Serial.begin(speed);

2. Serial.available();

Get the number of bytes (characters) available for reading from the
serial port. This is data that’s already arrived and stored in the serial receive
buffer (which holds 64 bytes).
Serial.available() inherits from the Stream utility class.

3. Serial.read();
This function reads the incoming data. It returns the first byte of
incoming data available.

43
4. Serial.println(value);
Prints data to the serial port as human-readable ASCII text followed
by a carriage return character (ASCII 13, or '\r') and a newline character
(ASCII 10, or '\n'). This command takes the same forms as Serial.print().
Println() returns the number of bytes written, though reading that
number is optional.

TESTING

CAN Transmitter :

1. We first prepare the code for CAN transmitter which will transmit
temperature, date and time to CAN receiver.
2. Then we burn that code hex file on ATMega32 board by using
following command.
Avrdude –c usbtiny –p atmega32 –U flash:w:can_tx.hex
3. We connect USB tiny to the board to check the output.
4. We got the following ouput after giving command sudo minicom on
VI editor.
5. This shows that message is sent successfully.

44
Fig 17: CAN transmitter output

CAN Receiver :

1. On the receiver side,the first step is same.We prepare a code for CAN
transmitter.
2. Then we burn the hex file of that code using following command.
Avrdude –c usbtiny –p atmega32 –U
flash:w:can_tx.hex
3. We connect the USB tiny to see the ouput.
4. After connecting the high pin of transmitter’s MCP2515 to the high
pin of receiver’s MCP2515 and the low pin of transmitter’s MCP2515
to the high pin of receiver’s MCP2515,We can get the following
ouput after giving command sudo minicom on VI editor.
5. This shows that message is sent successfully.

45
Fig 18: CAN receiver output

1. We connect the LCD to the board to see the output on it.


2. After making all the connections and giving supply to both the
boards,we can see the output on LCD as follows.

46
Fig 19: Dashboard output

Application :

1. We connect the CAN receiver’s TXD pin to the RX of nodemcu.


2. Then we upload the arduino code on nodemcu.
3. We prepare a server code in python. After uploading the arduino code,
we start that server.
4. We can see the temperature coming on serial monitor.
5. That temperature will get uploaded on MySQL database.

6. We can check the MySQL database by using following commands on


VI editor.
a) Sudo systemctl start mariadb.service
b) Mysql –u root –p
c) Use database_name;
d) Select * from table_name;
7. Then we prepare a code for android application using java
programming language and xml for the layout,which will access the
data from database.
8. We build the application and install it on android phone.

47
9. The application will look like this.

Fig 20: Application output

FUTURE SCOPE

The project has a very vast scope in future. Project can be updated in near
future as and when requirement for the same arises, as it is very flexible in
terms of expansion. The following are the future scope for the project.

 Extend this project to display other parameters like vehicle


speed,vehicle’s mileage, level of gas in tank, temperature of
engine, etc.

 Upload the application on play store.

48
 Set the date and time manually by using keypad.

 Add the functionality of controlling temperature in the


vehicle.

 Implement MQTT protocol instead of RESTful API to get


faster response and low power consumption.

49
CONCLUSION

This project introduces an embedded system with a combination of


CAN bus systems. Digital control of the vehicle is an important criterion of
modern technology. With the rapid development of embedded technology,
high-performance embedded processor is penetrated into the auto industry,
which is low cost, high reliability and other features to meet the needs of the
modern automobile industry.

The proposed high-speed CAN bus system solves the problem of


automotive system applications, also has a certain practical value and
significance. With AVR as the main controller and it makes full use of the
high-performance of AVR, high-speed reduction of CAN bus
communication control networks and instrument control so as to achieve full
sharing of data between nodes and enhance their collaborative work. This
system features efficient data transfer among different nodes in the practical
applications.

The ease of accessing performance statement of the vehicle such as


current temperature , date and time, etc. is achieved by implementing an
android application.

50
REFERENCES

1. https://www.tutorialspoint.com/android/android_php_mysql.htm

2.https://en.wikipedia.org/wiki/CAN_bus

3.Understanding and Using the Controller Area Network Communication


Protocol: Theory and Practice 2012 Edition, Kindle Edition

4.Building the Internet of Things: Implement New Buisness Model, Disrupt


Competitors, Transform Your Industry.

5.The avr microcontroller and embedded system using assembly and c.

51

You might also like