0% found this document useful (0 votes)
32 views56 pages

ESIOT Manual

The document introduces the Arduino platform and programming. It describes the Arduino board components, how to install the microcontroller board in the Arduino IDE, and provides a pictorial representation of an Arduino board.

Uploaded by

Keerthi Ga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views56 pages

ESIOT Manual

The document introduces the Arduino platform and programming. It describes the Arduino board components, how to install the microcontroller board in the Arduino IDE, and provides a pictorial representation of an Arduino board.

Uploaded by

Keerthi Ga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

KINGS ENGINEERING COLLEGE

(Approved by AICTE, New Delhi & Affiliated to the Anna University, Chennai)
CHENNAI-BANGALORE HIGH ROAD, OPP. TO HYUNDAI CAR COMPANY IRUNGATTUKOTTAI,
SRIPERUBUDUR, CHENNAI – 602 117

DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

CS3691 – EMBEDDED SYSTEM AND IOT LABORATORY

NAME: ____________________________

REG NO: _____________________________

YEAR: _____________________________
EX NO 1

8051 ASSEMBLY LANGUAGE EXPERIMENTS USING SIMULATOR

DATE:

a) Write an assembly language program to transfer N=____bytes of data from location


A: ____________h to location B: _____________h.

AIM:

To write an assembly language program to transfer N bytes of data from the location A
to location B.

PROGRAM:

Let N=05h , A:30h B: 40h

mov r0,#30h //source address

mov r1,#40h //destination address

mov r7,#05h //Number of bytes to be moved

back: mov a,@r0

mov @rl,a

inc r0

inc r1

djnz r7,back //repeat till all data transferred

end
OUTPUT:

RESULT:

Thus, the assembly language program to transfer the N bytes of data from location A
to location B has been executed successfully.
(b) Write an assembly language program to find the largest element in a given array of
N = _________ h bytes at location 4000h. Store the largest element at location 4062h.

AIM:

To write an assembly language program to find the largest element in a given array.

PROGRAM:

Let N=06h

mov r3,#6 //length of the array

mov dptr,#4000H //starting address of array

mov a,@dptr

mov r1,a

nextbyte: inc dptr

movx a,@dptr

clr c //reset borrow flag

mov r2,a //next number in the array

subb a,r1 //other Num-Prev largest no.

jc skip // JNC FOR SMALLEST


ELEMENT

mov a,r2 //update larger number in rl

mov r1,a

skip: djnz r3,nextbyte

mov dptr,#4062H //location of the result-4062h

mov a,r1 //largest number

movx @dptr,a //store at #4062H

end
OUTPUT:

RESULT

Thus, the assembly language program to find the largest element is a given array has been
executed successfully.
(C) Write an assembly language program to sort an array of N=__________h bytes of
data in ascending/descending order stored from location 9000h. (using bubble sort
algorithm).

AIM:

To write an assembly language program to sort an array of data in ascending/ descending


order stored from location 9000h.

PROGRAM:

Let N=06h

mov r0,#05H //count (N-1) array size=N

loop 1: mov dptr,#9000h //array stored from address 9000h

mov r1,#05h //initialize exchange counter

loop 2: movx a, @dptr //get number from array and store in B register

mov b,a

inc dptr

movx a, @dptr //next number in the array

clr c //reset borrow flag

mov r2,a //store in R2

sub a,b //2nd-1st No, since no compare instruction in 8051

jnc noexchg //JC-FOR DESCENDING ORDER

mov a,b // exchange the 2 nos in the array

movx @dptr,a

dec dpl //DEC DPTR – instruction not present

mov a,r2

movx @dptr,a

inc dptr

noexchg: djnz r1,loop2 //decrement compare counter


djnz r0,loop1 //decrement pass counter

end

OUTPUT:

RESULT:

Thus, the assembly language program to sort an array of data in


ascending/descending order stored from location 9000h has been executed successfully.
EX NO. 02

PERFORM ALU OPERATIONS

DATE:

AIM:

To write ALP for performing ALU operations.

THEORY:

Arithmetic instruction programming refers to the process of creating computer programs


