You are on page 1of 51

VEHICLE TO VEHICLE

COMMUNICATION USING RF & IR


TECHNOLOGY

A MAIN PROJECT REPORT


SUBMITTED IN PARTIAL FULFILLMENT OF THE
REQUIREMENTS FOR THE AWARD OF DEGREE OF

BACHELOR OF TECHNOLOGY
in
Electronics and Communication Engineering
of
APJ Abdul Kalam Technological University
by

ALAN SUDHISH VENGALI (VAS17EC009)


ARJUN A (VAS17EC027 )

(AN ISO 9001:2008 CERTIFIED INSTITUTION )

Department of Electronics and Communication


Engineering
Vidya Academy of Science & Technology
Thalakkottukara, Thrissur - 680 501
( http://www.vidyaacademy.ac.in)

JUNE 2022
Department of Electronics and Communication
Engineering
Vidya Academy of Science & Technology
Thalakkottukara, Thrissur - 680 501
(http://www.vidyaacademy.ac.in)

(AN ISO 9001:2008 CERTIFIED INSTITUTION )

Certificate
This is to certify that the Main Project Report titled “VEHICLE TO VEHI-
CLE COMMUNICATION USING RF & IR TECHNOLOGY” is a bonafide record
of the work carried out by ALAN SUDHISH VENGALI(VAS17EC009), ARJUN A
(VAS17EC027 ) of Vidya Academy of Science & Technology, Thalakkottukara, Thrissur
- 680 501 in partial fulfillment of the requirements for the award of Degree of Bachelor
of Technology in Electronics and Communication Engineering of APJ Abdul Kalam
Technological University, during the academic year 2021-2022. The Main Project re-
port has been approved as it satisfies the academic requirements in the respect of main
project work prescribed for the said degree.

Project Guide/Supervisor Head of Department


Mr. Sojan Francis P Dr. S Swapna Kumar
Asst. Prof., Dept. of ECE Prof., Dept of ECE

Project Coordinator
Mrs. Honey Mol P.K.
Asst. Prof., Dept. of ECE
Undertaking

We, ALAN SUDHISH VENGALI(VAS17EC009), ARJUN A (VAS17EC027 ),

hereby undertake that the main project work entitled “VEHICLE TO VEHICLE COM-

MUNICATION USING RF & IR TECHNOLOGY”, is carried out by us indepen-

dently under the valuable guidance of Mr. Sojan Francis P , Asst. Prof.,Dept. of Elec-

tronics and Communication, Vidya Academy of Science and Technology, Thalakkot-

tukara, Thrissur, in partial fulfillment of the requirements for the award of degree of

Bachelor of Technology in Electronics and Communication Engineering of APJ Ab-

dul Kalam Technological University, during the academic year 2021-2022.

ALAN SUDHISH VENGALI(VAS17EC009)


ARJUN A (VAS17EC027 )
Thrissur
JUNE 2022
VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Acknowledgement

During the course of our main project work several persons collaborated directly
and indirectly with us. Without their support it would be impossible for us to finish our
work. That is why we wish to dedicate this section to recognize their support.

We want to start expressing our thanks to our project guide Mr. Sojan Francis P
, Asst. Prof., Dept. of Electronics and Communication, because of her valuable advice
and guidance towards this work. We received motivation, encouragement and hold up
from her during the course of work.

We are grateful to express our thanks to all the faculty members of our department
for their support. We articulate our gratitude to all our friends for their support and help
for this work.

We are thankful to Dr. S Swapna Kumar, Head of Electronics and Communication


Engineering Department, and our Principal Dr. Saji C B, for their sole co-operation.

Last, but not the least we wish to express our gratitude to God Almighty for His
abundant blessings without which this effort would not have been successful.

ALAN SUDHISH VENGALI(VAS17EC009)


ARJUN A (VAS17EC027 )
Eighth Semester B.Tech (2018 Admissions)
Vidya Academy of Science & Technology
JUNE 2022 Thrissur - 680 501.

Electronics and Communication Engg. i VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Abstract

In the urban areas, most of the sound pollution are caused because of noisy environment
which is created by industrial machinery’s and vehicle horn. Among all the reasons
the vehicle horn is assumed most vital for making the noisy environment which has a
hazardous impact on the human health. Therefore, it is become graver to need a system
that is able to make the environment safe and sound. To confront this challenge, this
study proposes a V2V or Vehicle to Vehicle Communication System. In this study, the
V2V Communication has been accomplished using both Infrared and radio frequency
communication without using horn. IR transmitter which is used to transmit the signal
to front side vehicles and RF transmitter which is used to transmit the signal to both left
and right side vehicles are placed in front of the driver. Moreover, IR and RF receivers
are inserted behind the car to receive the corresponding transmitted signal from the other
vehicles. A speaker is used to alert the driver and a LCD is used to show from where
the transmitted signal has been come and the driver will decide where the car should
be moved. The whole functions of the system are processed by Arduino. The goal
of this work is to mitigate the vehicle noise to some extent and to reduce unnecessary
vehicle horn. This system can be used as a substitution of horn system in the populated,
emergency and busy places
The aim of V2V communication is to make a pollution free environment by allow-
ing vehicles in transit to send position and messages without making sound in traffic
congestion.

Electronics and Communication Engg. ii VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Contents

CERTIFICATE

UNDERTAKING

ACKNOWLEDGEMENT i

ABSTRACT ii

LIST OF FIGURES iv

LIST OF SYMBOLS AND ABBREVIATIONS v

1 INTRODUCTION 1
1.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Objectives of the Work . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Motivation for this work . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 SCOPE OF WORK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4.1 Benefits of the proposed system . . . . . . . . . . . . . . . . . . 3
1.4.2 Application of the Proposed System . . . . . . . . . . . . . . . . 3
1.5 Outline of the Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 LITERATURE REVIEW 5

3 METHODOLOGIES FOR THE PROJECT 8


3.1 SYSTEM DEVELOPMENT . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2 DESIGN OF PROPOSED SYSTEM . . . . . . . . . . . . . . . . . . . . 9

Electronics and Communication Engg. iii VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

4 HARDWARE SETUP 11
4.1 IR SENSOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1.1 Working Principle . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1.2 TSOP1738 Receiver . . . . . . . . . . . . . . . . . . . . . . . . 13
4.1.3 Pin out Description . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.2 RF MODULE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.2.1 Types of RF modules . . . . . . . . . . . . . . . . . . . . . . . . 15
4.2.2 Transmitter Modules . . . . . . . . . . . . . . . . . . . . . . . . 16
4.2.3 Receiver module . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.2.4 Transceiver modules . . . . . . . . . . . . . . . . . . . . . . . . 17
4.3 GPS MODULE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.3.1 Pin Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.3.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.3.3 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.4 I2C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

5 SOFTWARE ENVIRONMENT 22
5.1 PYTHON - IDLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.2 Arduino IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.3 How Arduino IDE works . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.4 Node MCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

PUBLICATIONS RELATED TO THIS WORK 26

BIBLIOGRAPHY 27

APPENDIX 28

Electronics and Communication Engg. iv VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

List of Figures

3.1 Block diagram of proposed v2v communication system . . . . . . . . . . 8


3.2 Block diagram of proposed v2v communication system . . . . . . . . . . 9

4.1 IR Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2 Pinout Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.3 RF Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.4 GPS module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.5 GPS Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.6 Voltage level controller . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

5.1 pythoncode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.2 code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.3 CODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.4 output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

Electronics and Communication Engg. v VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

List of Symbols and Abbreviations

RX Receiver

TX Transmitter

V2V Vehicle to vehicle

ITS Intelligent Transportation System

RF Radio Frequency
IR Infrared Frequency

LCD Liquid Crystal display

Hz HERTZ

Electronics and Communication Engg. vi VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Chapter 1

INTRODUCTION

1.1 General
Sound pollution is a significant environmental problem in rapidly developing cities. Ve-
hicle sound is probably the most rigorous and pervasive source of sound pollution among
other sources such as neighborhood, electrical appliances, TV and music systems, public
address systems, railway and air traffic and electricity generating sets. Most of the vehi-
cle noise are generated in traffic congestion which is caused by unnecessary honking of
vehicle horn. In most cases, driver irresponsibility is the main reason behind the vehicle
noise. Driver creates a hazardous situation by honking unnecessarily in traffic jam which
adversely effect in the human body. Researchers have found vehicle noise pollution to be
a major cause of several human defects like stress, unborn and effects on hearing. Over
the past few years researchers adopt some system that could mitigate the vehicle noise
in some extent. As computerized technology advances, there is a push towards Vehicle-
tovehicle Communication . Though vehicle to vehicle communication is mainly used
for traffic safety but this study presented a system which can be used as a substitute of
vehicle horn. In this system RF and IR communication has been used as a replacement
of vehicle horn. Every vehicle has been attached with a RF and IR Transmitter-Receiver
pair where RF transmitter and IR Transmitter are used to send the signal with a message
to the nearest vehicle.

Electronics and Communication Engg. 1 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

1.2 Objectives of the Work


Recent breakthroughs in science and technological innovations have led to an unprece-
dented advancement in provisions of technological solutions for the numerous problems
facing mankind. Researchers are busy leveraging on modern technology to provide better
and improved solutions commensurate to the ever increasing demands. Vehicle to Vehi-
cle Communication(V2V Communication) is the wireless transmission of data between
motor vehicles. The goal of V2V communication is to make a pollution free environment
by allowing vehicles in transit to send position and messages without making sound in
traffic congestion. The existing V2V Communication uses horn system which is a sound
making device that can be equipped to motor vehicles, buses, bicycles, trains and other
types of vehicles. The sound made usually resembles a “honk” which vehicle operator
uses the horn to warn others of the vehicle’s approach or presence or to call attention to
some hazard. Vehicle horns are usually electric driven by a flat circular steel diaphragm
that has an electromagnet acting on it and is attached to a contactor that repeatedly in-
terrupts the current to that electromagnet. This arrangement works like a buzzer or an
electric bell whose sound levels are approximately 107109 decibels . The advance model
of vehicle horn has been replaced by V2V Communication where depending upon the
technology is implemented, the vehicle’s driver may simply receive messages without
producing excessive amount of sound levels.

1.3 Motivation for this work


Noise pollution remains a major environmental health problem in the world, with the
transport sector being a major cause. Road traffic noise is the dominant source affecting
human exposure. Around 100 million people are exposed to road traffic noise. Noise
from road traffic alone is the second most harmful environmental stressor in the world,
behind air pollution, according to the World Health Organization (WHO). The harmful
effects of noise arise mainly from the stress reaction it causes in the human body, which
can also occur during sleep. These can potentially lead to premature death, cardiovas-
cular disease, cognitive impairment, sleep disturbance, hypertension and, at the least,
annoyance. The work presents a lot of considerations and improvements to remove ve-

Electronics and Communication Engg. 2 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

hicle horn system and replace the place of vehicle horn by using a V2V communication
system which can help to mitigate the excessive sound levels that roadside people face in
a traffic congestion area. The design uses two communication protocol to exchange both
radio Frequency and infrared ray communication technique has been used in this System.
RF transmitter and IR transmitter are placed in front of the driver and both receivers are
placed behind the vehicle. Receivers are attached with a Arduino which takes transmit-
ted signal that sends by the transmitters and read the signal to reproduce the messages.
A LCD is used to show the receiving messages and a buzzer is also used to draw the
attention of driver.

1.4 SCOPE OF WORK


The aim of V2V communication is to make a pollution free environment by allowing
vehicles in transit to send position and messages without making sound in traffic conges-
tion.

1.4.1 Benefits of the proposed system

• Sound pollution free environment.

• Avoid accidents.

• Vehicles gets fast notification

• System is secure and available

1.4.2 Application of the Proposed System

The application of the proposed system is to replace the existing vehicle horn using to
vehicle to vehicle communication. Using this we can send a direct message to vehicle.
In the curve roads it is used to find out if there is a car coming in the opposite direction.
Thereby avoiding accidents. This can also be used in emergency vehicles to send the
message to other vehicle to give them the way.

Electronics and Communication Engg. 3 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

1.5 Outline of the Report


This report contains 6 chapters. Chapter 1 gives the introduction to the project work
and describes the objectives of the work. Literature review is describes in Chapter 2.
Methodologies for the project is in chapter 3 . Chapter 4 describes about the hardwares
used in the project. Softwares used for programming is used described in chapter 5.
Conclusion and analysis of the project is in the chapter 6.

Electronics and Communication Engg. 4 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Chapter 2

LITERATURE REVIEW

In the urban areas, most of the sound pollution are caused because of noisy environment
which is created by industrial machinery’s and vehicle horn. Among all the reasons the
vehicle horn is assumed most vital for making the noisy environment which has a haz-
ardous impact on the human health. Therefore, it is become graver to need a system that
is able to make the environment safe and sound. To confront this challenge, this study
proposes a V2V or Vehicle to Vehicle Communication System. In this study, the V2V
Communication has been accomplished using both Infrared and radio frequency commu-
nication without using horn. IR transmitter which is used to transmit the signal to front
side vehicles and RF transmitter which is used to transmit the signal to both left and right
side vehicles are placed in front of the driver. Moreover, IR and RF receivers are inserted
behind the car to receive the corresponding transmitted signal from the other vehicles. A
speaker is used to alert the driver and a LCD is used to show from where the transmitted
signal has been come and the driver will decide where the car should be moved. The
whole functions of the system are processed by Arduino. The goal of this work is to
mitigate the vehicle noise to some extent and to reduce unnecessary vehicle horn. This
system can be used as a substitution of horn system in the populated, emergency and busy
places.
The field of automated vehicle technology is developing rapidly developing. Automated
vehicles can improve traffic safety, balance traffic flows, maximize road usage by offer-
ing driver warnings and/or assuming vehicle control in dangerous situations, as well as
provide motorists with the best end-to-end transportation experience and reduce emis-
sions, which are the most important goals of modern smart traffic control infrastructures.

Electronics and Communication Engg. 5 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Exchanging data and integration of such systems with Vehicle-to-Vehicle (V2V) may be
a keystone to successful readying of vehicular ad-hoc networks (VANETs) and will sim-
ply be the following step of this evolution, with dynamic period of time data exchange
between all the players of the traffic dominant system and fostering cooperative urban
quality. One of the applications of this concept is to provide vehicles and roads with the
ability to make road time more enjoyable and also to make roads safer. These applications
are typical examples of what an Intelligent Transportation System (ITS) is called. The
area of vehicle to vehicle (V2V) technology is speedily developing and to addressing the
transportation needs of citizens symbolizes the furtherance of technology and economic
growth. Global mobility and development of many cities have significantly increased the
number of vehicles on roads . Due to the increase in the range of the vehicles, there is a
massive waste of time, and an increase in pollution is happening and from other side the
degree of traffic accidents have increased considerably. Not only vehicles, however con-
jointly pedestrians face the security threat from traffic accidents . After years of analysis
and standardization efforts, connected vehicle technologies are nearly able to take off
and commercially viable and used by the overall public in a very big selection of condi-
tions, technological advancements are rushing on the automated technology time toward
this destination . Traffic congestion has become a problem nowadays, leading significant
cities to manipulate the technology to provide better, quicker and more efficient methods
to gain access. The main cause of road congestion is the drastic growth of the traffic pop-
ulation. Primarily planned to boost driving safety and enable crash prevention through
the reliable timely dissemination of warning messages among vehicles. Connected vehi-
cle technologies are expected to satisfy the ever increasing knowledge appetence of users
on wheels entailing vehicle-to-everything (V2X)
Data exchange in Vehicle-to-vehicle (V2V) communications systems is a field that re-
quires automated solutions, tools and methods and the capability to facilitate early detec-
tion and even a prediction. Many studies have focused on V2V system and its classifi-
cation to improve road safety, reduce traffic congestion and help streamline the vehicle
flow on the road. This study aims to review and analyse literature related to data exchange
in V2V communications systems. The factors considered to improve the understanding
of the field’s various contextual aspects were derived from published studies. We sys-
tematically searched all articles about the classification and detection of data exchange

Electronics and Communication Engg. 6 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

in vehicles, as well as their evaluation. Most articles are studies conducted in a V2V
communication system; a number of papers covered the actual attempts to develop V2V
communications; and few papers comprised framework proposals and architectures. The
some portion of articles presented review and survey articles. V2V collision avoidance
system, which is a field requiring automated solutions, tools and methods, entails the
capability to facilitate early detection. Several studies have been performed on the au-
tomatic detection of V2V and their subtypes to promote accurate detection. The basic
characteristics of this emerging field are identified from the aspects of motivations, open
challenges that impede the technology’s utility, authors’ recommendations and substan-
tial analysis of the previous studies are discussed based on seven aspect (devices, number
of scenario, test location, types of sensors, number of vehicle, evaluation techniques used
and types of software). This methodology consists of four phases; investigation, develop
a hardware system, study and analysis, and evaluation phases. However, research areas
on V2V communication with the scope of data exchange are varied. This systematic re-
view is expected to open opportunities for researchers and encourage them to work on
the identified gaps.

Electronics and Communication Engg. 7 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Chapter 3

METHODOLOGIES FOR THE


PROJECT

3.1 SYSTEM DEVELOPMENT

Figure 3.1: Block diagram of proposed v2v communication system

This work represents to replace the place of vehicle horn by using a V2V communication
system which can help to mitigate the excessive sound levels that roadside people face in
a traffic congestion area. Fig. 1 describes the basic block diagram of the proposed system.
The design uses two communication protocol to exchange messages without honking
between vehicles in traffic area. Both radio Frequency and infrared ray communication
technique has been used in this System. RF transmitter and IR transmitter are placed
in front of the driver and both receivers are placed behind the vehicle. Receivers are

Electronics and Communication Engg. 8 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

attached with an arduino which takes transmitted signal that sends by the transmitters
and read the signal to reproduce the messages. A LCD is used to show the receiving
messages and a buzzer is also used to draw the attention of driver. The circuit uses a RF
transmitter and receiver to send and receive messages to the left and right side vehicle
and uses a TSOP1738 IR receiver module at the back side of the vehicle to receive the
38 kHz frequency IR pulses from the IR transmitter which send message to the front side
vehicle.

3.2 DESIGN OF PROPOSED SYSTEM

Figure 3.2: Block diagram of proposed v2v communication system

In the proposed system, we have IR sensors, RF module and a GPS module. The core
of this system is an RF module and an IR sensor. Both are placed besides the driver.
They transmit data code serially to the receiver placed behind the vehicles which then
get passed onto the Arduino where it gets decoded. The required information is then dis-
played in an OLED depending on which driver changes the position of the vehicle. Radio
waves are a type of electromagnetic radiation with wavelengths in the electromagnetic

Electronics and Communication Engg. 9 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

spectrum longer than infrared light. Radio waves have frequencies from 300 GHZ to as
low as 3kHz . Like all other electromagnetic waves, they travel at the speed of light. Dif-
ferent frequencies of radio waves have different propagation characteristics in the Earth’s
atmosphere, long waves may cover a part of the Earth very consistently, shorter waves
can reflect very little and travel on a line of sight. In order to receive radio signals, for
instance from AM/FM radio stations, a radio antenna must be used. A 4 way DIP switch
is used to simulate different assigned messages that shows in the OLED when driver push
these switches. When switches are being pressed this generate a 4 words transmission
cycle that is fed parallel to the encoder IC HT 12E, which converts it to a serial bit stream
and sends to the RF transmitter. On the other hand, an IR transmitter which is basically
a TV remote consists of a set of button and a circuit board. Each button is embedded
with a black conductive disk which acts as contact between the buttons and the printed
circuit board. The circuit board or the chip consists of a circuitry to sense the connections
or detect the button being pressed and produces the signal in Morse code from which is
amplified by the transistors and then given to IR LED. The IR LED is connected to end
of the circuit board and emits infrared light. As RF and IR both have comparatively good
range and sensitivity these can be used as a medium of vehicle to vehicle communica-
tion to reduce the noise produced by vehicle horns in traffic congestion. The reason for
modulation is to separate the IR range from the IR light emitted by other bodies in the
vicinity. Usually it requires a line of sight communication. When a button is pressed, the
corresponding circuitry gets connected to bias the IR LED which emits IR light which
contains the input. This output in form of light pulses is pulse width modulated at 38
kHz frequency, which is obtained at the receiver by demodulation. these transmitters
kept at the front of the driver to transmit the data wirelessly to the approaching vehicles.
As RF and IR both have comparatively good range and sensitivity these can be used as
a medium of vehicle to vehicle communication to reduce the noise produced by vehicle
horns in traffic congestion.
This arrangement mainly serves the purposes that it helps the driver for making de-
cision when one vehicle request another vehicle to move right, left or forward in traffic
areas. It also warns the driver if there is already a vehicle standing where the receiver
vehicle has to be moved. The circuit uses a RF receiver and TSHOP1738 IR receiver
both are interfaced with a Arduino.

Electronics and Communication Engg. 10 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Chapter 4

HARDWARE SETUP

4.1 IR SENSOR
An infrared (IR) sensor is an electronic device that measures and detects infrared radia-
tion in its surrounding environment. Infrared radiation was accidentally discovered by an
astronomer named William Herchel in 1800. While measuring the temperature of each
color of light (separated by a prism), he noticed that the temperature just beyond the red
light was highest. IR is invisible to the human eye, as its wavelength is longer than that
of visible light (though it is still on the same electromagnetic spectrum). Anything that
emits heat (everything that has a temperature above around five degrees Kelvin) gives
off infrared radiation. There are two types of infrared sensors: active and passive. Ac-
tive infrared sensors both emit and detect infrared radiation. Active IR sensors have two
parts: a light emitting diode (LED) and a receiver. When an object comes close to the
sensor, the infrared light from the LED reflects off of the object and is detected by the
receiver. Active IR sensors act as proximity sensors, and they are commonly used in
obstacle detection systems (such as in robots).

4.1.1 Working Principle

The working principle of an infrared sensor is similar to the object detection sensor. This
sensor includes an IR LED an IR Photo diode, so by combining these two can be formed
as a photo-coupler otherwise opto coupler. The physics laws used in this sensor are planks
radiation, Stephan Boltzmann weins displacement. IR LED is one kind of transmitter

Electronics and Communication Engg. 11 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Figure 4.1: IR Sensor

that emits IR radiations. This LED looks similar to a standard LED and the radiation
which is generated by this is not visible to the human eye. Infrared receivers mainly
detect the radiation using an infrared transmitter. These infrared receivers are available
in photo diodes form. IR Photo diodes are dissimilar as compared with usual photo diodes
because they detect simply IR radiation. Different kinds of infrared receivers mainly exist
depending on the voltage, wavelength, package, etc. Once it is used as the combination
of an IR transmitter receiver, then the receiver’s wavelength must equal the transmitter.
Here, the transmitter is IR LED whereas the receiver is IR photo diode. The infrared
photo diode is responsive to the infrared light that is generated through an infrared LED.
The resistance of photo-diode the change in output voltage is in proportion to the infrared
light obtained. This is the IR sensor’s fundamental working principle. Once the infrared
transmitter generates emission, then it arrives at the object some of the emission will
reflect back toward the infrared receiver. The sensor output can be decided by the IR
receiver depending on the intensity of the response An infrared sensor circuit is one of
the basic and popular sensor modules in an electronic device. This sensor is analogous
to human’s visionary senses, which can be used to detect obstacles and it is one of the
common applications in real-time.
We have used TSOP1738 in this project The given image is a general block diagram
of the internal components of TSOP1738. The detail of every component is discussed

Electronics and Communication Engg. 12 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

below:
The TSOP1738 is a member of IR remote control receiver series. This IR sensor
module consists of a PIN diode and a pre amplifier which are embedded into a single
package. The output of TSOP is active low and it gives +5V in off state. When IR
waves, from a source, with a center frequency of 38 kHz incident on it, its output goes
low. Lights coming from sunlight, fluorescent lamps etc. may cause disturbance to it and
result in undesirable output even when the source is not transmitting IR signals. A band
pass filter, an integrator stage and an automatic gain control are used to suppress such
disturbances. TSOP module has an inbuilt control circuit for amplifying the coded pulses
from the IR transmitter. A signal is generated when PIN photodiode receives the signals.
This input signal is received by an automatic gain control (AGC). For a range of inputs,
the output is fed back to AGC in order to adjust the gain to a suitable level. The signal
from AGC is passed to a band pass filter to filter undesired frequencies. After this, the
signal goes to a demodulator and this demodulated output drives an NPN transistor. The
collector output of the transistor is obtained at pin 3 of TSOP module.

4.1.2 TSOP1738 Receiver

It gives the IR receiver and amplifier within a single package. Special frequency level
makes it operate with a specific device. TSOP1738 has an internal bandpass filter to avoid
any ambient light especially sunlight. The internal filter gives PCM frequency for analog
signals It is usable with any kind of TTL/CMOS microcontroller, IC or microprocessors.

Electronics and Communication Engg. 13 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

4.1.3 Pin out Description

Figure 4.2: Pinout Diagram

GND: The ground pin is only to make common ground with other devices, especially
microcontrollers and ICs.
VSS: It is a power input pin for activating the internal decoder and IR receiver. The
power should be according to its specification and should be only at power pin. In case
of power input on any pin even if its low the IC will start heat up which can be noticed
by touching it. In the end, heating will damage the TSOP.
Output: The data will come out in the form of the pulse from the output pin. The
output pin can be interfaced with any TTL/CMOS devices with a little resistance. Output
data will be in voltage form, from the TSOP

4.2 RF MODULE
An RF module (short for radio-frequency module) is a (usually) small electronic device
used to transmit and/or receive radio signals between two devices. In an embedded sys-
tem it is often desirable to communicate with another device wirelessly. This wireless
communication may be accomplished through optical communication or through radio-
frequency (RF) communication. For many applications, the medium of choice is RF
since it does not require line of sight. RF communications incorporate a transmitter and
a receiver. They are of various types and ranges. Some can transmit up to 500 feet. RF
modules are typically fabricated using RF CMOS technology.

Electronics and Communication Engg. 14 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

In addition, reliable RF communication circuit requires careful monitoring of the


manufacturing process to ensure that the RF performance is not adversely affected.
RF modules are most often used in medium and low volume products for consumer
applications such as garage door openers, wireless alarm or monitoring systems, indus-
trial remote controls, smart sensor applications, and wireless home automation systems.
They are sometimes used to replace older infrared communication designs as they have
the advantage of not requiring line-of-sight operation.
Several carrier frequencies are commonly used in commercially available RF mod-
ules, including those in the industrial, scientific and medical (ISM) radio bands such
as 433.92 MHz, 915 MHz, and 2400 MHz. These frequencies are used because of na-
tional and international regulations governing the used of radio for communication. Short
Range Devices may also use frequencies available for unlicensed such as 315 MHz and
868 MHz.
RF modules may comply with a defined protocol for RF communications such as
Zigbee, Bluetooth Low Energy, or Wi-Fi, or they may implement a proprietary protocol.

Figure 4.3: RF Module

4.2.1 Types of RF modules

The term RF module can be applied to many different types, shapes and sizes of small
electronic sub assembly circuit board. It can also be applied to modules across a huge

Electronics and Communication Engg. 15 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

variation of functionality and capability. RF modules typically incorporate a printed


circuit board, transmit or receive circuit, antenna, and serial interface for communication
to the host processor.
Most standard, well known types are :
transmitter module receiver module transceiver module system on a chip module.

4.2.2 Transmitter Modules

An RF transmitter module is a small PCB sub-assembly capable of transmitting a radio


wave and modulating that wave to carry data. Transmitter modules are usually imple-
mented alongside a microcontroller which will provide data to the module which can be
transmitted. RF transmitters are usually subject to regulatory requirements which dictate
the maximum allowable transmitter power output, harmonics, and band edge require-
ments.

Specifications RF 433MHz Transmitter

Frequency Range: 433.92MHz


Input Voltage: 3-12V

4.2.3 Receiver module

An RF receiver module receives the modulated RF signal, and demodulates it. There
are two types of RF receiver modules: superheterodyne receivers and super regenerative
receivers. Super regenerative modules are usually low cost and low power designs using
a series of amplifiers to extract modulated data from a carrier wave. Super regenerative
modules are generally imprecise as their frequency of operation varies considerably with
temperature and power supply voltage. Superheterodyne receivers have a performance
advantage over super regenerative; they offer increased accuracy and stability over a large
voltage and temperature range. This stability comes from a fixed crystal design which
in the past tended to mean a comparatively more expensive product. However, advances
in receiver chip design now mean that currently there is little price difference between
superheterodyne and super regenerative receiver modules.

Electronics and Communication Engg. 16 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Specifications RF 433MHz Transmitter

Frequency Range: 433.92 MHz Modulation: ASK Input Voltage: 5V

4.2.4 Transceiver modules

An RF transceiver module incorporates both a transmitter and receiver. The circuit is


typically designed for half-duplex operation, although full-duplex modules are available,
typically at a higher cost due to the added complexity.

4.3 GPS MODULE


One of the global positioning system (GPS) devices ultilizes data from satellites to locate
a specific point on the Earth in a process named trilateration. Meanwhile, a GPS receiver
measures the distances to satellites using radio signals to trilaterate. And trilateration is
similar to triangulation, which measures angles, depicted in this illustration (Tim Gun-
ther, 2020). GPS modules contain tiny processors and antennas that directly receive data
sent by satellites through dedicated RF frequencies. From there, it’ll receive timestamp
from each visible satellites, along with other pieces of data. If the module’s antenna can
spot 4 or more satellites, it’s able to accurately calculate its position and time. The four
well-known Global Navigation Satellite System include GPS, BDS(Beidou), GLONASS
and GALILEO four satellite navigation systems. The earliest appeared in the United
States is GPS (Global Positioning System), which is the most complete technology at
this stage. We have used NEO-6M GPS module is shown in the figure below. It comes
with an external antenna, and doesn’t come with header pins. So, we’ll need to get and
solder some. This module has an external antenna and built-in EEPROM. Interface:
RS232 TTL Power supply: 3V to 5V Default baudrate: 9600 bps Works with standard
NMEA sentences
The NEO-6M GPS module is also compatible with other microcontroller boards. The
heart of the module is a NEO-6M GPS chip from u-blox. It can track up to 22 satellites
on 50 channels and achieves the industry’s highest level of sensitivity i.e. -161 dB track-
ing, while consuming only 45mA supply current. The u-blox 6 positioning engine also
boasts a Time-To-First-Fix (TTFF) of under 1 second. One of the best features the chip

Electronics and Communication Engg. 17 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

provides is Power Save Mode(PSM). It allows a reduction in system power consumption


by selectively switching parts of the receiver ON and OFF. This dramatically reduces
power consumption of the module to just 11mA making it suitable for power sensitive
applications like GPS wristwatch. The necessary data pins of NEO-6M GPS chip are
broken out to a ”0.1 pitch headers. This includes pins required for communication with a
microcontroller over UART. The original circuit diagram of the module, is shown below:

Figure 4.4: GPS module

4.3.1 Pin Description

Arduino Uno is a microcontroller board based on 8-bit ATmega328P microcontroller.


Along with ATmega328P, it consists other components such as crystal oscillator, serial
communication, voltage regulator, etc. to support the microcontroller. Arduino Uno has
14 digital input/output pins (out of which 6 can be used as PWM outputs), 6 analog input
pins, a USB connection, A Power barrel jack, an ICSP header and a reset button.

Electronics and Communication Engg. 18 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Figure 4.5: GPS Schematic

The 14 digital input/output pins can be used as input or output pins by using pin-
Mode(), digitalRead() and digitalWrite() functions in Arduino programming. Each pin
operate at 5V and can provide or receive a maximum of 40mA current, and has an inter-
nal pull-up resistor of 20-50 KOhms which are disconnected by default. Out of these 14
pins, some pins have specific functions as listed below
• Serial Pins 0 (Rx) and 1 (Tx) - Rx and Tx pins are used to receive and transmit TTL
serial data. They are connected with the corresponding ATmega328P USB to TTL serial
chip.
• External Interrupt Pins 2 and 3 - These pins can be configured to trigger an interrupt
on a low value, a rising or falling edge, or a change in value.
• PWM Pins 3, 5, 6, 9 and 11 - These pins provide an 8-bit PWM output by using
analogWrite() function.
• SPI Pins 10 (SS), 11 (MOSI), 12 (MISO) and 13 (SCK) ==¿ These pins are used for
SPI communication.
• In-built LED Pin 13- This pin is connected with an built-in LED, when pin 13 is
HIGH – LED is on and when pin 13 is LOW, its off.
There are 6 analog input pins, each of which provide 10 bits of resolution, i.e. 1024
different values. They measure from 0 to 5 volts but this limit can be increased by using
AREF pin with analog Reference() function.
• Analog pin 4 (SDA) and pin 5 (SCA) also used for TWI communication using Wire

Electronics and Communication Engg. 19 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

library.
• AREF - Used to provide reference voltage for analog inputs with analogReference()
function.
• Reset Pin -Making this pin LOW, resets the Arudino.
we configure the gps using in Node Mcu. Node mcu is open source in which we are
able to interface with NEO-6M GPS module .
As indicated, the GPS modules are based on the u-blox NEO-6M GPS engine. The
NEO-6M module includes one configurable UART interface for serial communication,
but the default UART (TTL) baud rate here is 9,600. Because the GPS signal is right-
hand circular-polarized (RHCP), the style of the GPS antenna will be different from the
common whip antennas used for linear polarized signals. The most popular antenna type
is the patch antenna. Patch antennas are flat, generally have a ceramic and metal body,
and are mounted on a metal base plate. They are often cast in a housing. For more
information about u-blox reference designs, see their website. Remember, the position
of the antenna mounting is very crucial for optimal performance of the GPS receiver.
When using the patch antenna, it should be oriented parallel to the geographic horizon.
The antenna must have full view of the sky, ensuring a direct line of sight with as many
visible satellites as possible.

4.3.2 Features

1) A complete GPS module with an active antenna integrated, and a built-in EEPROM
to save configuration parameter data. 2) Built-in 25 x 25 x 4mm ceramic active antenna
provides strong satellite search capability. 3) Equipped with power and signal indicator
lights and data backup battery. 4) Power supply: 3-5V; Default baud rate: 9600bps. 5)
Interface: RS232 TTL 6) Maximum navigation update rate: 5Hz 7)Maximum DC current
at any output: 10mA 8) Sensitivity: -160dBm

