You are on page 1of 7

VNIT-CS : www.vncs.com.vn ; www.daotaocntt.

org

IoT Advanced
programming & automation

Contents
1.Tutorial description ............................................................................................................. 2
2.ISR829 router wireless configuration with WPA-PSK encryption ........................................ 2
3. IoE MCU board registration ............................................................................................... 4
4.Javascript code for the MCU Board (remote fire sensors) .................................................. 5
5. Javascript code for the SBC Board (visual fire alarm) ....................................................... 6

1
VNIT-CS : www.vncs.com.vn ; www.daotaocntt.org

1.Tutorial description
This tutorial will provide guidelines to simulate a fully automated IoT environment using the
capabilities of the new Cisco Packet Tracer 7.0 devices.

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 bord 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.

2.ISR829 router wireless configuration


with WPA-PSK encryption
1. Setup an IP address on the wlan-ap0 interface for integrated AP managment

2. Connect to the integrated AP (service-module wlan-ap0 session)

3. Configure the SSID with the following settings. Here is configured the SSID, the
authentication mode, and the WPA-PSK key.

dot11 ssid TEST

authentication open

authentication key-management wpa

wpa-psk ascii 0 AZERTYUIOP

guest-mode
2
VNIT-CS : www.vncs.com.vn ; www.daotaocntt.org
4. Configure the Dot11Radio0 interface with the following settings. Here is configured the
encryption mode and the link with the previously configured SSID.

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).

6.Configure the Wlan-GigabitEthernet0 interface as an access port in Vlan 1 :

interface Wlan-GigabitEthernet0

switchport mode access

7.Configure DHCP on the router for vlan 1 :

ip dhcp excluded-address 192.168.100.1 192.168.100.9

ip dhcp pool IoE_POOL

network 192.168.100.0 255.255.255.0

default-router 192.168.100.1

interface Vlan1

ip address 192.168.100.1 255.255.255.0

3
VNIT-CS : www.vncs.com.vn ; www.daotaocntt.org

3. 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)

4
VNIT-CS : www.vncs.com.vn ; www.daotaocntt.org

4.Javascript code for the MCU Board


(remote fire sensors)
The IoEClient.setup(api) function sets up the API for remote monitor and control from IoE
server. The api is an object describing the states reported by the IoE device and identifying the
one remote controlable [controlable: true] by the server.

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

}]

});

5
VNIT-CS : www.vncs.com.vn ; www.daotaocntt.org
function loop() {

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);

5. Javascript code for the SBC Board


(visual fire alarm)
var state = 0;

function setup() {

IoEClient.setup({

type: "FireAlarm",

states: [{

name: "On",

type: "bool",

controllable: true

}]

});

6
VNIT-CS : www.vncs.com.vn ; www.daotaocntt.org
IoEClient.onInputReceive = function(input) {

processData(input, true);

};

attachInterrupt(0, function() {

processData(customRead(0), false);

});

setState(state);

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);