Lab 2 Config IoT Devices
Lab 2 Config IoT Devices
Smart Things are physical objects that can connect to the Registration Server or Home
Gateway through a network interface. They are separated into 4 subcategories : Home,
Smart City, Industrial, and Power Grid.
Components are physical objects that connect to microcontroller (MCU-PT) or single
boarded computers (SBC-PT). They typically does not have a network interface and rely on
the MCU-PT or SBC-PT for network access. These are simple devices that only communicate
through their analog or digital slots.
There are three subcategories for Components :
The Home Gateway provides 4 ethernet ports as well as a wireless access point configured with
the "HomeGateway" ssid on channel 6. WEP / WPA-PSK / WPA2 enterprise can be configured
to secure wireless connections. The picture below shows 4 IOE Things attached to a Home
Gateway The Home Gateway is connected to the Internet through it's Internet WAN ethernet
port.
Page-1
The IoE Things can be remotely managed through a web interface hosted by the Home
Gateway. The Home Gateway internal (LAN) IP address is 192.168.25.1 but it can also be
accessed through it's Internet facing IP address (not configured in this lab, configuration done
with a wifi connected laptop). The following screenshot displays the status of the 4 IOE Thngs
connected to the gateway.
Page-2
IoE components in Packet Tracer 7.1.1
3. Connecting IoE components
As they don't have ethernet interface, IoE components can't be directly connected to the Home
Gateway. These smaller sensors or actuators are connected to a microcontrollers (MCU-PT)
card. The MCU-PT is connected to the gateway which only sees the microcontroller board but
not the IoE components. The Home Gateway relies on the remote control API eventually
programmed on the MCU-PT to get the sensor's status.
Real world MCU are for example Arduino boards like the Arduino Yún Shield
function setup() {
pinMode(1, OUTPUT);
Serial.println("Blinking");
}
function loop() {
digitalWrite(0, HIGH);
delay(1000);
digitalWrite(0, LOW);
delay(500);
}
Page-3
As you can see on the screenshot below, Packet Tracer 7.1.1 emulates Arduino integrated
development environment (IDE) for IoT objects programming.
Page-4
The table below lists all the things available in Packet Tracer 7.0 and their behaviors with
respect to the simulated environment :
Page-5
Fire Sprinkler, Affects Water Level at a rate of 0.1 cm per
Ceiling Sprinkler second.
Page-6
LED Affects Visible Light with a maximum
output of 1%.
Page-7
Temperature Monitor Detects Ambient Temperature.
Page-8
AC, Affects Humidity at a rate of -2% per hour.
Air Cooler
Affects Ambient Temperature at a rate of -
10°C per hour.
The project is based on microcontroller board designs, produced by several vendors, using
several microcontrollers. Arduino boards provide digital and analog input/output (I/O) pins
that can interface to different expansion boards and other circuits. The boards feature serial
and USB communication interfaces for loading programs from computers to the boards.
Structure
setup() If defined, this function is The setup() function is called when a sketch
called once when the starts. Use it to initialize variables, pin modes,
program starts. start using libraries, etc. The setup function
will only run once, after each powerup or reset
function setup() { of the Arduino board.
pinMode(0, INPUT);
} void setup()
{
Page-9
Serial.begin(9600);
pinMode(buttonPin, INPUT);
}
Digital I/O
pinMode(slot, Set a digital slot to INPUT Configures the specified pin to behave either
mode) or OUTPUT. as an input or an output.
Page-10
delay(1000); // waits for a second
}
digitalWrite(slot, Writes to a digital slot with Write a HIGH or a LOW value to a digital pin.
value) HIGH or LOW.
void loop()
digitalWrite(1, HIGH);
{
digitalWrite(ledPin, HIGH); // sets the LED o
n
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED o
ff
delay(1000); // waits for a second
}
A MCU board connected to smoke and temperature sensors will act as a remote Fire Detection
Unit. The board will be securely wifi connected to a 829 ISR router.
A SBC board connected to a visual alarm will act as a Fire Alarm System.
Both IoT board will register to a central IoE server which will provide automation capabilities
to raise the Fire Alarm if a fire is detected by the Remote Fire Sensor.
Page-11
ISR829 router wireless configuration with WPA-PSK encryption
1. Setup an IP address on the wlan-ap0 interface for integrated AP managment
3. Configure the SSID with the following settings. Here is configured the SSID, the
authentication mode, and the WPA-PSK key.
interface Dot11Radio0
no ip address
bridge-group 1
encryption mode ciphers aes-ccm
ssid TEST
5. Go back to the router configuration. The data path of the integrated AP is linked to the
router's Wlan-GigabitEthernet0 interface (not the AP interface).
interface Wlan-GigabitEthernet0
switchport mode access
7.Configure DHCP on the router for vlan 1 :
Page-12
IoE MCU board registration
Add a wireless connector to the MCU board and configure wireless settings to connect it to the
remote 829 router. On the config tab, configure the address of the remote IoE server
(192.168.20.2) with the following user/password (user : register, password : register)
The IoEClient.reportStates(states) reports the states of this device to the IoE server. The
argument is a string representing all states of this device. The argument can also be an array
representing all states. The number of states must match the length of the states property in
the IoEClient.setup() function.
function setup() {
pinMode(1, OUTPUT);
IoEClient.setup({
type: "Fire Detection",
states: [{
name: "Fire",
type: "bool"
},
{
name: "Temperature",
type: "number",
unit: "°C",
imperialUnit: "°F",
toImperialConversion: "x*1.8+32",
toMetricConversion: "(x-32)/1.8",
decimalDigits: 1
},
{
name: "Smoke Level",
type: "number",
unit: "ppm",
decimalDigits: 1
}]
});
}
function loop() {
Page-14
var SmokeLevel = analogRead(A0);
var Temperature = analogRead(A1);
var FireDetected=false;
if (SmokeLevel>50 || Temperature>580) {
digitalWrite(0, HIGH);
FireDetected=true;
}
else {
digitalWrite(0, LOW);
FireDetected=false;
}
IoEClient.reportStates([FireDetected,Temperature,SmokeLevel]);
delay(500);
}
Page-15
}
function processData(data, bIsRemote) {
if ( data.length <= 0 )
return;
setState(parseInt(data));
}
function setState(newState) {
state = newState;
if ( state === 0 )
digitalWrite(0, LOW);
else
digitalWrite(0, HIGH);
customWrite(0, state);
IoEClient.reportStates(state);
setDeviceProperty(getName(), "state", state);
}
8. Practices - How to Simulate IoT projects using Cisco Packet Tracer
Steps to simulate IoT based Home Automation
a. Open Packet tracer
b. Select Home icon at the left bottom corner and now choose the required
Home components .
Page-16
c. Drag and place the components
Page-17
e. Thus now let’s establish a wireless connection. Go to Wireless devices
and choose Home Gateway
Page-18
h. Then paste the SSID In each appliance by clicking on the config option.
Similarly repeat the steps for other devices as well.
Page-19
Choose Home Gateway as IOT Server
j. Thus you can notice that all devices are connected to the Home
Gateway
Page-20
m. Thus your smart device is connected to your Home Gateway.
Click on smart device and choose Desktop. You can now login
Page-21
Result
Page-22