4.3.3 Applications

GPS application
Smart phone and tablets
Navigation systems
Drones

Electronics and Communication Engg. 20 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

4.4 I2C
I2C (Inter-Integrated Circuit), alternatively known as I2C or IIC, is a synchronous, multi-
controller/multi-target (controller/target), packet switched, single-ended, serial commu-
nication bus invented in 1982 by Philips Semiconductors. It is widely used for attaching
lower-speed peripheral ICs to processors and microcontrollers in short-distance, intra-
board communication.
Several competitors, such as Siemens, NEC, Texas Instruments, STMicroelectronics,
Motorola,[1] Nordic Semiconductor and Intersil, have introduced compatible I2C prod-
ucts to the market since the mid-1990s.
System Management Bus (SMBus), defined by Intel in 1995, is a subset of I2C,
defining a stricter usage. One purpose of SMBus is to promote robustness and interop-
erability. Accordingly, modern I2C systems incorporate some policies and rules from
SMBus, sometimes supporting both I2C and SMBus, requiring only minimal reconfigu-
ration either by commanding or output pin use.

Figure 4.6: Voltage level controller

Electronics and Communication Engg. 21 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Chapter 5

SOFTWARE ENVIRONMENT

5.1 PYTHON - IDLE


Python has become one of the most popular programming languages in the world in
recent years. It’s used in everything from machine learning to building websites and
software testing. It can be used by developers and non-developers alike. Python, one of
the most popular programming languages in the world, has created everything from Net-
flix’s recommendation algorithm to the software that controls self-driving cars. Python
is a general-purpose language, which means it’s designed to be used in a range of appli-
cations, including data science, software and web development, automation, and gener-
ally getting stuff done. Python is commonly used for developing websites and software,
task automation, data analysis, and data visualization. Since it’s relatively easy to learn,
Python has been adopted by many non-programmers such as accountants and scientists,
for a variety of everyday tasks, like organizing finances. “Writing programs is a very
creative and rewarding activity,” says University of Michigan and Coursera instructor
Charles R Severance in his book Python for Everybody. “You can write programs for
many reasons, ranging from making your living to solving a difficult data analysis prob-
lem to having fun to helping someone else solve a problem.” IDLE (Integrated Devel-
opment and Learning Environment) is an integrated development environment (IDE) for
Python. The Python installer for Windows contains the IDLE module by default.IDLE is
not available by default in Python distributions for Linux. It needs to be installed using
the respective package managers.IDLE can be used to execute a single statement just like
Python Shell and also to create, modify, and execute Python scripts. IDLE provides a

