Iot Worksheet
Iot Worksheet
INDEX
Exp. List of Experiments Conduct Viva Record Total Remarks
No (M.M:12) (M.M:10) (M.M:8) (M.M:30)
1.
Familiarization with
Arduino/Raspberry Pi
hardware and perform
necessary software
installation.
2. Identification of different
sensors used in IoT
applications.
3. Demonstration of
Autodesk Tinkercad
Simulation Platform.
6. Interfacing of
Arduino/Raspberry Pi
with temperature and
humidity sensor with real
time application.
7. To display data
generated by sensor on
LCD using
Arduino/Raspberry Pi.
1. Aim:
2. Objective:
3. System Requirements:
• Windows 7 or above.
• Google Chrome
• Arduino IDE
4. Steps/Program:
Arduino Uno consists of 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog
inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button
1. Power USB Arduino board can be powered by using the USB cable from your computer. All you
need to do is connect the USB cable to the USB connection (1).
2. Power (Barrel Jack) Arduino boards can be powered directly from the AC mains power supply by
connecting it to the Barrel Jack (2).
3. Voltage Regulator The function of the voltage regulator is to control the voltage given to the Arduino
board and stabilize the DC voltages used by the processor and other elements.
4. Crystal Oscillator The crystal oscillator helps Arduino in dealing with time issues. How does
Arduino calculate time? The answer is, by using the crystal oscillator. The number printed on top of
the Arduino crystal is 16.000H9H. It tells us that the frequency is 16,000,000 Hertz or 16 MHz.
5. 17.Arduino Reset You can reset your Arduino board, i.e., start your program from the beginning.
You can reset the UNO board in two ways. First, by using the reset button (17) on the board. Second,
you can connect an external reset button to the Arduino pin labelled RESET (5).
• The Arduino UNO board has 14 digital I/O pins (15) (of which 6 provide PWM (Pulse Width
Modulation) output. These pins can be configured to work as input digital pins to read logic values (0
or 1) or as digital output pins to drive different modules like LEDs, relays, etc. The pins labeled “~”
can be used to generate PWM.
16. AREF
AREF stands for Analog Reference. It is sometimes, used to set an external reference voltage
(between 0 and 5 Volts) as the upper limit for the analog input pins
Program an Arduino:
• The most important advantage with Arduino is the programs can be directly loaded to the device
without requiring any hardware programmer to burn the program.
• This is done because of the presence of the 0.5KB of Boot-loader which allows the program to be
burned into the circuit.
• All we have to do is to download the Arduino software and writing the code.
• The Arduino tool window consists of the toolbar with the buttons like verify, upload, new, open,
save, serial monitor.
• It also consists of a text editor to write the code, a message area which displays the feedback like
showing the errors, the text console which displays the output and a series of menus like the File,
Edit, Tools menu.
• Declaration of Variables
• Initialisation: It is written in the setup () function.
• Control code: It is written in the loop () function.
2. The sketch is saved with .ino extension. Any operations like verifying, opening a sketch, saving a
sketch can be done using the buttons on the toolbar or using the tool menu.
3. The sketch should be stored in the sketchbook directory.
4. Chose the proper board from the tools menu and the serial port numbers.
5. Click on the upload button or chose upload from the tools menu. Thus the code is uploaded by the
boot loader onto the micro controller.
8. Now find the Arduino shortcut on your Desktop and click on it. The IDE will open up and you’ll see
the code editor:
• Understand the function of Node MCU, Arduino Uno and Raspberry Pi.
• Learnt about Arduino IDE.
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):
1. Aim:
2. Objective:
3. System Requirements:
• Windows 7 or above.
• Google Chrome
• Arduino IDE
4. Steps/Program:
Sensors:
The sensors are defined as a machine, module, or a device that detect changes in the environment. The
sensors transfer those changes to the electronic devices in the form of a signal. A sensor and electronic
devices always work together. The output signal is easily readable by humans. Nowadays, Sensors are used
in daily lives. For example, controlling the brightness of the lamp by touching its base, etc. The use of
sensors is expanding with new technologies.
The sensor is a device, which is made up of Single Crystal Silicon. It is considered as a widely used
semiconductor material. It has superior mechanical stability, machinability, etc. It can also combine
electronics and sensing elements on the same substrate. The sensors are used to measure the physical
quantities, such as pressure, temperature, sound, humidity, and light, etc. An example of sensors is Fire
Alarm, a detector present on the fire alarm detects the smoke or heat. The signal generated from the detector
is sent to the alarming system, which produces an alert in the form of alarm. The types of detectors are
smoke detectors, heat detectors, carbon monoxide detectors, multi-sensors detectors, etc.
1. Temperature sensors
A temperature sensor is a device used to measure temperature. This can be air temperature, liquid
temperature or the temperature of solid matter. There are different types of temperature sensors available
and they each use different technologies and principles to take the temperature measurement.
2. Proximity sensor
A proximity sensor is a sensor able to detect the presence of nearby objects without any physical contact.
A proximity sensor often emits an electromagnetic field or a beam of electromagnetic radiation (infrared, for
instance), and looks for changes in the field or return signal. The object being sensed is often referred to as
the proximity sensor's target. Different proximity sensor targets demand different sensors.
3. Pressure sensor
A pressure sensor is a device for pressure measurement of gases or liquids. Pressure is an expression of the
force required to stop a fluid from expanding, and is usually stated in terms of force per unit area. A pressure
sensor usually acts as a transducer; it generates a signal as a function of the pressure imposed. For the
purposes of this article, such a signal is electrical.
4. Gas sensor
A gas detector is a device that detects the presence of gases in an area, often as part of a safety system. A
gas detector can sound an alarm to operators in the area where the leak is occurring, giving them the
opportunity to leave. This type of device is important because there are many gases that can be harmful to
organic life, such as humans or animals.
5. Smoke sensor
A smoke detector is a sensor that detects smoke as a primary indication of fire. It provides a signal to a fire
alarm system in a large building, or produces an audible and visual signal locally in a room or a home.
Smoke detectors are usually housed in a small, round shaped plastic case, and placed at the roof where there
are risks of fire or fire hazards.
6. IR sensors
A motion sensor (or motion detector) is an electronic device that is designed to detect and measure
movement. Motion sensors are used primarily in home and business security systems, but they can also be
found in phones, paper towel dispensers, game consoles, and virtual reality systems. Unlike many other
types of sensors (which can be handheld and isolated), motion sensors are typically embedded systems with
three major components: a sensor unit, an embedded computer, and hardware (or the mechanical
component). These three parts vary in size and configuration, as motion sensors can be customized to
perform highly specific functions. For example, motion sensors can be used to activate floodlights, trigger
audible alarms, activate switches, and even alert the police.
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):
1. Aim:
Demonstration of Autodesk Tinkercad Simulation Platform.
2. Objective:
• Learn about IoT based simulations.
• Testing and model in IoT based simulation platform.
3. System Requirements:
• Google Chrome
• Arduino IDE
• Tinkercad
4. Steps/Program:
Introduction of Tinkercad
Tinkercad - https://www.tinkercad.com is an excellent tool that allows you to simulate Arduino-based systems (and a lot
more). You can (perhaps you SHOULD) simulate all exercises and even your own designs before trying them on real
hardware. It also allows you to do programming using blocks. You can download / copy-paste the generated code later into
Arduino IDE to program the real Arduino board, rather than having to write it from scratch.
Create a new personal account on Tinkercad website (you can also use your Google account to log in). Then select Circuits
on the left pane, and click Create new Circuit.
Hardware
In Components Basic, you can select Arduino Uno R3.
You can rotate it to portrait mode if you wish, which will allow more space for other components to be added.
You can add more components and wire them up as desired. Clicking on the lead of a component allows you to start a
connecting wire from there. Clicking on a wire allows you to change its color.
Programming and Simulation
To program the Arduino,
1. Click on Code
2. You can choose Blocks or Blocks+Text or Text*. For beginners, it is recommended to use Blocks + Text.
• This allows you to see the C++ code generated corresponding to your blocks.
• You can copy this code later into Arduino IDE to program the real Arduino, rather than having to write it
from scratch.
• You can also download the code as an Arduino-compatible .ino file.
3. You can code by selecting the blocks and connecting them appropriately.
4. You can start the simulation by clicking Start Simulation.
You have to click Stop Simulation to stop the simulation before you can modify your program and/or hardware connections.
Debugging (Advanced)
More often than not, the code written by a programmer does not work as expected the very first time he/she runs it. We need
to find out the logical flaws in our code and fix them before we are able to achieve full functionality. Figuring out flaws
usually boil down to inspecting variable values at various points in our code, and comparing it with the expected values at
those points based on the program logic and data inputs. The usual way Arduino programmers do it is by printing out the
variable values to Serial console.
Tinkercad allows for debugging without having to print the values you want to inspect through Serial.
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):
1. Aim:
2. Objective:
3. Requirements:
➢ 1 × Breadboard
➢ 1 × Arduino Uno R3
➢ 1 × LED
➢ 1 × 330Ω Resistor
➢ 2 × Jumper
4. Procedure:
LEDs are small, powerful lights that are used in many different applications. To start, we will work on blinking an LED,
the Hello World of micro controllers. It is as simple as turning a light on and off. Establishing this important baseline
will give you a solid foundation as we work towards experiments that are more complex.
➢ Step 1: Start a new sketch in the Arduino IDE. Start a new sketch in the Arduino IDE:
➢ Step 2: Set the pinMode for Pin 5. ...
➢ Step 3: Set Pin 5 HIGH. ...
➢ Step 4: Compile the code. ...
➢ Step 5: Upload the code to Arduino.
Note − To find out the polarity of an LED, look at it closely. The shorter of the two legs, towards the flat edge of the bulb
indicates the negative terminal.
Components like resistors need to have their terminals bent into 90° angles in order to fit the breadboard sockets properly.
You can also cut the terminals shorter.
Sketch
Open the Arduino IDE software on your computer. Coding in the Arduino language will control your circuit. Open the new
sketch File by clicking New.
➢ pinMode(5, OUTPUT) − Before you can use one of Arduino’s pins, you need to tell Arduino Uno R3 whether it is
an INPUT or OUTPUT. We use a built-in “function” called pinMode() to do this.
➢ digitalWrite(5, HIGH) − When you are using a pin as an OUTPUT, you can command it to be HIGH (output 5
volts), or LOW (output 0 volts).
5. Steps/Program:
pinMode(LED_BUILTIN,OUTPUT);
pinMode(5, OUTPUT);
void loop() { // the loop function runs over and over again forever
// put your main code here, to run repeatedly:
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(5, HIGH);
delay(10000);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(5, LOW);
delay(10000);
1. Aim:
2. Objective:
3. Requirements:
• Arduino Uno R3 board
• Ultrasonic sensor (HC-SR04)
• 16×2 LCD I2C Display
• Jumper Wires
4. Procedure:
Arduino:
It is an open-source electronics platform. It consists ATmega328 8-bit Micro controller. It can be able to read inputs from
different sensors & we can send instructions to the micro controller in the Arduino. It provides Arduino IDE to write code &
connect the hardware devices like Arduino boards & sensors.
Ultrasonic Sensor:
An ultrasonic Sensor is a device used to measure the distance between the sensor and an object without physical contact.
This device works based on time-to-distance conversion.
So, the known parameters are time and speed (constant). Using these parameters, we can calculate the distance traveled by
the sound wave.
Formula: Distance = Speed * Time
In the code, the “duration” variable stores the time taken by the sound wave traveling from the emitter to the receiver. That
is double the time to reach the object, whereas the sensor returns the total time including sender to object and object to
receiver. Then, the time taken to reach the object is half of the time taken to reach the receiver.
Setup:
1. Connect the Echo pin of the sensor to the D2 pin of the Arduino.
2. Connect the Trig pin of the sensor to the D3 pin of the Arduino.
3. Navigate to Tools and select board and port.
4. Verify and compile the code, then upload the code to the Arduino Uno R3 board.
5. Monitor the output in the Serial monitor (Set the baud rate as 9600). To open Serial monitor Tools>Serial
Monitor or (Ctrl+Shift+M).
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C
lcd(0x20, 16, 2); // Format => (ADDRESS,Width,Height )
void setup()
{
// ....
}
5. Steps/Program:
#define echoPin \
long duration; // Variable to store time taken to the pulse to reach receiver
void setup()
Serial.begin(9600);
delay(500);
void loop()
digitalWrite(trigPin, LOW);
digitalWrite(
delayMicroseconds(10); // keep the trigger "ON" for 10 ms to generate pulse for 10 ms.
digitalWrite(trigPin,LOW);
Serial.print("Distance: ");
Serial.println(" cm");
delay(100);
}
6. Output:
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):
1. Aim:
Interfacing of Arduino/Raspberry Pi with temperature and humidity sensor with real time application.
2. Objective:
3. Requirements:
• Arduino Uno R3 board
• Ultrasonic sensor (HC-SR04)
• Jumper Wires
4. Procedure:
DHT11 Sensor:
DHT11 Module features a temperature & humidity sensor complex with a calibrated digital signal output. The exclusive
digital-signal-acquisition technique and temperature & humidity sensing technology ensure high reliability and excellent
long-term stability. This sensor includes an NTC for temperature measurement and a resistive-type humidity
measurement component for humidity measurement. These are connected to a high- performance 8-bit microcontroller,
offering excellent quality, fast response, anti-interference ability, and cost effectiveness.
The schematic diagram for the DHT11 module is given below. As mentioned earlier, the board has a very low
components count. The VCC and GND are directly connected to the DHT11 and a pullup resistor is added to the DATA
pin. Sufficient filtering is provided with the tantalum and multilayer capacitors. An LED with a current limit resistor is
used as a power indicator.
Humidity Sensor:
The humidity sensor is a device that senses, measures, and reports the relative humidity (RH) of air or determines the
amount of water vapor present in gas mixture (air) or pure gas. Humidity sensing is related to a water adsorption and
desorption process.
5. Steps/Program:
#include <dht.h>
dht DHT;
void setup() {
Serial.begin(9600);
}
void loop(){
int chk = DHT.read11(7); //digital pin 7 for input of temperature
Serial.print("temperature: ");
Serial.println(DHT.temperature);
Serial.print("humidity: ");
Serial.println(DHT.humidity);
delay(1000);
}
6. Output:
Learning outcomes (What I have learnt):
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):
1. Aim:
2. Objective:
3. Requirements:
• Arduino Uno R3 board
• LCD
• Jumper Wires
4. Procedure:
The LCD (Liquid Crystal Display) is a type of display that uses the liquid crystals for its operation. The library that allows
us to control the LCD display is called Liquid Crystal Library.
The library is based on a compatible chipset called Hitachi HD44780. It is found on most of the LCDs that are based on text.
It works with either an 8-bit mode or 4-bit mode. Here, the bit mode signifies the data lines in addition to the enable, rs, and
rw control lines (optional).
LCD Structure
The Liquid Crystal Display has a parallel interface. It means that the microcontroller operates several pins at once to control
the LCD display.
• Pin1(Vss): Ground pin of the LCD module.
• Pin3(VEE): Contrast adjustment pin. This is done by connecting the ends of a 10K potentiometer to +5V and
ground and then connecting the slider pin to the VEE pin. The voltage at the VEE pin defines the contrast. The
normal setting is between 0.4 and 0.9V.
• Pin4(RS): Register select pin. The JHD162A has two registers namely command register and data register. Logic
HIGH at RS pin selects data register and logic LOW at RS pin selects command register. If we make the RS pin
HIGH and feed an input to the data lines (DB0 to DB7), this input will be treated as data to display on LCD screen.
If we make the RS pin LOW and feed an input to the data lines, then this will be treated as a command (a command
to be written to LCD controller – like positioning cursor or clear screen or scroll).
• Pin5(R/W): Read/Write modes. This pin is used for selecting between read and write modes. Logic HIGH at this
pin activates read mode and logic LOW at this pin activates write mode.
• Pin6(E): This pin is meant for enabling the LCD module. A HIGH to LOW signal at this pin will enable the
module.
• Pin7(DB0) to Pin14(DB7): These are data pins. The commands and data are fed to the LCD module though these
pins.
• Pin15(LED+): Anode of the back light LED. When operated on 5V, a 560-ohm resistor should be connected in
series to this pin. In Arduino based projects the back light LED can be powered from the 3.3V source on the
Arduino board.
5. Steps/Program:
#include "LiquidCrystal.h"
LiquidCrystal lcd(8,7,6,5,4,3);
int GAS_VAL = 0;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print(" Experiment 7 ");
}
void loop()
{
GAS_VAL = analogRead(A0);
Serial.println(GAS_VAL);
if (GAS_VAL > 500)
{
lcd.setCursor(0,1);
lcd.print(" GAS Detected");
}
else
{
lcd.setCursor(0,1);
lcd.print(" GAS Not Detect");
}
delay(10); // Delay a little bit to improve simulation performance
}
6. Output:
Learning outcomes (What I have learnt):
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):
1. Aim:
2. Objective:
3. Requirements:
• Arduino Uno R3 board
• LCD
• Jumper Wires
• MQ135 Air Quality Sensor.
4. Procedure:
MQ-135 sensor belongs to the MQ series that are used to detect different gasses present in the air. The MQ-135 sensor is
used to detect gases such as NH3, NOx, alcohol, Benzene, smoke, CO2, etc. steel exoskeleton houses a sensing device
within the gas sensor module.
Specifications
The table below shows some key specifications of the MQ-135 sensor module:
Feature Description
Pinout
Circuit
The MQ-135 sensor module consists of four pins namely VCC, GND, DO, and DO. The table below gives a brief
description of them.
Pin Description
VCC Positive power supply pin that powers up the sensor module.
Analog output pin. It generates a signal proportional to the concentration of gas vapors coming in
AO
contact with the sensor.
Digital Output pin. It also produces a digital signal whose limit can be set using the in-built
DO
potentiometer.
5. Steps/Program:
int sensorValue;
int digitalValue;
void setup()
{
Serial.begin(9600); // sets the serial port to 9600
pinMode(13, OUTPUT);
pinMode(2, INPUT);
}
void loop()
{
sensorValue = analogRead(0); // read analog input pin 0
digitalValue = digitalRead(2);
if (sensorValue > 400)
{
digitalWrite(13, HIGH);
}
else
digitalWrite(13, LOW);
Serial.println(sensorValue, DEC); // prints the value read
Serial.println(digitalValue, DEC);
delay(1000); // wait 100ms for next reading
}
#include "LiquidCrystal.h"
LiquidCrystal lcd(8,7,6,5,4,3);
int GAS_VAL = 0;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print(" Experiment 7 ");
}
void loop()
{
GAS_VAL = analogRead(A0);
Serial.println(GAS_VAL);
if (GAS_VAL > 500)
{
lcd.setCursor(0,1);
lcd.print(" GAS Detected");
}
else
{
lcd.setCursor(0,1);
lcd.print(" GAS Not Detect");
}
delay(10); // Delay a little bit to improve simulation performance
}
6. Output:
Learning outcomes (What I have learnt):
1. Aim:
Real Time application of controlling actuators through bluetooth application using Arduino.
2. Objective:
3. Requirements:
• Arduino Uno R3 board
• HC-05
• Jumper Wires
• 1k Resistor
4. Procedure:
a) Arduino Bluetooth:
Bluetooth module is a basic circuit set of chip which integrated Bluetooth functions and which can be used in
wireless network transmission. Generally, the Bluetooth module can be divided into the following types: data
transmission module, remote control module, etc.
Flexible and packed with high Bluetooth transmission speed, the Grove – Blueseeed LE – Dual Model (HM13)
uses a CSR dual-mode Bluetooth chip, with the ARM architecture single chip that supports AT instructions.
This allows users like yourself to have control over the serial baud rate, equipment name, and pairing password!
You may be wondering; why not the HC-06 or HC-05 Arduino Bluetooth module instead? Well, with the Grove –
Blueseeed – Dual Model (HM13), you’re getting the following key advantages:
Bluetooth 4.0 BLE rather than Bluetooth V2.0
b) Hardware configurations:
Step 1: Connect the Grove – Blueseeed – Dual model (HM13) to a Grove port on the Grove – Base Shield via the
Grove cable
Step 2: Plug Grove – Base Shield into your Arduino board
Step 3: Connect your Arduino to PC via USB cable
c) Understanding the software:
Conventions
In EDR mode, only the slave can be configured while either master or slave can be in BLE mode.
Factory default setting: EDR Name HMSoft, Slave role, PinCode 1234
BLE Name HMSoft, Slave role, PinCode 000000
Baud: 115200, N, 8, 1;
AT Command format: Uppercase AT command format. string format, without any other symbol. (e.g. \r or \n).
Any incorrect command would get no response.
Step 5: Hit “Write new value” and write some words to start sending data to the PC
5. Steps/Program:
#include <SoftwareSerial.h>
SoftwareSerial SUART(10, 11); // SRX = 2, STX = 3
#define ledpin 13 //built-in L of UNO
void setup()
{
pinMode(ledpin, OUTPUT);
digitalWrite(ledpin, LOW); //L is OFF
Serial.begin(9600);
SUART.begin(9600);
}
void loop()
{
if (SUART.available())
{
char x = SUART.read();
if (x == 'Y')
{
digitalWrite(ledpin, HIGH); //L is ON
}
if (x == 'N')
{
digitalWrite(ledpin, LOW); //L is OFF
}
}
if(Serial.available())
{
char c = Serial.read();
SUART.write(c);
}
}
6. Output:
Learning outcomes (What I have learnt):
1. Aim:
Study the Implementation of Zigbee Protocol using Raspberry Pi/Arduino.
2. Objective:
3. Requirements:
• Arduino Uno R3 board
• Jumper Wires
• 1k Resistor
• 2 XBee Pro S2 Transceiver
• 2 UART to USB adapter board1 USB
Cord
4. Procedure:
Introduction
XBee wireless transceivers provide a quick, easy way to add wireless communication to any system. This page
will outline how to set up two XBee Pro Series 2 transceivers for communication with each other.
After selecting the Test/Query button, you should see a dialogue box like the one below. You will want to record
the serial number shown, as you will need it in a couple minutes.
After recording the serial number you can click OK. Next, select the Modem Configurationtab at the top of the
window. Once here, select the read button. This will bring up the current configuration for the connected XBee
and will be similar to the following:
Once here, you want to select Zigbee Coordinator AT in the function set drop down menu.
After selecting the coordinator function set, you will need to set the PAN ID. This can beany four-digit number
and allows the XBees to distinguish between modules in their network and those from other networks. Once you
have added the wanted PAN ID click the “Write” button. This will update and configure the XBee. Once this is
done you can disconnect the XBee and plug in the second XBee.
After re-connecting the coordinator to the computer. You will again go into the Modem Configuration tab and
click the read button. You will then want to set the Destination Address to the serial number of the Router XBee
in the same manner as you just did for the Router. Once done you will again click the write button to update the
coordinator XBeesettings. After the write process is complete you are ready to use your XBees and communicate
wirelessly
When typing single characters, you should see a screen similar to the one above. To send strings of data you can
assemble a data packet. To do this click the “Assemble Packet” button and type the wanted string into the box
then click send data. This will send the entire packet before receiving the same packet back.
If everything you type is being reflected back in red, you are successfully transmitting andreceiving with your
XBees!! You are now ready to use them however you wish. You canconnect them to any microcontroller and
transmit data through the UART peripheral or you can connect each XBee to a different computer and have a chat
application. There aremany more possibilities that are now at your fingertips with your working XBees.
About Zigbee
Zigbee is a wireless communication protocol targeted for battery-powered devices (it has both low power and
low cost). It generally operates in the 2.4GHz range (although there are geographic variations), and supports data
ranges from 20 to 250 kbits/s. The transmission distance though, is small compared to the likes of LoRa. It is 10
to 100 m, whereas LoRa can transmit over a few kilometers. Another thing to note is that Zigbee communication
doesn’t work very well if there is no line of sight between transmitter andreceiver.
These works with UART and therefore, it is fairly easy to interface them with Arduino. Itis important to look at
the pinout of XBee though, to understand which are the UART pins
The DOUT and DIN pins in the figure above are the UART pins (TX and RX). They can be connected to two
digital pins of Arduino (if you plan to use SoftwareSerial), or else topins 0 and 1 of Arduino respectively (if you
plan to use HW Serial). Please note that you
won’t be able to read print statements from the Arduino on the Serial Monitor if you use Hardware Serial for
Zigbee interface.
• You will need a breakout board or an Explorer with a USB to UART converter for thisconfiguration.
• The PAN ID (Personal Area Network ID) has to be the same for the devices that want tocommunicate with
each other.
• One module needs to be set as the transmitter and the other as the receiver (this isdetermined by the
CE field).
• Note the baud rate that you set. This will be used in the Arduino code, when configuringthe Serial
communication with XBee.
Circuit Diagram
Once your XBee is configured, you can connect it to the Arduino via the breakout/Explorerboard. In that case, the
pinout will be slightly different depending on which board/ Explorer you are using. Here we will assume you are
connecting the XBee directly to Arduino Uno, in which case, the connections will be –
5. Steps/Program:
#include <SoftwareSerial.h>
SoftwareSerial xbeeSerial(2,3); //RX, TX
void setup() {
Serial.begin(9600);
xbeeSerial.begin(9600);
}
void loop() {
if(Serial.available() > 0){ char
input = Serial.read();
xbeeSerial.print(input);
}
}
void setup() {
Serial.begin(9600);
xbeeSerial.begin(9600);
}
void loop() {
if(xbeeSerial.available() > 0){char
input = xbeeSerial.read();
Serial.print(input);
}
}
6. Output:
Learning outcomes (What I have learnt):