IoT Advanced Program & Automation PDF
IoT Advanced Program & Automation PDF
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.
3. Configure the SSID with the following settings. Here is configured the SSID, the
authentication mode, and the WPA-PSK key.
authentication open
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
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
default-router 192.168.100.1
interface Vlan1
3
VNIT-CS : www.vncs.com.vn ; www.daotaocntt.org
4
VNIT-CS : www.vncs.com.vn ; www.daotaocntt.org
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({
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
},
type: "number",
unit: "ppm",
decimalDigits: 1
}]
});
5
VNIT-CS : www.vncs.com.vn ; www.daotaocntt.org
function loop() {
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);
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);
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);