Electronics and Communication Engg. 22 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

fully-featured text editor to create Python script that includes features like syntax high-
lighting, auto completion, and smart indent. It also has a debugger with stepping and
breakpoints features.

Figure 5.1: pythoncode

5.2 Arduino IDE


The open-source arduino software (IDE) makes it easy to write code and upload it to
the board. This software can be used with any arduino board or NodeMCU. Version
1.8.9 of the arduino IDE introduced official support for adding third party boards (like
the Adafruit Flora and Trinket) to the new board manager. This addition is great news,
because it allows users to quickly add new boards with the click of a button. Previously
the addition of new boards required a cumbersome manual installation process, or in
certain cases, the download of a completely separate version of the IDE with the new
boards added. Arduino IDE (Integrated Development Environment) is the software for
arduino. It is a text editor like a notepad with different features. It is used for writing
code, compiling the code to check if any errors are there and uploading the code to the
arduino. It is a cross-platform software which is available for every Operating System

Electronics and Communication Engg. 23 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

like Windows, Linux, macOS. It supports C/C++ language. It is open-source software,


where the user can use the software as they want it to. They can also make their own
modules/functions and add them to the software. It supports every available arduino
board including arduino mega, arduino leonardo, arduino ethernet and more. Word file
is called a document similarly, arduino file is called a sketch where the user writes code.
The format of Arduino is saved as ino.