that involve performing mathematical operations on data. Arithmetic instructions are
fundamental components of assembly language and machine-level programming. They allow
you to manipulate numerical values, calculate results, and perform various mathematical
operations within a computer's central processing unit (CPU).

Arithmetic instruction programming is a low-level and powerful way to perform


mathematical operations within a computer program. It offers fine-grained control over the
CPU's resources and is often used when performance, efficiency, or hardware interaction is a
priority.

The arithmetic instructions perform the basic operations such as:

1. Addition

2. Multiplication

3. Subtraction

4. Division

PROGRAM:

a. Addition of two 16- bit numbers.

mov r0,#34h //lower nibble of No. 1

mov r1,#12h //higher nibble of No. 1

mov r2,#0dch //lower nibble of No.2

mov r3,#0feh //higher nibble of No.2

clr c

mov a,r0
mov a,r2

mov 22h,a

mov a,r1

addc a,r3

mov 21h,a

mov 00h,c

end

OUTPUT:

b) Subtraction of two 16-bit numbers.

PROGRAM:

mov r0,#Odch //lower nibble of No. 1

mov r1,#0feh // higher nibble of No. 1

mov r2,#34h //lower nibble of No. 2

mov r3,#12h //higher nibble of No. 2

clr c

mov a,r0

subb a,r2
mov 22h,a

mov a,r1

subb a,r3

mov 21 h,a

mov 00h,c

end

OUTPUT:

c. Square of given number.

PROGRAM:

Let N= 05

mov a,#05

mov b,a

mul ab

mov 30h,a

mov 31h,b

end
OUTPUT:

d) Cube of given number.

PROGRAM:

mov r0,#0fh

mov a,r0

mov b,r0

mul ab

mov r1,b

mov b,r0

mov ab

mov 32h,a

mov r2,b

mov a,r1

mov b,r0

mul ab

add a,r2

mov 31h,a

mov a,b

addc a,#00h

mov 30h,a

end
OUTPUT:

e) Logical operations AND, OR, XOR on two eight-bit numbers stored in internal RAM
locations 21h,22h.

PROGRAM:

mov a,21h //do not use #, as data ram 21h is to be accessed

mov a,22h //logical and operation

mov 30h,a //and operation result stored in 30h

mov a,21h

orl a,22h //logical or operation

mov 31h,a //or operation result stored in 31h

mov a,21h

xrl a,22h //logical xor operation

mov 32h,a //xor operation result stored in 32h

end

OUTPUT:

RESULT:

Thus, ALP for performing ALU operations is executed.


EX NO 03

WRITE BASIC AND ARITHMETIC PROGRAM USING EMBEDDED C

DATE:

AIM:

To write an ALP to display the numbers form ‘0 to F’ on four 7 segment displays.

PROGRAM:

#include<reg51.h>

sbit a=P3^0;

sbit b=P3^1;

sbit c=P3^2;

sbit d=P3^3;

void main()

unsignedchar n[10]={0x40.0xf9,0x24,0x30,0x19,0x12.0x02,0xF8,0 x E00,0x10};

unsigned inti,j;

a=b=c=d=1;

while(1)

for(i=0;i<10;i++)

P2=n[i];

for(j=0;j<60000;j++);

TIMER DELAY
WAR to generate the SOO us time delay using T1M2(timer1 and mode2)?

#include<reg51.h>

void main()

unsigned chari;

TMOD=0x20; //set the timer mode//

for(i=0i<2;i++) //double the timer delay//

TL1=0x19; //set the time delay//

TH1=0x00;

TR1=1;//timer ON//

While(TF1==0); //check the flag bit//

TF1=0;

TR1=0;//timer off//

}
OUTPUT:

RESULT:

Thus, the arithmetic program using embedded C to display the numbers form ‘0 to F’ on
four 7 segment displays has been executed successfully.
EX NO. 4

INTRODUCTION TO ARDUINO PLATFORM AND PROGRAMMING

DATE:

AIM:

To introduce Arduino platform and programming.

THEORY:

