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

Exercise 5 Arduino To Arduino Communication

This document discusses various communication protocols used for Arduino-to-Arduino communication, including wired protocols like UART, I2C, and SPI, as well as wireless protocols like Bluetooth, Zigbee, WiFi, and LoRaWAN. It provides example code to simulate data exchange between Arduinos using different protocols in Proteus software. The document aims to help students understand appropriate protocol selection based on application requirements like data rate, range, power consumption, and complexity.

Uploaded by

Kazuha Minato
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Exercise 5 Arduino To Arduino Communication

This document discusses various communication protocols used for Arduino-to-Arduino communication, including wired protocols like UART, I2C, and SPI, as well as wireless protocols like Bluetooth, Zigbee, WiFi, and LoRaWAN. It provides example code to simulate data exchange between Arduinos using different protocols in Proteus software. The document aims to help students understand appropriate protocol selection based on application requirements like data rate, range, power consumption, and complexity.

Uploaded by

Kazuha Minato
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Laboratory Activity 5: Exploring Arduino-to-Arduino Communication Protocols

Introduction:

The ability for microcontrollers to exchange data effectively is crucial for building complex
interconnected systems. This laboratory activity focuses on exploring and simulating various
communication protocols used for Arduino-to-Arduino communication within the Proteus software
environment.

Wired Protocols:

• Universal Asynchronous Receiver-Transmitter (UART): This workhorse protocol reigns supreme


for short-range serial communication. It utilizes a simple two-wire setup (TX and RX) for
transmitting and receiving data one bit at a time. UART's beauty lies in its simplicity and
widespread compatibility, making it ideal for tasks like sending sensor readings from an Arduino
to a computer for visualization or logging data.

• Inter-Integrated Circuit (I2C): This master-slave protocol shines when efficiency is key. Imagine
connecting multiple sensors and actuators to your Arduino – I2C allows you to achieve this with
only two wires (SCL for clock and SDA for data) because it facilitates communication between a
single master device (the Arduino) and multiple slave devices (the sensors and actuators). This
reduces wiring complexity and board space, making it perfect for applications with a dense cluster
of peripherals, like building a weather station that collects temperature, humidity, and pressure
data.

• Serial Peripheral Interface (SPI): When high-speed data exchange becomes the priority, SPI
emerges as the champion. This synchronous protocol utilizes four wires (SCK for clock, MOSI for
master-out-slave-in, MISO for master-in-slave-out, and SS for slave select) to establish a dedicated
communication channel. This structured approach allows for faster and more reliable data transfer
compared to UART, making it a great choice for applications involving real-time data acquisition,
like controlling a high-resolution display or capturing audio data from a microphone.
Wireless Protocols:

• Bluetooth: A familiar name in the world of personal devices, offers a user-friendly solution for
short-range data exchange between Arduinos and smartphones or tablets. Its moderate data rates
make it suitable for tasks like control or monitoring in simple projects. Setting up and using
Bluetooth is relatively straightforward, and its widespread device support ensures compatibility
with a vast range of gadgets. An additional perk is the lower power consumption compared to Wi-
Fi, making it a good choice for battery-powered projects. However, Bluetooth's range is typically
limited to under 10 meters, and it's not ideal for applications requiring high data transfer speeds.
Security considerations also come into play when transmitting sensitive data over Bluetooth
connections.

• Zigbee: Zigbee shines brightly in the domain of low-power, low-data-rate wireless sensor
networks. This mesh networking protocol allows for robust and scalable communication between
battery-powered devices, making it ideal for building environmental monitoring systems or
implementing smart home automation with low-maintenance sensors. Zigbee's strength lies in its
ability to establish a self-healing mesh topology, meaning data can be routed through different
nodes if one becomes unavailable, ensuring reliable communication. Security features are built-
in for secure communication, adding another layer of trust. The trade-off for Zigbee's benefits lies
in its very low data rate, limiting its use for applications requiring high bandwidth. Setting up a
mesh network also involves additional configuration compared to simpler protocols. Furthermore,
the availability of Zigbee-enabled devices might be lower compared to Bluetooth.

• WiFi: For scenarios requiring high data transfer speeds, Wi-Fi emerges as the champion.
Leveraging existing Wi-Fi infrastructure, it facilitates streaming data or controlling Arduinos
remotely with multimedia content. Imagine sending live video feeds from your Arduino project
to a computer or controlling a robot with real-time commands – Wi-Fi's high data rates make these
applications possible. The long range of Wi-Fi allows communication over wider areas,
eliminating the limitations of short-range protocols. However, this convenience comes at the cost
of higher power consumption. Wi-Fi-powered devices typically require a constant power source,
limiting their use in battery-powered projects. Additionally, accessing a Wi-Fi network or hotspot
is a prerequisite for using Wi-Fi, and security concerns arise when connecting to public networks.