5.3 How Arduino IDE works


When a user writes code and compiles, the IDE will generate a hex file for the code
(hex file are hexa decimal files which are understood by arduino) and then sent to the
board using a USB cable. Every arduino board is integrated with a microcontroller, the
microcontroller will receive the hex file and runs as per the code written.

Figure 5.2: code

5.4 Node MCU


We configure the gps using in Node Mcu. Node mcu is open source in which we are
able to interface with NEO-6M GPS module . NodeMCU is a low-cost open source IoT
platform. It initially included firmware which runs on the ESP8266 Wi-Fi SoC from
Espressif Systems, and hardware which was based on the ESP-12 module.
NodeMCU is an open source firmware for which open source prototyping board
designs are available. The name ”NodeMCU” combines ”node” and ”MCU” (micro-
controller unit).[8] The term ”NodeMCU” strictly speaking refers to the firmware rather
than the associated development kits.

Electronics and Communication Engg. 24 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Both the firmware and prototyping board designs are open source.
The firmware uses the Lua scripting language. The firmware is based on the eLua
project, and built on the Espress if Non-OS SDK for ESP8266. It uses many open source
projects, such as lua-cjson and SPIFFS. Due to resource constraints, users need to select
the modules relevant for their project and build a firmware tailored to their needs. Support
for the 32-bit ESP32 has also been implemented.
The prototyping hardware typically used is a circuit board functioning as a dual in-
line package (DIP) which integrates a USB controller with a smaller surface-mounted
board containing the MCU and antenna. The choice of the DIP format allows for easy
prototyping on breadboards. The design was initially based on the ESP-12 module of the
ESP8266, which is a Wi-Fi SoC integrated with a Tensilica Xtensa LX106 core, widely
used in IoT application