Arduino is a project, open-source hardware, and software platform used to design and build
electronic devices. It designs and manufactures microcontroller kits and single-board
interfaces for building electronics projects. The Arduino boards were initially created to help
the students with the non-technical background. The designs of Arduino boards use a variety
of controllers and microprocessors. The Arduino board consists of sets of analog and digital
I/O (Input / Output) pins, which are further interfaced to breadboard, expansion
boards, and other circuits. Such boards feature the model, Universal Serial Bus (USB),
and serial communication interfaces, which are used for loading programs from the
computers.

PICTORIAL REPRESENTATION OF ARDUINO


Installing the Microcontroller Board in Arduino IDE:

ESP 32

Prerequisites: Arduino IDE Installed

Before starting this installation procedure, make sure you have the latest version of the
Arduino IDE installed in your computer. If you don’t, uninstall it and install it again.
Otherwise, it may not work. Installing ESP32 Add-on in Arduino IDE.

To install the ESP32 board in your Arduino IDE, follow these next instructions:

i. In your Arduino IDE, go to File> Preferences

ii. Enter the following into the “Additional Board Manager URLs” field:
https://raw.githubusercontent.com/espressif/arduino-sp32/ghpages/package_esp32_index.json
Then, click the “OK” button.

iii. Open the Boards Manager. Go to Tools > Board > Boards Manager

iv. Search for ESP32 and press install button for the “ESP32 by Espressif Systems”:
v. That is it. It should be installed after a few seconds.

Testing the Installation

Plug the ESP32 board to your computer. With your Arduino IDE open, follow these steps:

1. Select your Board in Tools > Board menu (in my case it’s the DOIT ESP32 DEVKIT
V1)
2. Select the Port (if you don’t see the COM Port in your Arduino IDE, you need to
install the CP210x USB to UART Bridge VCP Drivers)
3. Open the following example under File > Examples > WiFi (ESP32) > WiFiScan
4. A new sketch opens in your Arduino IDE
5. Press the Upload button in the Arduino IDE. Wait a few seconds while the code
compiles and uploads to your board.
6. If everything went as expected, you should see a “Done uploading.” message.

7. Open the Arduino IDE Serial Monitor at a baud rate of 115200.


8. Press the ESP32 on-board Enable button and you should see the networks available
near your ESP32.

PIN CONFIGURATIONS
1. IR SENSOR - ESP32
2. O/P GPIO 4
3. BUZZER/LED GPIO 13

PROGRAM:

i) //Same code for both LED and Buzzer (mention Pin no)

// the setup function runs once when you press reset or power the board

void setup() {

// initialize digital pin LED_BUILTIN as an output.

pinMode(LED_BUILTIN, OUTPUT);

// the loop function runs repeatedly forever

void loop() {
digitalWrite(LED_BUILTIN, LOW); // turn the LED on (HIGH is the

voltage level)

delay(2000); // wait for a second

digitalWrite(LED_BUILTIN, HIGH); // turn the LED off by making the

voltage LOW

delay(1000); // wait for a second

OUTPUT:

ii) //Same code for both LED and IR sensor

// constants won't change. They're used here to set pin numbers:

const int buttonPin = 4; // the number of the pushbutton pin

const int ledPin = 13; // the number of the LED pin

// variables will change:

int buttonState = 0; // variable for reading the pushbutton status