• LoRaWAN: LoRaWAN takes the crown for communication over vast distances. This low-power,
wide-area networking protocol enables data transmission over kilometers in some cases, making
it perfect for applications like remote sensor data collection in agriculture or building smart city
infrastructure. Imagine collecting temperature data from sensors scattered across a vast farm or
monitoring environmental conditions in remote locations – LoRaWAN's exceptional range makes
these scenarios achievable. The key to its long range lies in its extremely low data rate. While
this limits the type of data that can be transmitted, the trade-off is exceptional range and battery
efficiency. LoRaWAN is ideal for situations where long-distance communication reigns supreme,
even if the data itself is minimal. However, operating a LoRaWAN network requires additional
infrastructure like gateways and servers, and the availability of LoRaWAN-enabled devices might
be lower compared to some other protocols.

Objectives:

After successful completion of this activity, student should be able to:

• Gain an understanding of various communication protocols commonly used for Arduino-to-


Arduino communication, including wired and wireless options.
• Simulate data exchange between Arduinos using Proteus software.
• Analyze the strengths and weaknesses of each communication protocol.
• Identify appropriate protocols for different application scenarios.

Equipment Required:

Computer with Proteus software installed

Arduino IDE (Integrated Development Environment)

Sample Arduino code for each communication protocol (provided or developed during the activity)

Procedures:

1. Launch Proteus software and create a new project.


2. Utilize the Arduino libraries within Proteus to include virtual Arduino boards in the schematic.
3. Configure the communication protocol settings for each Arduino based on the chosen protocol
(e.g., baud rate for UART, clock speed for SPI).
4. Connect the appropriate pins on the Arduino boards according to the selected protocol (TX/RX
for UART, SCL/SDA for I2C, SCK/MOSI/MISO/SS for SPI).
5. Develop and upload sample Arduino code to virtual boards using the Arduino IDE. This code
should demonstrate basic data transmission and reception functionalities.
6. Run the simulation within Proteus and observe the data exchange between the Arduinos.
7. Analyze the behavior of each protocol based on its characteristics (e.g., data rate, complexity,
wiring requirements).
8. Modify the sample code to explore different data formats and communication patterns.

Example Source Codes:

Transmitter:

int button1=13, button2=12, b1,b2;

void setup() {
Serial.begin(9600);
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
}

void loop() {
b1=digitalRead(button1);
b2=digitalRead(button2);
if((b1==LOW)&&(b2==HIGH))
{
Serial.print('a');
delay(10);
}
if((b1==HIGH)&&(b2==LOW))
{
Serial.print('b');
delay(10);
}
if((b1==LOW)&&(b2==LOW))
{
Serial.print('c');
delay(10);
}
if((b1==HIGH)&&(b2==HIGH))
{
Serial.print('d');
delay(10);
}

}
Receiver:

int bulb1=8, bulb2=9;


char data;

void setup() {
Serial.begin(9600);
pinMode(bulb1,OUTPUT);
pinMode(bulb2,OUTPUT);
}

void loop() {
data=Serial.read();
if(data=='a')
{
digitalWrite(bulb1,HIGH);
digitalWrite(bulb2,LOW);
delay(10);
}
if(data=='b')
{
digitalWrite(bulb1,LOW);
digitalWrite(bulb2,HIGH);
delay(10);
}
if(data=='c')
{
digitalWrite(bulb1,HIGH);
digitalWrite(bulb2,HIGH);
delay(10);
}
if(data=='d')
{
digitalWrite(bulb1,LOW);
digitalWrite(bulb2,LOW);
delay(10);
}
}
Simulation Environment:

Conclusion:
Questions to answer:

1. When designing a simple robot controlled remotely with basic commands (start, stop, turn) via
Bluetooth or Zigbee, which factors (range, power consumption, ease of use) are most critical for
selecting the optimal wireless protocol?
2. In a network of temperature sensors deployed across a large farm for data collection, battery life
and reliable data transmission are crucial. How do the characteristics of LoRaWAN and Zigbee
protocols influence their suitability for this application?
3. When using Bluetooth communication between two Arduinos that are paired and within range but
not transmitting data, what troubleshooting steps can be taken to identify the cause of the
communication failure?
4. What potential factors, such as network node density, power limitations, or wireless interference,
could contribute to data loss in a Zigbee sensor network? How can these factors be addressed to
improve network stability?
5. While Wi-Fi offers high data rates suitable for live video streaming from an Arduino project, its
power consumption can limit battery life. What alternative approaches, such as reducing video
resolution, exploring LoRaWAN (despite its lower data rate), or optimizing Arduino code, could
be considered to balance video quality, data transmission needs, and battery life?

References:

You might also like