Figure 5.3: CODE

Electronics and Communication Engg. 25 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

CONCLUSION AND ANALYSIS

This proposed method can provide a safe and efficient way to communicate to an-
other vehicle in traffic congestion . By using this device , we not only solve the
noise pollution but also a device to replace the existing horn of the vehicle The
proposed system is initiated to draw the attention of the driver without making any
external horn. Instead of sending a message wirelessly among the vehicles. besides
the driver so that driver could take movement step based on the received message.
By adding the GPS to the system we can overcome the disadvantage of curve roads.
Even in the curvy roads the vehicle will detect the vehicle coming from the oppo-
site direction, which in turn avoid accidents. This device can be used in emergency
vehicles also , by sending the messages to give the way for emergency vehicles.
This will be a easier process than the noise from the emergency vehicles. Vehicle
to vehicle is a future technology,V2V communication system could potentially al-
low vehicles to collaborate on the roadway by moving closer together in a platoon
with other vehicles traveling in the same direction.As a result, roadways improve
capacity by accommodating more vehicles in the same amount of area. Although
we are still a long way from having a linked vehicle road transport system, there are
technologies on the market today that try to bridge the gap between existing and
V2V technologies. The main aim of this system is to make a sound pollution free
environment so that people are not be affected by various diseases which caused
by unnecessary vehicle horn. For future improvement, this system can be modified
by using internet of things for communication among the vehicles.


Figure 5.4: output

Electronics and Communication Engg. 26 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Bibliography

[1] P. A. Koushki, L. F. Cohn, and A. A. Felimban, “Urban traffic noise in Riyadh,


Saudi Arabia, perceptions and attitudes,” Journal of Transportation Engineering,
vol. 119, no. 5, pp. 751–762, 1993.

[2] Tayler Thompson “Hardware Necessary for Vehicle to Vehicle Communication on


a Large Scale” Marshall University College of Information Technology and Engi-
neering.

[3] Fahmida Ahmed, Shakh Md. Alimuzjaman Alim, Md. Shafiqul Islam, Kanti Bhusan
Roy Kawshik, Shafiul Islam, “433 MHz (Wireless RF) Communication between
Two Arduino UNO” American Journal of Engineering Research (AJER), Vol 5,
Issue-10, pp-358-362, 2016.

[4] https://en.wikipedia.org/wiki/Vehicleh orn.

Electronics and Communication Engg. 27 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

APPENDIX

•Reference paper of project


• program code for arduino
• program code for GPS

Electronics and Communication Engg. 28 VAST, Thalakotukara


2nd International Conference on Electrical & Electronic Engineering (ICEEE), 27-29 December 2017, RUET, Rajshahi, Bangladesh

Vehicle to Vehicle Communication Using RF and


IR Technology
Eftekhar Hossain, Nursadul Mamun Md. Fahim Faisal
Dept. of Electronics and Telecommunication Engineering. Department of Mechanical Engineering
Chittagong University of Engineering and Technology, Chittagong University of Engineering and Technology,
Chittagong, Bangladesh. Chittagong, Bangladesh.
eftekhar.13ete@gmail.com, nursad49@gmail.com f.faisal_bd@yahoo.com

Abstract— In the urban areas, most of the sound pollution presented a system which can be used as a substitute of
are caused because of noisy environment which is created by vehicle horn. In this system RF and IR communication has
industrial machineries and vehicle horn. Among all the reasons been used as a replacement of vehicle horn. Every vehicle
the vehicle horn is assumed most vital for making the noisy has been attached with a RF and IR Transmitter-Receiver
environment which has a hazardous impact on the human pair where RF transmitter and IR Transmitter are used to
health. Therefore, it is become graver to need a system that is send the signal with a message to the nearest vehicle.
able to make the environment safe and sound. To confront this
challenge, this study proposes a V2V or Vehicle to Vehicle
Communication System. In this study, the V2V Communication II. BACKGROUND STUDY
has been accomplished using both Infrared and radio Recent breakthroughs in science and technological
frequency communication without using horn. IR transmitter innovations have led to an unprecedented advancement in
which is used to transmit the signal to front side vehicles and provisions of technological solutions for the numerous
RF transmitter which is used to transmit the signal to both left problems facing mankind. Researchers are busy leveraging
and right side vehicles are placed in front of the driver. on modern technology to provide better and improved
Moreover, IR and RF receivers are inserted behind the car to
solutions commensurate to the ever increasing demands.
receive the corresponding transmitted signal from the other
vehicles. A speaker is used to alert the driver and a LCD is used
Vehicle to Vehicle Communication(V2V Communication) is
to show from where the transmitted signal has been come and the wireless transmission of data between motor vehicles.
the driver will decide where the car should be moved. The The goal of V2V communication is to make a pollution free
whole functions of the system are processed by PIC environment by allowing vehicles in transit to send position
Microcontroller. The goal of this work is to mitigate the vehicle and messages without making sound in traffic congestion.
noise to some extent and to reduce unnecessary vehicle horn. The existing V2V Communication uses horn system which is
This system can be used as a substitution of horn system in the a sound making device that can be equipped to motor
populated, emergency and busy places. vehicles, buses, bicycles, trains and other types of vehicles.
The sound made usually resembles a “honk” which vehicle
Keywords— V2V; PIC Microcontroller; RF Transmitter; IR operator uses the horn to warn others of the vehicle’s
Transmitter; LCD. approach or presence or to call attention to some hazard.
Vehicle horns are usually electric driven by a flat circular
I. INTRODUCTION steel diaphragm that has an electromagnet acting on it and is
attached to a contactor that repeatedly interrupts the current
Sound pollution [1] is a significant environmental to that electromagnet. This arrangement works like a buzzer
problem in rapidly developing cities. Vehicle sound is or an electric bell whose sound levels are approximately 107-
probably the most rigorous and pervasive source of sound 109 decibels [3]. The advance model of vehicle horn has
pollution among other sources such as neighborhood, been replaced by V2V Communication where depending
electrical appliances, TV and music systems, public address upon the technology is implemented, the vehicle’s driver may
systems, railway and air traffic and electricity generating simply receive messages without producing excessive
sets. Most of the vehicle noise are generated in traffic amount of sound levels.
congestion which is caused by unnecessary honking of
vehicle horn. In most cases, driver irresponsibility is the main
reason behind the vehicle noise. Driver creates a hazardous III. PROPOSED SYSTEM
situation by honking unnecessarily in traffic jam which
adversely effect in the human body. Researchers have found A. System Block Diagram
vehicle noise pollution to be a major cause of several human This work presents a lot of considerations and
defects like stress, unborn and effects on hearing. Over the improvements to remove vehicle horn system and replace the
past few years researchers adopt some system that could place of vehicle horn by using a V2V communication system
mitigate the vehicle noise in some extent. As computerized which can help to mitigate the excessive sound levels that
technology advances, there is a push towards Vehicle-to- roadside people face in a traffic congestion area. Fig. 1
vehicle Communication [2]. Though vehicle to vehicle describes the basic block diagram of the proposed system.
communication is mainly used for traffic safety but this study The design uses two communication protocol to exchange
2nd International Conference on Electrical & Electronic Engineering (ICEEE), 27-29 December 2017, RUET, Rajshahi, Bangladesh