void setup() {

// initialize the LED pin as an output:


pinMode(ledPin, OUTPUT);

// initialize the pushbutton pin as an input:

pinMode(buttonPin, INPUT);

void loop() {

// read the state of the pushbutton value:

buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:

if (buttonState == HIGH) {

// turn LED on:

digitalWrite(ledPin, LOW);

else {

// turn LED off:

digitalWrite(ledPin, HIGH);

OUTPUT:

RESULT:

Thus, Arduino IDE was installed and basic program was executed.
EX NO 5 EXPLORE DIFFERENT COMMUNICATION METHODS WITH IOT
DEVICES (ZIGBEE, GSM, BLUETOOTH)

DATE:

AIM:

To study various communication methods with IoT devices ZigBee, GSM, Bluetooth.

THEORY:

Zigbee

ZigBee is similar to Bluetooth and is majorly used in industrial settings. It has some
significant advantages in complex systems offering low-power operation, high security,
robustness and high and is well positioned to take advantage of wireless control and sensor
networks in IoT applications. The latest version of ZigBee is the recently launched 3.0, which
is essentially the unification of the various ZigBee wireless standards into a single standard.

Bluetooth

An important short-range IoT communications Protocols / Technology. Bluetooth,


which has become very important in computing and many consumer product markets. It is
expected to be key for wearable products, again connecting to the IoT albeit probably via a
smartphone in many cases. The new Bluetooth Low-Energy (BLE) – or Bluetooth Smart, as it
is now branded – is a significant protocol for IoT applications. Importantly, while it offers a
similar range to Bluetooth it has been designed to offer significantly reduced power
consumption.
How to Set Up and Test Arduino Bluetooth Connection

This works with android phones and the HC-05 and HC-06 bluetooth modules, as well as
pretty much any arduino or arduino clone.

Step 1: Connect the Bluetooth module to the Arduino like so

RX-pin2

TX-pin 3

GND-GND

VCC-5v

Step 2: Plug in the Arduino and Upload the Sketch

Download the ino file and upload it to the arduino.


(DOWNLOAD THIS FILE FROM :https://www.instructables.com/How-to-Set-Up-and-Test-
Arduino-Bluetooth-Connection//)

Step 3: Connect to the Bluetooth on Your Phone

Open up the bluetooth settings on your phone and look for the module. Mine is named
Sailfish but yours should be named either hc-05 or hc-06. The password is almost always
1234, if not, try 0000.

Step 4: Connect to the Bluetooth Module

Download a Bluetooth terminal app from the Appstore, this one work great:
https://play.google.com/store/apps/details?id=Qwerty.BluetoothTerminal&hl=en and open it
up. Open the app, hit connect to a device - insecure and select your Bluetooth module from
the list.
Step 5: Ready to Go!

Finally open up the Serial Monitor in the Arduino IDE by hitting the magnifying glass in the
top right corner, and you should be good to go. You now have a back and forth extremely
simple connection between your phone and your Arduino via Bluetooth.

Cellular

Any IoT application that requires operation over longer distances can take advantage of
GSM/3G/4G cellular communication capabilities. While cellular is clearly capable of sending
high quantities of data, especially for 4G, the cost and power consumption will be too high
for many applications. But it can be ideal for sensor-based low-bandwidth-data projects that
will send very low amounts of data over the Internet.
PIN CONFIGURATION

1. DHT 11 - ESP 32
2. O/P - GPIO 2

PROGRAM:

#include <BluetoothSerial.h>

#include "DHT.h"

#define dhtPin 2

#define DHTTYPE DHT11

DHT dht(dhtPin, DHTTYPE);

BluetoothSerial SerialBT;

void setup() {

Serial.begin(115200);

SerialBT.begin("ESP32_BT_Server"); // Set a name for Bluetooth server

dht.begin();

void loop() {

float temperature = dht.readTemperature(); // Read temperature value in


float humidity = dht.readHumidity(); // Read humidity value

if (isnan(temperature) || isnan(humidity)) {

Serial.println("Failed to read from DHT sensor!");

SerialBT.println("Failed to read from DHT sensor!");

return;

SerialBT.print("Temperature: ");

SerialBT.print(temperature);

SerialBT.print(" °C\t");

SerialBT.print("Humidity: ");

SerialBT.print(humidity);

SerialBT.println(" %");

delay(2000);

OUTPUT:
PIN CONFIGURATION

1. DHT 11 - ESP 32
2. O/P - GPIO 2(On Board LED)

PROGRAM:

#include <BluetoothSerial.h>

#if !defined(CONFIG_BT_ENABLED) ||

!defined(CONFIG_BLUEDROID_ENABLED)

#error Bluetooth is not enabled! Please run `make menu config` to and enable

it

#endif

#define ledPin 2

BluetoothSerial SerialBT;

String message = "";

char incomingChar;

void setup() {

pinMode(ledPin, OUTPUT);

Serial.begin(115200);

SerialBT.begin("ESP32"); //Bluetooth device name

Serial.println("The device started, now you can pair it with bluetooth!");

void loop() {

if (SerialBT.available()){

char incomingChar = SerialBT.read();

if (incomingChar != '\n'){

message += String(incomingChar);

}else{
message = "";

Serial.write(incomingChar);

if (message =="on"){

digitalWrite(ledPin, HIGH);

else if (message =="off"){

digitalWrite(ledPin, LOW);

delay(20);

OUTPUT:

RESULT:

Thus, study various communication methods with IoT devices ZigBee, GSM, Bluetooth was
done.
EX NO 6 INTRODUCTION TO RASPBERRY PI PLATFORM AND
PYTHON PROGRAMMING

DATE:

AIM:

To introduce Raspberry Pi Platform and Python programming.

THEORY:

Raspberry Pi, developed by Raspberry Pi Foundation in association with Broadcom, is a


series of small single-board computers and perhaps the most inspiring computer available
today. From the moment you see the shiny green circuit board of Raspberry Pi, it invites you
to tinker with it, play with it, start programming, and create your own software with it.
Earlier, the Raspberry Pi was used to teach basic computer science in schools but later,
because of its low cost and open design, the model became far more popular than anticipated.
It is widely used to make gaming devices, fitness gadgets, weather stations, and much more.
But apart from that, it is used by thousands of people of all ages who want to take their first
step in computer science. It is one of the best-selling British computers and most of the
boards are made in the Sony factory in Pencoed, Wales. In 2012, the company launched the
Raspberry Pi and the current generations of regular Raspberry Pi boards are Zero, 1, 2, 3, and
4.

Generation 1 Raspberry Pi had the following four options −

• Model A
• Model A +
• Model B
• Model B +

Among these models, the Raspberry Pi B models are the original credit-card sized format.

On the other hand, the Raspberry Pi A models have a smaller and more compact footprint and
hence, these models have the reduced connectivity options.

Raspberry Pi Zero models, which come with or without GPIO (general-purpose input output)
headers installed, are the most compact of all the Raspberry Pi boards types.
PROGRAM:

CONTROL LED:

import RPi.GPIO as GPIO

import time

GPIO.setmode(GPIO.BCM)

GPIO.setup(18,GPIO.OUT)

while True:

GPIO.output(18,True)

time.sleep(1)

GPIO.output(18,False)

time.sleep(1)
OUTPUT:

RESULT:

Thus, Raspberry Pi is introduced and python program for controlling LED is executed.
EX NO 7 INTERFACING SENSORS WITH RASPBERRY PI

DATE:

AIM:

To interface sensors with Raspberry Pi.

THEORY:

The Raspberry Pi IR Sensor Interface can be converted into a Proximity Detector,


where the application will detect if the object is too close to the sensor.

CIRCUIT DIAGRAM:

COMPONENTS REQUIRED:

 Raspberry Pi 3 Model B
 IR Sensor
 5V Buzzer
 Mini Breadboard
 Connecting Wires
 Power Supply
 Computer

CIRCUIT DESIGN:
The IR Sensor Module has only three Pins: VCC, GND and Data. Connect the VCC and
GND pins of the IR Sensor to +5V and GND pins of the Raspberry Pi. Then connect the Data
pin of the IR Sensor to GPIO23 i.e., Physical Pin 16 of the Raspberry Pi. To indicate the
alarm, I have used a simple 5V Buzzer. Connect one terminal of the buzzer to GND of
Raspberry Pi and the other terminal (usually marked +) to GPIO24 i.e., Physical Pin 18 of
Raspberry Pi.

1) BUTTON AND LED INTERFACE


from machine import Pin
import utime as time
led = Pin(27, Pin.OUT)
sensor = Pin(28, Pin.IN)
while True:
time.sleep(1)
print(sensor.value())
if sensor.value()==0:
led.value(1)
else:
led.value(0)

OUTPUT:

2) RASPBERRY PI PICO AND DHT11 INTEFACE


from machine import Pin, I2C
import utime as time
import sys
import dht
sensor = dht.DHT11(Pin(28))
while True:
time.sleep(5)
sensor.measure()
t = (sensor.temperature)
h = (sensor.humidity)
print("Temperature: {}".format(sensor.temperature))
print("Humidity: {}".format(sensor.humidity))

OUTPUT:

3) RGB LIGHT
from machine import Pin
import utime
red = Pin(11, Pin.OUT)
green = Pin(12, Pin.OUT)
blue = Pin(13, Pin.OUT)
while True:
red.value(0)
green.value(0)
blue.value(0)
utime.sleep(2)

red.value(1)
green.value(0)
blue.value(0)
utime.sleep(2)

red.value(0)
green.value(0)
blue.value(0)
utime.sleep(2)
red.value(0)
green.value(1)
blue.value(0)
utime.sleep(2)
red.value(0)
green.value(0)
blue.value(0)
utime.sleep(2)

red.value(0)
green.value(0)
blue.value(1)
utime.sleep(2)

OUTPUT:

RESULT:

The sensors are interfaced with Raspberry Pi successfully.


EX NO 8 SETUP A CLOUD PLATFORM TO LOG THE DATA

DATE:

AIM:

To setup a cloud platform to log the data.

PROCEDURE: -

1. Creating an Arduino Account

To starting using the Arduino IoT cloud, we first need to log in or sign up to Arduino.

2. Go to the Arduino IoT Cloud

After we have signed up, you can access the Arduino IoT Cloud from any page on arduino.cc
by clicking on the four dots menu in the top right corner. You can also go directly to the
Arduino IoT Cloud.

Navigating to the cloud.

3. Creating a Thing

The journey always begins by creating a new Thing. In the Thing overview, we can choose
what device to use, what Wi-Fi network we want to connect to, and create variables that we
can monitor and control. This is the main configuration space, where all changes we make are
automatically generated into a special sketch file.

The Thing overview

4. Configuring a Device

Devices can easily be added and linked to a Thing. The Arduino IoT Cloud requires your
computer to have the Arduino Create Agent installed. The configuration process is quick and
easy, and can be done by clicking on the “Select device” button in the Thing overview. Here,
we can choose from any board that has been configured, or select the “Configure new device”
option.
Configuring a device

We can also get a complete overview of our devices by clicking the “Devices" tab at the top
of the Arduino IoT Cloud interface. Here we can manage and add new devices.

The device tab

5. Creating Variables

The variables we create are automatically generated into a sketch file. There are several data
types we can choose from, such as int, float, boolean, long, char. There are also special
variables, such as Temperature, Velocity, Luminance that can be used. When clicking on the
“Add variable” button, we can choose name, data type, update setting and interaction mode.

Creating variables
6. Connecting to a Network

To connect to a Wi-Fi network, simply click the “Configure” button in the network section.
Enter the credentials and click “Save”. This information is also generated into your sketch
file!

Entering network credentials

7. Editing the Sketch

An automatically generated sketch file can be found in the “Sketch” tab. It has the same
structure as a typical .ino file, but with some additional code to make the connection to your
network and to the cloud. A sketch that, for example, reads an analog sensor, and use the
cloud variable to store it. When the sketch has been uploaded, it will work as a regular sketch,
but it will also update the cloud variables that we use. Additionally, each time we create a
variable that has the Read & Write permission enabled, a function is also generated, at the
bottom of your sketch file. Each time these variable changes, it will execute the code within
this function! This means that we can leave most of the code out of the loop () and only run
code when needed.To upload the program to our board, simply click the "Upload" button.
The editor also has a Serial Monitor Tool, which can be opened by clicking the magnifying
glass in the toolbar. Here you can view information regarding your connection, or commands
printed via

Serial.print()

The Serial Monitor Tool

After we have successfully uploaded the code, we can open the “Serial Monitor” tab to view
information regarding our connection. If it is successful, it will print “connected to
network_name” and “connected to cloud”. If it fails to connect, it will print the errors here as
well. The cloud editor is a mirrored "minimal" version of the Web Editor. Any changes you
make will also be reflected in the Web Editor, which is more suitable for developing more
advanced sketches.

8. Creating a Dashboard

Now that we have configured the device & network, created variables, completed the sketch
and successfully uploaded the code, we can move on to the fun part: creating dashboards!
Visualize your data

Dashboards are visual user interface for interacting with your boards over the cloud, and we
can setup many different setups depending on what your IoT project needs. We can access
our dashboards by clicking on the “Dashboards” tab at the top of the Arduino IoT Cloud
interface, where we can create new dashboards, and see a list of dashboards created for other
Things.

Navigating to dashboards

If we click on “Create new dashboard”, we enter a dashboard editor. Here, we can create
something called widgets. Widgets are the visual representation of our variables we create,
and there are many different to choose from. Below is an example using several types of
widgets.
The different widgets available

When we create widgets, we also need to link them to our variables. This is done by clicking
on a widget we create, select a Thing, and select a variable that we want to link. Once it is
linked, we can either interact with it, for example a button, or we can monitor a value from a
sensor. As long as our board is connected to the cloud, the values will update.

Let's say we have a temperature widget that we want to link to the temperature variable inside
the Cloud project thing.

Linking a variable to a widget.

Note that not all widgets and variables are compatible. A switch and an integer can for
example not be linked, and will not be an option while setting up your dashboard.

We can also have several things running at once, depending on your Arduino IoT Cloud plan,
which we can include in the same dashboard. This is a great feature for tracking multiple
boards in for example a larger sensor network, where boards can be connected to different
networks around the world, but be monitored from the same dashboard.

RESULT:

Thus, IOT devices are logged in cloud successfully.


EXP NO 9 LOG DATA USING RASPBERRY PI AND UPLOAD TO THE
CLOUD PLATFORM

DATE:

AIM:

To log data using Raspberry Pi and upload data to the cloud platform.

THEORY:

ThingSpeak is an open IoT platform for monitoring your data online. In ThingSpeak channel
you can set the data as private or public according to your choice. ThingSpeak takes
minimum of 15 seconds to update your readings. Its a great and very easy to use platform for
building IOT projects.

There are also some other platforms available for monitoring your data online which we will
cover in later articles but there are some advantages of ThingSpeak over other platforms like
it is very easy to set up and it also has many options to plot graph.

Components Required

1. Raspberry Pi

2. Power Cable

3. WiFi or Internet

Step 1: Go to https://thingspeak.com.

Step 2: Create an account using Email-id.

Step 3: Now, create a channel.


Step 4: After the creation of channel ,go to the API Keys and copy the Write API Key.

Step 5: And now paste the Write API Key in your code and your channel number in place of
“myChannelNumber” and “myWriteAPIKey”.

Step 6: After pasting the API key and Channel number, now you can upload the code to
ESP32.

Step 7: Now you can view the temperature and humidity data in the form of graph in your
channel i.e., in the private view.
PROGRAM:

#include <WiFi.h> // Install the WiFi library

#include <DHT.h> //Install the DHT library

#include <ThingSpeak.h> //Install the ThingSpeak library

char* ssid = "SSID"; //enter SSID

char* passphrase = "PASS"; // enter the password

WiFiServer server(80);

WiFiClient client;

unsigned long myChannelNumber = CHANNEL NUMBER;

const char * myWriteAPIKey = "API KEY";

unsigned long lastTime = 0;

unsigned long timerDelay = 1000;

//----DHT declarations

#define DHTPIN 4 // Digital pin connected to the DHT sensor

#define DHTTYPE DHT11 // DHT 11

// Initializing the DHT11 sensor.

DHT dht(DHTPIN, DHTTYPE);

void setup()

Serial.begin(115200); //Initialize serial

Serial.print("Connecting to ");

Serial.println(ssid);

WiFi.begin(ssid, passphrase);

while (WiFi.status() != WL_CONNECTED) {

delay(500);

Serial.print(".");
}

// Print local IP address and start web server

Serial.println("");

Serial.println("WiFi connected.");

Serial.println("IP address: ");

Serial.println(WiFi.localIP());

server.begin();

//----nitialize dht11

dht.begin();

ThingSpeak.begin(client); // Initialize ThingSpeak

void loop ()

if ((millis() - lastTime) > timerDelay)

delay(2500);

// Reading temperature or humidity takes about 250 milliseconds!

float t = dht.readTemperature ();

// Read temperature as Celsius (the default)

float h = dht.readHumidity ();

float f = dht.readTemperature(true);

if (isnan(h) || isnan(t) || isnan(f)) {

Serial.println(F("Failed to read from DHT sensor!"));

return;

Serial.print("Temperature (ºC): ");


Serial.print(t);

Serial.println("ºC");

Serial.print("Humidity");

Serial.println(h);

ThingSpeak.setField(1, t);

ThingSpeak.setField(2, h);

// Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to

store up to 8 different

// pieces of information in a channel. Here, we write to field 1.

int x = ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey);

if(x == 200){

Serial.println("Channel update successful.");

else{

Serial.println("Problem updating channel. HTTP error code " + String(x));

lastTime = millis();

}
OUTPUT:

RESULT:

The cloud platform is setup and log the data to the cloud is done.
EX NO 10 DESIGN AN IOT BASED SYSTEM

DATE:

AIM:

To design an IoT based system for Home Automation.

THEORY:

IoT devices and applications become more prevalent, it’s important to consider the ethical
implications of IoT design. Some key ethical considerations include privacy, security, data
ownership, and transparency. For example, imagine a smart home security system that uses
cameras and sensors to monitor a family’s activity. While the system may be effective in
preventing theft or intruders, it could also collect personal data about the family’s daily
routines and habits, which could be used for nefarious purposes if it falls into the wrong
hands.

How IoT engineers can address this issue:

1.Implement security measures: IoT designers should implement security measures


such as encryption and authentication to protect user data from unauthorized access.

2.Develop transparent data policies: IoT designers should develop transparent data
policies that clearly explain what data is being collected and how it will be used, as
well as obtain user consent before collecting any personal data.

3.Consider the impact on vulnerable populations: IoT designers should consider the
potential consequences of their designs, particularly for vulnerable populations such
as children, the elderly, or people with disabilities, and work to ensure that their
products are accessible and inclusive to all users.

4.Prioritize privacy by design: IoT designers should prioritize privacy by design,


which involves incorporating privacy considerations into the design process from the
beginning, rather than as an afterthought.

5.Educate users: IoT designers should provide clear and concise instructions on how
to use their products safely and securely, as well as provide resources for users to
learn more about IoT security and privacy best practices.

PROGRAM:

HOME AUTOMATION USING IOT

#define BLYNK_TEMPLATE_ID "TMPL3Wh1hKBQP"


#define BLYNK_TEMPLATE_NAME "Relay"

#define BLYNK_AUTH_TOKEN "ZnGEt8jHHcQ4pJ_Xj976QGkswyCgw5nG"

#define BLYNK_PRINT Serial

#include <WiFi.h>

#include <WiFiClient.h>

#include <BlynkSimpleEsp32.h>

#include "DHT.h"

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "your_ssid";

char pass[] = "pass";

#define DHTPIN 4 // Mention the digital pin where you

connected

#define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);

BlynkTimer timer;

void sendSensor(){

float h = dht.readHumidity();

float t = dht.readTemperature(); // or

dht.readTemperature(true) for Fahrenheit

if (isnan(h) || isnan(t)) {

Serial.println("Failed to read from DHT sensor!");

return;

Blynk.virtualWrite(V0, t);

Blynk.virtualWrite(V1, h);

Serial.print("Temperature : ");
Serial.print(t);

Serial.print(" Humidity : ");

Serial.println(h);

int ledpin = 2;

void setup(){

Serial.begin(115200);

Blynk.begin(auth, ssid, pass);

pinMode(ledpin,OUTPUT);

dht.begin();

timer.setInterval(1000L, sendSensor);

void loop(){

Blynk.run();

timer.run();

OUTPUT:

RESULT:

An IoT based system for Home Automation is been created.

You might also like