20dit057 Iot
20dit057 Iot
PRACTICAL - 1
IMPLIMANTATION :
Step 1: Simply follow this link to download Instant Contiki.
Step 3: Start your virtualization software like Vmware or Virtualbox and load your Instant
Contiki File. In Vmware click Open a Virtual Machine as shown below
DEPSTAR-IT 1
IT444 - Internet of Things 20DIT057
Step 7: Enter your credentials and start using Instant Contiki (Username and Password is
user).
DEPSTAR-IT 2
IT444 - Internet of Things 20DIT057
PRACTICAL - 2
AIM : Study of different types of motes and deploy them using IoT
architecture. Simulate Hello World program using Cooja.
THEORY :
MicaZ mote:
The MICAz is a 2.4 GHz Mote module used for enabling low-power, wireless sensor
networks.
Supported by MoteWorks™ wireless sensor network platform for reliable, ad-hoc
mesh networking
MoteWork enables the development of custom sensor applications and is specifically
optimized for low-power, battery-operated networks.
Sky mote:
Tmote Sky is an ultra low power wireless module for use in sensor networks,
monitoring applications, and rapid application prototyping.
Tmote Sky leverages industry standards like USB and IEEE 802.15.4 to interoperate
seamlessly with other devices.
ESB:
The ESB (Embedded Sensor Board) is a prototype wireless sensor network device
developed at FU Berlin.
The ESB consists of a Texas Instruments MSP430 low-power microcontroller with
2k RAM and 60k flash ROM, a TR1001 radio transceiver, a 32k serial EEPROM, an
RS232 port, a JTAG port, a beeper, and a number of sensors (passive IR, active IR
sender/receiver, vibration/tilt, microphone, temperature).
The Contiki/ESB port contains drivers for most of the sensors. The drivers were
mostly adapted from sources from FU Berlin.
CC430 mote:
Z1 mote:
DEPSTAR-IT 3
IT444 - Internet of Things 20DIT057
IMPLIMANTATION :
Let’s Simulate Hello World Program using Cooja, for that click on Cooja which
shows in Contiki’s home screen.
New simulation.
DEPSTAR-IT 4
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 5
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 6
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 7
IT444 - Internet of Things 20DIT057
PRACTICAL - 3
AIM : Create a scenario by adding some motes. Do the simulation for the
same. Also observe the result for said scenario. When one mote send the
signal then led should turn green while one receive then it should show red
color.
IMPLIMANTATION :
1) Make a folder inside the contiki directory named ‘led programming’.
2) Copy the MakeFile file from the ‘hello world’ folder and copy it in the ‘led
programming’.
3) Make a file named led.c and write the following code in it.
DEPSTAR-IT 8
IT444 - Internet of Things 20DIT057
4) Create a new simulation and add new sky motes. Add new process source and select
the before created led.c file. Compile and create the motes.
5) Now right click on the motes and select Show LED Click button.
6) Start the simulation and observe.
DEPSTAR-IT 9
IT444 - Internet of Things 20DIT057
PRACTICAL - 4
IMPLIMANTATION :
1) For this task, we will add a sky mote as router and other motes to receive signals and
we will observe the radio traffic between them.First of all, we will open Cooja
simulator and create new simulator.
2) We will browse through example folder to find ipv6 > rpl-borer-router >
borderrouter.c. We will compile it and press create.
DEPSTAR-IT 10
IT444 - Internet of Things 20DIT057
4) To create receiving motes, we will follow the same process to add sky motes. This
time, we will browse to ipv6 > sky-websense > sky-websense.c.
5) We will need more receivers for better visualization so we will add 5 motes.
DEPSTAR-IT 11
IT444 - Internet of Things 20DIT057
6) We can change some view options as our convenience.see the traffic, we will right
click on server and go to Mote tools for Sky 1 > Serial Socket (SERVER)
8) To get more information about traffic, we can go to tools > Radio messages.
DEPSTAR-IT 12
IT444 - Internet of Things 20DIT057
10) Now, to visualize the content of simulator in browser, we will run the following
command into different terminal.
Commands :
cd Contiki/examples/ipv6/rpl-border-router/ Make connect-router-cooja
11) Now, if we write ip address of router in browser like firefox, we will be able to see
its neighbour’s information.
DEPSTAR-IT 13
IT444 - Internet of Things 20DIT057
12) And if we search for ip address of any receiver mote, we will be able to get its sensed
data like light and temperature.
DEPSTAR-IT 14
IT444 - Internet of Things 20DIT057
PRACTICAL - 5
IMPLIMANTATION :
DEPSTAR-IT 15
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 16
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 17
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 18
IT444 - Internet of Things 20DIT057
PRACTICAL - 6
IMPLIMANTATION :
THEORY :
Node Red:
MQTT:
MQTT is an OASIS standard messaging protocol for the Internet of Things (IoT).
It is designed as an extremely lightweight publish/subscribe messaging transport that
is ideal for connecting remote devices with a small code footprint and minimal
network bandwidth.
MQTT today is used in a wide variety of industries, such as automotive,
manufacturing, telecommunications, oil and gas, etc.
PRACTICAL :
DEPSTAR-IT 19
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 20
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 21
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 22
IT444 - Internet of Things 20DIT057
When we click add, the server will be created and we will fill a couple of fields there
like topic and QoS.
We will provide same configuration for MQTT in node but we don’t need to create
MQTT Broker again.
We will give input string in timestamp node. We change the timestamp to string of
“Hello world” and give it the topic name same as MQTT nodes.
Now we can deploy our model by “Deploy” button on top right corner.
We can see “Successfully deployed” message.
And in a moment, we will be able to see connected status if there is no error.
In debug console, which can be opened from right panel, we can see the output
received by.
DEPSTAR-IT 23
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 24
IT444 - Internet of Things 20DIT057
PRACTICAL - 7
IMPLIMANTATION :
THEORY :
Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with
constrained nodes and constrained networks in the Internet of Things. CoAP is designed to
enable simple, constrained devices to join the IoT even through constrained networks with
low bandwidth and low availability. It is generally used for machine-to-machine (M2M)
applications such as smart energy and building automation. The protocol was designed by
the Internet Engineering Task Force (IETF), CoAP is specified in IETF RFC 7252.
CoAP Features
IMPLIMANTATION :
DEPSTAR-IT 25
IT444 - Internet of Things 20DIT057
2) Now, create sky mote name router from rpl-border-router and select file border-
router.c.Compile the file and set quantity as 1.
3) Create 2nd sky mote and name as server, select file from er-rest-examples>er-server-
example-server.c. Begin the compilation of file.
DEPSTAR-IT 26
IT444 - Internet of Things 20DIT057
6) Make the connection of router and server by giving the command in terminal.
7) Connection is established.
DEPSTAR-IT 27
IT444 - Internet of Things 20DIT057
8) Now start the simulation and measure/analyse the network. Set the 3rd node in such a
way that it is not in the range of router.
DEPSTAR-IT 28
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 29
IT444 - Internet of Things 20DIT057
12) Select core and click the get button, we can see the results of testing, sensors,
actuators.
13) Now click the toggle button and give 1 in the outgoing section and post the data on
the network.
DEPSTAR-IT 30
IT444 - Internet of Things 20DIT057
14) By giving the data from the browser check the mote interface shown in the figure.
DEPSTAR-IT 31
IT444 - Internet of Things 20DIT057
PRACTICAL - 8
AIM : Implement mini project and connect with IBM Bluemix &
Thingspeak for data collection on cloud and plot the graph of it. Plotting
data on thingspeak.com. Take analog input from ESP and pass that data
to api.thingspeak.com and prepare a 2 online graph.
THEORY :
Bluemix:
Bluemix is the IBM open cloud platform that provides mobile and web developers
access to IBM software for integration security transaction and other key functions as
well as software from business partners.
Built on Cloud Foundry open source technology Bluemix provides pre-built Mobile
Backend as a Service (MBaaS) capabilities. Bluemix offers more control to
application developers by using its Platform as a Service (PaaS) offering. The goal is
to simplify the delivery of an application by providing services that are ready for
immediate use and hosting capabilities to enable internal scale development.
With the broad set of services and runtimes in Bluemix the developer gains control
and flexibility and has access to various data options from predictive analytics to big
data.
Bluemix provides the following features:
A range of services that enable you to build and extend web and mobile apps fast
Processing power for you to deliver app changes continuously
Fit-for-purpose programming models and services
Manageability of services and applications
Optimized and elastic workloads
Continuous availability
Thingspeak:
ThingSpeak allows you to aggregate, visualize and analyze live data streams in the
cloud. Some of the key capabilities of ThingSpeak include the ability to:
Easily configure devices to send data to ThingSpeak using popular IoT Simulate
CoAPs.
Visualize your sensor data in real-time.
Aggregate data on-demand from third-party sources.
Use the power of MATLAB to make sense of your IoT data.
Run your IoT analytics automatically based on schedules or events.
Prototype and build IoT systems without setting up servers or developing web
software.
Automatically act on your data and communicate using third-party services like
Twilio or Twitter
DEPSTAR-IT 32
IT444 - Internet of Things 20DIT057
PROGRAM :
Bluemix:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <PubSubClient.h>
#include "DHT.h"
WiFiClient wifiClient;
PubSubClient client(server, 1883, NULL, wifiClient);
DHT dht(DHTPIN, DHTTYPE);
void setup()
{ Serial.begin(960
0); dht.begin();
Serial.println();
Serial.print("Connecting to ");
Serial.print(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
if (!client.connected())
{ Serial.print("Reconnecting client to
"); Serial.println(server);
while (!client.connect(clientId, authMethod, token)) {
DEPSTAR-IT 33
IT444 - Internet of Things 20DIT057
Serial.print(".");
delay(500);
}
Serial.println("Bluemix connected");
}
}
long lastMsg = 0;
void loop() {
client.loop();
long now = millis();
if (now - lastMsg > 3000) {
lastMsg = now;
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
String payload = "{\"d\":{\"Name\":\"" DEVICE_ID "\"";
payload += ",\"temperature\":";
payload += temperature;
payload += "}}";
DEPSTAR-IT 34
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 35
IT444 - Internet of Things 20DIT057
Thingspeak:
#include <ESP8266WiFi.h>
#define SENSOR A0
void setup()
{ Serial.begin(960
0); delay(10);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
float value = 0;
void loop()
{ delay(500
0);
value = analogRead(A0);
Serial.print("connecting to ");
Serial.println(host);
Serial.println("connection done");
// We now create a URI for the request
String url = "/update?";
url += "key=";
url += privateKey;
url += "&field1=";
url += value;
// Read all the lines of the reply from server and print them to Serial
while (client.available()) {
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();
Serial.println("closing connection");
}
DEPSTAR-IT 37
IT444 - Internet of Things 20DIT057
DEPSTAR-IT 38
IT444 - Internet of Things 20DIT057
PRACTICAL - 9
THEORY :
ZigBee module:
DEPSTAR-IT 39
IT444 - Internet of Things 20DIT057
Zigbee is not for situations with high mobility among nodes. Hence, it is not suitable
for tactical ad hoc radio networks in the battlefield, where high data rate and high
mobility is present and needed.
DEPSTAR-IT 40
IT444 - Internet of Things 20DIT057
PRACTICAL - 10
THEORY :
Environmental monitoring:
Since each TinyOS system can be embedded in a small sensor, they are useful in
monitoring air pollution, forest fires, and natural disaster prevention
Smart vehicles:
Smart vehicles are autonomous and can be understood as a network of sensors. These
sensors communicate through low-power wireless area networks (LPWAN) which
makes TinyOS a perfect fit.
DEPSTAR-IT 41
IT444 - Internet of Things 20DIT057
Smart cities:
TinyOS is a viable solution for the low-power sensor requirements of smart cities’
utilities, power grids, Internet infrastructure and other applications.
TinyOS models:
1. Data model:
Static Memory Allocation
No Heaps or any other dynamic structures used.
Memory requirements determined at compile time.
This increases the runtime efficiency.
Global variables
Allocated on per frame basis.
Local Variables
Saved on the stack
Defined in the function/method
2. Thread model:
Power-Aware Two-levels Scheduling
Long running tasks and interrupt events
DEPSTAR-IT 42
IT444 - Internet of Things 20DIT057
3. Programming model:
Construction of Modules
Modules implementation similar to C coding
Programs are built out of components
Each component specifies an interface
Interfaces are “hooks” for wiring components
Composition of Configurations
Components are statically wired together
Increases programming efficiency (code reuse) a runtime efficiency.
4. Component model:
Components should use and provide bidirectional interfaces.
Components should call and implement commands and signal and
handle events.
Components must handle events of used interfaces and also provide
interfaces that must implement commands.
DEPSTAR-IT 43