messages without honking between vehicles in traffic area. transmitted together with the header bits via an RF or an
Both radio Frequency and infrared ray communication infrared transmission medium upon receipt of a trigger
technique has been used in this System. RF transmitter and signal. The capability to select a TE trigger on the HT12E or
IR transmitter are placed in front of the driver and both a DATA trigger on the HT12A further enhances the
receivers are placed behind the vehicle. Receivers are application flexibility of the 212 series of encoders. The
attached with a PIC microcontroller which takes transmitted HT12A additionally provides a 38 kHz carrier for infrared
signal that sends by the transmitters and read the signal to systems. The 212 series of encoders begin a 4-word
reproduce the messages. A LCD is used to show the transmission cycle upon receipt of a transmission enable
receiving messages and a buzzer is also used to draw the signal. This cycle will repeat itself as long as the transmission
attention of driver. The circuit uses a RF transmitter and enable (TE or D8~D11) is held low. Once the transmission
receiver to send and receive messages to the left and right enables returns high the encoder output completes its final
side vehicle and uses a TSOP1738 IR receiver module at the cycle and then stops. The address pins A0-A7 are used to
back side of the vehicle to receive the 38 kHz frequency IR ensure that the data reaches the intended receivers only. But
pulses from the IR transmitter which send message to the in this case, the address pins A0-A7 are simply grounded.
front side vehicle.
D. Decoder IC HT 12D
RF RX/TX RF RX/TX The 212 decoders are a series of CMOS LSIs for remote
Module Module control system applications [6]. They are paired with
Holtek’s 212 series of encoders. For proper operation, a pair
of encoder/decoder with the same number of addresses and
LCD data format should be chosen. The decoders receive serial
Vehicle with Vehicle with addresses and data from a programmed 212 series of
Buzzer encoders that are transmitted by a carrier using an RF or an
PIC 16f877A PIC 16f877A
IR transmission medium. They compare the serial input data
LCD three times continuously with their local addresses. If no
error or unmatched codes are found, the input data codes are
Buzzer decoded and then transferred to the output pins. The VT pin
also goes high to indicate a valid transmission. The 212
series of decoders are capable of decoding information that
IR RX/TX IR RX/TX consists of N bits of address and 12_N bits of data. Of this
Module Module series, the HT12D is arranged to provide 8 address bits and 4
data bits, and HT12F is used to decode 12 bits of address
Fig. 1. Block Diagram of proposed Vehicle to Vehicle Communication
information. The 212 series of decoders provides various
system combinations of addresses and data pins in different packages
so as to pair with the 212 series of encoders. The decoders
receive data that are transmitted by an encoder and interpret
B. RF module the first N bits of code period as addresses and the last 12_N
In this RF system (operates at radio frequency), the digital bits as data, where N is the address code number. A signal on
data is represented as variations in the amplitude of carrier the DIN pin activates the oscillator which in turn decodes the
wave. This kind of modulation is known as Amplitude shift incoming address and data. The decoders will then check the
keying. The RF module comprises of an RF transmitter and received address three times continuously. If the received
an RF receiver. The transmitter/ receiver pairs operate at a address codes all match the contents of the decoder’s local
frequency of 434 MHz An RF transmitter receives serial data address, the 12_N bits of data are decoded to activate the
and transmits it wirelessly through RF through its antenna output pins and the VT pin is set high to indicate a valid
connected at antenna pin. The transmission occurs at the rate transmission. This will last unless the address code is
of 1Kbps-10Kbps. The transmitted data is received by an RF incorrect or no signal is received. The output of the VT pin is
receiver operating at the same frequency as that of the high only when the transmission is valid, otherwise it is
transmitter. The RF module is often used along with a pair of always low. These decoder ICs have a wide range of
encoder/decoder[4]. The encoder is used for encoding operating voltages ranging from 2.4V to 12V. Low power
parallel data for transmission feed while reception is decoded and high noise immunity CMOS technology is used in this
by a decoder. HT12E-HT12D, HT640-HT648 etc. are some decoder. The received codes are checked three times to
commonly used encoder/decoder pair ICs. ensure error-free reception.

C. Encoder IC HT 12E E. TSHOP1738-IR Receiver


The 212 encoders are a series of CMOS LSIs used for The TSOP1738 is a member of IR remote control
remote control system applications[5]. They are capable of receiver series. This IR sensor module consists of a PIN
encoding information which consists of N address bits and diode and a pre amplifier which are embedded into a single
12_N data bits. Each address/data input can be set to one of package. The output of TSOP is active low and it gives +5V
the two logic states. The programmed addresses/data are in off state. When IR waves, from a source, with a center
2nd International Conference on Electrical & Electronic Engineering (ICEEE), 27-29 December 2017, RUET, Rajshahi, Bangladesh

frequency of 38 kHz incident on it, its output goes low. Earth very consistently, shorter waves can reflect very little
Lights coming from sunlight, fluorescent lamps etc. may and travel on a line of sight. In order to receive radio signals,
cause disturbance to it and result in undesirable output even for instance from AM/FM radio stations, a radio antenna
when the source is not transmitting IR signals. A band pass must be used. The transmitter used in this system works at
filter, an integrator stage and an automatic gain control are 434MHz. A 4 way DIP switch is used to simulate different
used to suppress such disturbances. TSOP module has an assigned messages that shows in the LCD when driver push
inbuilt control circuit for amplifying the coded pulses from these switches. When switches are being pressed this
the IR transmitter. A signal is generated when PIN generate a 4 words transmission cycle that is fed parallel to
photodiode receives the signals. This input signal is received the encoder IC HT 12E, which converts it to a serial bit
by an automatic gain control (AGC). For a range of inputs, stream and sends to the RF transmitter. On the other hand, an
the output is fed back to AGC in order to adjust the gain to a IR transmitter which is basically a TV remote consists of a
suitable level. The signal from AGC is passed to a band pass set of button and a circuit board. Each button is embedded
filter to filter undesired frequencies. After this, the signal with a black conductive disk which acts as contact between
goes to a demodulator and this demodulated output drives an the buttons and the printed circuit board. The circuit board or
NPN transistor. The collector output of the transistor is the chip consists of a circuitry to sense the connections or
obtained at pin 3 of TSOP module. detect the button being pressed and produces the signal in
Morse code from which is amplified by the transistors and
F. IC CD4017B then given to IR LED. The IR LED is connected to end of the
The 4017B is an integrated circuit which has been circuit board and emits infrared light. The remote controls
designed to count pulses in IR receiver circuit. It can count work by modulating the output from an infrared LED.A
from zero to ten and its outputs are decoded. It has 16 pins series of pulses of varying width are sent to a gate that turns
and looks like any other 16 pin integrated circuit. They can on or off, the modulator which is usually 38KHz. The reason
be used in timing circuits and are often used to switch on for modulation is to separate the remote IR range from the IR
and off LEDs or motors or other circuits. This saves a lot of light emitted by other bodies in the vicinity. Usually it
board space and time required to build this circuits when the requires a line of sight communication. When a button is
application demands using a counter followed by a decoder pressed, the corresponding circuitry gets connected to bias
IC. This IC also simplifies the design and makes debugging the IR LED which emits IR light which contains the input.
easy. This output in form of light pulses is pulse width modulated
at 38 kHz frequency, which is obtained at the receiver by
demodulation. these transmitters kept at the front of the
driver to transmit the data wirelessly to the approaching
IV. RESULT AND DISCUSSION vehicles.
One of the major advantages of this system is its simple
circuit and working principle. The circuit is divided into two
parts. First one is the Transmitter section which includes a
RF transmitter and a IR remote as a IR transmitter (both kept
in front of the driver) and second is the receiver section
interfaced with a microcontroller. Though Receiver section
connected with the microcontroller it keeps a distance from
MCU because the two receivers a RF receiver and a IR
receiver kept behind on the vehicle and microcontroller with
a LCD placed in front of the driver so that driver can see the
messages that sends by another vehicle. Both part of the
circuit are discussed in detail in the following sections.

