Exercise-5-Arduino-to-Arduino-Communication Word
Exercise-5-Arduino-to-Arduino-Communication Word
LABORATORY WORK #5
ACTIVITY 5
SUBMITTED BY:
MANAOIS, ETHAN ZACHARY A.
DATE SUBMITTED:
MAY 26, 2024
SUBMITTED TO:
ENGR. GILFRED ALLEN M.
(INSTRUCTOR)
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:
· 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, MISOfor master-in-slave-out, and SSfor 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 involvesadditional 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:
Equipment Required:
Sample Arduino code for each communication protocol (provided or developed during the activity)
Procedures:
Transmitter:
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:
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:
CIRCUIT DIAGRAM
SIMULATION
Conclusion:
In summary, knowing the different ways Arduinos can communicate, both wired and wireless, is
important for choosing the best one for your projects. Using Proteus software to simulate how Arduinos
share data helps us see how each method works in real-time. This lets us understand the pros and cons of
each option. For example, wired methods like I2C and SPI are fast and reliable but need physical
connections, which can be a drawback in some setups. Wireless methods like Bluetooth, Zigbee, and
Wi-Fi offer more flexibility and range but might have issues like interference and higher power use.
Picking the right method for each project, whether it's simple robot control or a large sensor network,
ensures the best performance and efficiency in Arduino projects.
Questions to answer:
1. When designing a simple robot controlled remotely with basic commands (start, stop, turn)
viaBluetooth or Zigbee, which factors (range, power consumption, ease of use) are most critical
for selecting the optimal wireless protocol?
When designing a simple robot that is controlled remotely using basic commands through Bluetooth or
Zigbee, it's important to consider range, power consumption, and ease of use when choosing the best wireless
protocol. The range affects how far you can control the robot, which is important for flexibility. Power consumption
impacts battery life and how long the robot can operate without needing a recharge. Ease of use determines how
simple it is to set up and operate the control system, making sure it can be quickly and easily managed.
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?
In a large farm with temperature sensors, battery life and reliable data transmission are very important. The
features of LoRaWAN and Zigbee protocols play a big role in determining their suitability. LoRaWAN is a great
choice because it has excellent battery life and reliable long-range communication, making it perfect for large areas
with low power use. Zigbee also has good battery life and effective medium-range communication. Its mesh
networking improves reliability by letting data hop between nodes, though it might use more power than
LoRaWAN.
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?
If you're having trouble with two Arduinos connected via Bluetooth that are within range but not sending
data, try these steps to fix it. First, make sure both devices have power and that the Bluetooth modules are properly
connected. Then, check that the baud rates of the Bluetooth modules match. Confirm that the devices are paired
correctly and re-pair them if needed. Also, look for any interference from other electronics or physical barriers.
Using simpler communication scripts can help find and solve the problem.
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?
Several factors can lead to data loss in a Zigbee sensor network, including the density of
network nodes, power constraints, and wireless interference. High node density can result in
congestion, but this can be reduced by optimizing the network layout and using proper channel
allocation to manage traffic. Power limitations, such as nodes running out of battery, can be
addressed by using energy-efficient devices and performing regular maintenance. Interference
from other wireless signals can disrupt communication, but selecting less crowded channels and
utilizing Zigbee’s frequency agility can help keep the network stable.
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?
Wi-Fi offers fast data rates that are great for live video streaming from an Arduino
project, but it uses a lot of power, which can drain the battery quickly. To manage video quality,
data needs, and battery life, there are a few alternatives to consider. Lowering the video
resolution can reduce the data rate and power use, which helps the battery last longer while still
keeping the video quality decent. While LoRaWAN doesn't work for live video because of its
low data rate, it can still send important updates if needed. Also, improving the Arduino code to
use power-saving methods like sleep modes and better data handling can help extend battery life.