A. Transmitter Section
The core of this system is an RF module and an IR TV
remote. Both are placed besides the driver. They transmit
data code serially to the receiver placed behind the vehicles
which then get passed onto the microcontroller where it gets
decoded. The required information is then displayed in an
LCD depending on which driver changes the position of the
vehicle. Radio waves are a type of electromagnetic radiation Fig. 2. Circuit diagram for transmitter section.
with wavelengths in the electromagnetic spectrum longer
than infrared light. Radio waves have frequencies from 300 As RF and IR both have comparatively good range and
GHZ to as low as 3kHz [7]. Like all other electromagnetic sensitivity these can be used as a medium of vehicle to
waves, they travel at the speed of light. Different frequencies vehicle communication to reduce the noise produced by
of radio waves have different propagation characteristics in vehicle horns in traffic congestion. Fig. 2 shows the circuit
the Earth’s atmosphere, long waves may cover a part of the diagram of RF transmitter used in the system.
2nd International Conference on Electrical & Electronic Engineering (ICEEE), 27-29 December 2017, RUET, Rajshahi, Bangladesh

B. Reciever & Microcontroller Section the train of 38KHz IR pulses from the remote that makes its
This arrangement mainly serves the purposes that it helps output to oscillate too. These pulses are inverted at the
the driver for making decision when one vehicle request collector of T1, which finally go to the clock input of the
another vehicle to move right, left or forward in traffic areas. decade counter. The arriving pulses could increment the
It also warns the driver if there is already a vehicle standing CD4017 counter at the same rate (38 kHz), but because of the
where the receiver vehicle has to be moved. The circuit uses presence of the RC filter circuit (R1 = 100K, C1 = 10 uF)
a RF receiver and TSHOP1738 IR receiver both are between the collector and the ground, the train of pulses
interfaced with a PIC 16f877A microcontroller. The RF appear as a single pulse to the counter. Thus, on each key
receiver has 4 output data pins which are connected with the pressing, the CD4017 counter advances only by a single
4 ADC pin of the microcontroller. The received data is count. When the user releases the key, the C1 capacitor
decoded by HT12D decoder which simply converts serial discharges through the R1 resistor, and the clock line is back
data to parallel data. HT12D decoder will be in standby mode to zero. So every time the user presses and releases a key on
initially i.e. oscillator is disabled and a HIGH on DIN pin the remote, the CD4017 counter receives a single pulse at its
activates the oscillator. Thus the oscillator will be active clock input. Initially, when the circuit is just powered on, the
when the decoder receives data transmitted by an encoder. Q0 output of the CD4017 decade counter goes high. The
The device starts decoding the input address and data. The counter increments for each low-to-high going pulse arriving
decoder matches the received address three times at its CLK pin (14). This output is fed to the fifth analog pin
continuously with the local address given to pin A0 – A7. If of the microcontroller and a LCD is used to display the
all matches, data bits are decoded and output pins D8 – D11 messages that show when driver presses the RF transmitter or
are activated. This valid data is indicated by making the pin IR transmitter. A buzzer is also used as a horn which kept
VT (Valid Transmission) HIGH. This will continue till the inside in the vehicle. The circuit of the receiver’s module and
address code becomes incorrect or no signal is received. microcontroller section is shown in Fig. 3.
Different LEDs are used as an indication of correct data
reception. The TSOP1738 IR receiver module is placed
behind the vehicle to receive the 38 kHz frequency IR pulses
from the remote control [8].

Fig. 3. Circuit diagram for entire receiver section with MCU. Fig. 4. Small scaled model of the proposed system

Under normal condition, the output pin of the IR module The major advantage of this systems is that the
is at logic High, which means the transistor BC557 is cut-off transmitter and receiver section has no connection with the
and its collector terminal is at logic Low. The collector of T1 internal circuitry of the vehicle. Hence it can be integrated
drives the clock line of the CD4017 decade counter. when onto any of the existing vehicles without any modifications to
driver faces a TV or DVD remote towards the TSOP1738 the vehicle. This makes the system highly adaptable.
and presses any key on it. The TSOP1738 module receives
2nd International Conference on Electrical & Electronic Engineering (ICEEE), 27-29 December 2017, RUET, Rajshahi, Bangladesh

A scaled version of the proposed system was REFERENCES


implemented and is shown in Fig. 4. It was able to detect the
RF and IR signals from fairly good distance with 100% [1] P. A. Koushki, L. F. Cohn, and A. A. Felimban, “Urban traffic noise
accuracy in traffic areas. in Riyadh, Saudi Arabia, perceptions and attitudes,” Journal of
Transportation Engineering, vol. 119, no. 5, pp. 751–762, 1993.
[2] Tayler Thompson “Hardware Necessary for Vehicle to Vehicle
Communication on a Large Scale” Marshall University College of
V. CONCLUSION Information Technology and Engineering.
[3] https://en.wikipedia.org/wiki/Vehicle_horn.
This study presents a vehicle to vehicle communication
[4] Fahmida Ahmed, Shakh Md. Alimuzjaman Alim, Md. Shafiqul Islam,
system that would be used as vehicle horn system in a Kanti Bhusan Roy Kawshik, Shafiul Islam, “433 MHz (Wireless RF)
congested traffic area. The proposed system is initiated to Communication between Two Arduino UNO” American Journal of
draw the attention of the driver without making any external Engineering Research (AJER), Vol 5, Issue-10, pp-358-362, 2016.
horn. Instead of sending a message wirelessly among the [5] HT 12E Datasheet [Online]. Available: www.
vehicles. The message is displaying in an LCD screen that eleinmec.com/datasheets/ds_holtek_ht12e.pdf.
placed besides the driver so that driver could take movement [6] HT 12D Datasheet [Online]. Available: www. eleinmec.
step based on the received message. The main aim of this com/datasheets/ds_holtek_ht12d.pdf.
system is to make a sound pollution free environment so that [7] N. M.Z. Hashim, A.S. Jaafar, N.A.Ali, L.Salahuddin,
people are not be affected by various diseases which caused N.R.Mohamad, M. A. Ibrahim, “Traffic Light Control System for
Emergency Vehicles Using Radio Frequency”, IOSR Journal of
by unnecessary vehicle horn. For future improvement, this Engineering (IOSRJEN), Vol. 3, Issue 7, PP 43-52, July. 2013.
system can be modified by using internet of things for [8] Tam Van Nguyen, Dong Gun Lee, Yong Ho Seol, Myung Hwan Yu,
communication among the vehicles. Deokjai Choi, “Ubiquitous Access to Home Appliance Control
System using Infrared Ray and Power Line Communication”, ICI
2007, 3rd IEEE/IFIP International Conference in Central Asia,
Tashkent, Uzbekistan, vol 1, pp1-4, 26-28 Sept. 2007.

View publication stats


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

CODE USED

Arduino Coding
// askr eceiver.pde
// − −mode : C + + − −
//Simpleexampleof howtouseRadioHeadtoreceivemessages
//withasimpleASKtransmitterinaverysimpleway.
//Implementsasimplex(one − way)receiverwithanRx − B1module
include < T imerOne.h >
include < RHA SK.h >
include < SP I.h > //N otactualyusedbutneededtocompile
include < Sof twareSerial.h >
include ”SSD1306Ascii.h”
include ”SSD1306AsciiAvrI2c.h”
// 0X3C+SA0 - 0x3C or 0x3D
define I2CA DDRESS0x3C
// Define proper RSTP IN if required.
def ineRSTP IN − 1
//irsensorpins
def inelef tA2
def inerightA0
def inef rontA1
def inebackA3
//irledpwmpin
def ineir9
def ineHORN 2
def ineM ODE6
//SetupanewSof twareSerialobjectwithRXindigitalpin10andT Xin
digitalpin11
SoftwareSerial portOne(5, 4);
String locat;
bool Horn=HIGH;
SSD1306AsciiAvrI2c oled;
RHA SKdriver;
Stringda;
constchar ∗ msg = ”1”;
bool Left = 1;
bool Right =1;
bool Front =1;
bool BAck = 1;

Electronics and Communication Engg. 34 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

bool oRF=0;
bool oLeft = 0;
bool oRight =0;
bool oFront =0;
bool oBAck = 0;
unsigned long ti;
unsigned long td;
int voltage;
// This is the callback for the Timer
void timerCallback()
//Left = digitalRead(left);
voltage = readVoltage(A2);
if (voltage¿=3.0)
Left=1;
else
Left=0;
voltage = readVoltage(A0);
if (voltage¿=3.0)
Right=1;
else
Right=0;
voltage = readVoltage(A1);
if (voltage¿=3.0)
Front=1;
else
Front=0;
voltage = readVoltage(A3);
if (voltage¿=3.0)
BAck=1;
else
BAck=0;
// Right =digitalRead(right);
//Front = digitalRead(front);
//BAck = digitalRead(back);
void normald rive()uint8t bu[1]; uint8t bulen = sizeof (bu); //readtheirsensor′ stimerCallback();
if (driver.recv(bu, bulen)) // Non-blocking

int i;
// Message with a good checksum received, dump it.
da = (char*)bu;

if(Left==1 oLeft==0)
oled.println(”LEFT, ”);
//oled.println(” DETECTED!”);
oLeft=1;
td=millis();

if(Right==1 oRight==0)

Electronics and Communication Engg. 35 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

oled.println(”RIGHT, ”);
//oled.println(” DETECTED!”);
oRight=1;
td=millis();

if(Front==1 oFront==0)
oled.println(”FRONT, ”);
//oled.println(” DETECTED!”);
oFront=1;
td=millis();

if(BAck==1oBAck==0)
oled.println(”BACK, ”);
//oled.println(” DETECTED!”);
oBAck=1;
td=millis();

//check the rf signal and print the output on OLED screen


if (int(da[0])==49 oRF==0 oLeft!=1 oRight!=1 oFront!=1 oBAck!=1)
//Serial.print(da);
oled.print(”HIDDEN,”);
oRF=1;
td=millis();
//oled.println(” DETECTED!”);

Serial.println(Horn);
if(Horn== LOW)
digitalWrite(ir,1);
ti = millis();
driver.send((uint8t ∗)msg, strlen(msg));
driver.waitP acketSent();
Horn = HIGH;

unsigned long tc= millis();


if(tc-ti¿5000)
digitalWrite(ir,0);

if(tc-td¿2000)
da=””;
oRF=0;
oLeft=0;
oRight=0;
oFront=0;
oBAck=0;
oled.clear();

void gpsd rive()//EnableSof twareSerialobjecttolistenif (portOne.available())chartemp = p


else

Electronics and Communication Engg. 36 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

Serial.println(locat);
oled.clear();
oled.println(”Car Near”);
oled.println(locat);
locat = ””;

void setup()
portOne.begin(9600);
pinMode(left,INPUT);
pinMode(right,INPUT);
pinMode(front,INPUT);
pinMode(back,INPUT);
pinMode(HORN,INPUTP U LLU P );
pinM ode(M ODE, IN P U TP U LLU P );
pinM ode(ir, OU T P U T ); / ∗
T imer1.initialize(100);
T imer1.attachInterrupt(timerCallback); ∗/
T imer1.start();
if RSTP IN >= 0
controller.add(irSensor);
oled.begin(Adaf ruit128x64, I2CA DDRESS, RSTP IN );
else//RSTP IN >= 0
oled.begin(Adaf ruit128x64, I2CA DDRESS);
endif //RSTP IN >= 0
//Calloled.setI2cClock(f requency)tochangef romthedef aultf requency.
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println(”init failed”);
else
oled.setFont(System5x7);
oled.set2X();
oled.clear();
oled.println(” Hello”);
oled.println(” Welcome!”);
delay(1000);
oled.clear();

attachInterrupt(digitalPinToInterrupt(HORN),transmitt,LOW);
int mode=1;
void loop()
mode = digitalRead(MODE);
if(mode==1)
gpsd rive();
else
normald rive();

int readVoltage(int pin)


int sensorValue = analogRead(pin);

Electronics and Communication Engg. 37 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 -


5V):
float voltage = sensorValue * (5.0 / 1023.0);
//Serial.println(voltage); return voltage;

void transmitt()
Horn = LOW;

Node Mcu(GPS server)


include ¡Arduino.h¿
include ¡TinyGPS++.h¿
include ¡ESP8266WiFi.h¿
include ¡PubSubClient.h¿
include ¡SoftwareSerial.h¿
TinyGPSPlus gps;
/*d7 - 13-tx
d8 - 15-rx*/
SoftwareSerial gpsSerial(15, 13); // RX, TX
SoftwareSerial ardSerial(4,5);
char buff[100];
const char* ssid = ”Galaxy M30s11E5”;
const char* password = ”ynwo4606”;
const char* mqtts erver = ”anirudhan − 80td.local”;
WiFiClient espClient;
PubSubClient client(espClient);
unsigned long lastMsg = 0;
define MSGB U F F ERS IZE(50)
charmsg[M SGB U F F ERS IZE];
intvalue = 0;
void callback(char* topic, byte* payload, unsigned int length)

payload[length] = ”;
float value = String((char*) payload).toFloat();

Serial.println(topic);
Serial.println(value);
ardSerial.print(”/”);
ardSerial.print(value);

void setupw if i()


delay(10);
// We start by connecting to a WiFi network
//Serial.println();
// Serial.print(”Connecting to ”);
//Serial.println(ssid);
WiFi.mode(WIFIS T A);

Electronics and Communication Engg. 38 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

W iF i.begin(ssid, password);
while (WiFi.status() != WLC ON N ECT ED)delay(500); //Serial.print(”.”);
randomSeed(micros());
//Serial.println(””);
//Serial.println(”WiFi connected”);
//Serial.println(”IP address: ”);
//Serial.println(WiFi.localIP());

void reconnect()
// Loop until we’re reconnected
while (!client.connected())
//Serial.print(”Attempting MQTT connection...”);
// Create a random client ID
String clientId = ”ESP8266Client-”;
clientId += String(random(0xffff), HEX);
// Attempt to connect
if (client.connect(clientId.cs tr()))//Serial.println(”connected”); //Onceconnected, publishanann

void printData()

if (gps.location.isUpdated())

double lat = gps.location.lat();


double lng = gps.location.lng();
//double lat = 76.110909;
//double lng = 10.110090;
snprintf(buff, MSGB U F F ERS IZE, ”
Serial.print(”P ublishmessage : ”);
Serial.print(buf f );
client.publish(”Car1
latitude”, buf f );
snprintf (buf f, M SGB U F F ERS IZE, ”
Serial.print(””);
Serial.println(buff);
client.publish(”Car1
longitude”, buff);

void setup()

Serial.begin(9600);
setupw if i(); client.setServer(mqtts erver, 1883);
client.setCallback(callback);
gpsSerial.begin(9600);
ardSerial.begin(9600);
void loop()

Electronics and Communication Engg. 39 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

//Serial.println(rec);
if (!client.connected())
reconnect();

client.loop();
while (gpsSerial.available() ¿ 0)
if (gps.encode(gpsSerial.read()))
printData();

import paho.mqtt.client as mqtt


from math import cos, asin, sqrt
def distance(lat1, lon1, lat2, lon2):
p = 0.017453292519943295
a = 0.5 - cos((lat2 - lat1) * p)/2 + cos(lat1 * p) * cos(lat2 * p) * (1 - cos((lon2 - lon1) *
p)) / 2
return 12742 * asin(sqrt(a))
def onc onnect(client, userdata, f lags, rc) : T hecallbackf orwhenthe
clientconnectstothebroker
print(”Connectedwithresultcode0”.f ormat(str(rc)))P rintresultof connectionattempt
client.subscribe(”Car1
latitude”)Subscribetothetopic\digitest/test1”, receiveanymessagespublishedonit
client.subscribe(”Car1
longitude”)
client.subscribe(”Car2
latitude”)Subscribetothetopic\digitest/test1”, receiveanymessagespublishedonit
client.subscribe(”Car2
longitude”)
def onm essage(client, userdata, msg) :
globalc1Long
globalc1Lat
globalc2Long
globalc2Lat
T hecallbackf orwhenaP U BLISHmessageisreceivedf romtheserver.
print(”M essagereceived− > ”+msg.topic+””+str(msg.payload))P rintareceivedmsg
if msg.topic == ”Car1
latitude” :
c1Lat = f loat(msg.payload.decode(”utf − 8”))
print(c1Lat)
if msg.topic == ”Car1
longitude” :
c1Long = f loat(msg.payload.decode(”utf − 8”))

Electronics and Communication Engg. 40 VAST, Thalakotukara


VEHICLE TO VEHICLE COMMUNICATION USING RF & IR TECHNOLOGY

print(c1Long)
if msg.topic == ”Car2
latitude” :
c2Lat = f loat(msg.payload.decode(”utf − 8”))
print(c2Lat)
if msg.topic == ”Car2
longitude” :
c2Long = f loat(msg.payload.decode(”utf − 8”))
print(c2Long)
try :
d = distance(c1Lat, c2Long, c2Lat, c2Long) ∗ 1000
print(f ”distancebetween2gpslocations : dm”)

if (d <= 500) :
print(d)
client.publish(′ Car1
near′ , payload = d, qos = 0, retain = F alse)
client.publish(′ Car2
near′ , payload = d, qos = 0, retain = F alse)
except:
pass
client = mqtt.Client(”digim qttt est”)Createinstanceof clientwith
clientID\digim qttt est”
client.onc onnect = onc onnectDef inecallbackf unctionf orsuccessf ul
connection
client.onm essage = onm essageDef inecallbackf unctionf orreceiptof a
message
client.connect(”m2m.eclipse.org”, 1883, 60)Connectto(broker, port,
keepalive − time)
client.connect(′ anirudhan − 80td′ , 1883, 60)
client.loopf orever()Startnetworkingdaemon

Electronics and Communication Engg. 41 VAST, Thalakotukara


Department of Electronics and Communication
Vidya Academy of Science & Technology
Thalakkottukara, Thrissur - 680 501
(http://www.vidyaacademy.ac.in)

You might also like