0% found this document useful (0 votes)
9 views36 pages

IBC Lecture Week3

Uploaded by

Umar Jawad
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)
9 views36 pages

IBC Lecture Week3

Uploaded by

Umar Jawad
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/ 36

BM470: IoT and

Biomedical
Computing

1
Overview

• IoT Hardware
– Sensors and Actuators

2
Class Activity
Arduino Programming

3
Tasks

• Read a potentiometer, print its state out to the Arduino


Serial Monitor.
• The bare minimum of code needed to start an Arduino
sketch
• Turn an LED on and off
• Read a switch, print the state out to the Arduino Serial
Monitor
• Reads an analog input and prints the voltage to the Serial
Monitor
4
The bare minimum

• void setup() {
• // put your setup code here, to run once:
• }

• void loop() {
• // put your main code here, to run
repeatedly:
• }

5
Read a potentiometer/print its state out to the
Arduino Serial Monitor
void setup() {
// initialize serial communication at 9600 bits per
Reads an analog input on pin 0, second:
prints the result to the Serial
Serial.begin(9600);
Monitor. Attach the center pin of a
potentiometer to pin A0, and the }
outside pins to +5V and ground.
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
} 6
Example 2
int potPin = A0; // Potentiometer wiper connected to
The potentiometer's position is analog pin A0
read as an analog input (ranging int potValue = 0; // Variable to store the potentiometer
from 0 to 1023), which can then be value
used for various applications, such
as adjusting brightness or void setup() {
controlling servo motors. Serial.begin(9600); // Start serial communication at 9600
bps
}

void loop() {
potValue = analogRead(potPin); // Read the
potentiometer value
Serial.println(potValue); // Print the value to the Serial
Monitor
delay(100); // Small delay for readability
}
7
Blink: Turn an LED on and off

• void setup() {
• On the UNO, MEGA and
ZERO, it is attached to • pinMode(LED_BUILTIN, OUTPUT);
digital pin 13, on • }
MKR1000 on pin 6.
• void loop() {
• LED_BUILTIN is set to the
correct LED pin • digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is
independent of which the voltage level)
board is used. • delay(1000); // wait for a second
• digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making
the voltage LOW
• delay(1000);
• }

8
Read a switch, print the state out to the Arduino
Serial Monitor.
// digital pin 2 has a pushbutton attached to it. Give it a name:
• Reads a digital int pushButton = 2;
input on pin 2, prints // the setup routine runs once when you press reset:
the result to the void setup() {
Serial Monitor
Serial.begin(9600);
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
}

void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
Serial.println(buttonState);
delay(1);
} 9
Reading an analog input/print to the Serial Monitor
void setup() {
• Reads an analog input on
pin 0, converts it to Serial.begin(9600);
}
voltage, and prints the
result to the Serial Monitor. void loop() {
// read the input on analog pin 0:
• Attach the center pin of a int sensorValue = analogRead(A0);
potentiometer to pin A0,
and the outside pins to // Convert the analog reading (which goes from 0 -
1023) to a voltage (0 - 5V):
+5V and ground.
float voltage = sensorValue * (5.0 / 1023.0);

// print out the value you read:

Serial.println(voltage);
} 10
11
Bridging Physical and Digital

• Sensors and actuators are the device components that


bridge the Internet and the physical world.
• Sensors convert energy readings from the physical
environment into numeric values that can be transmitted
digitally.
• Actuators convert digital instructions into mechanical
actions.

12
Cont..

13
SENSORS

• Sensors receive inputs from the physical world (e.g.,


motion, light, air quality, contact, location, proximity,
humidity, orientation, etc.).
• They detect the presence of energy or changes in energy
and quantify it, producing a numeric value.
• A digital thermometer usually converts heat energy to a
voltage, and then quantifies the voltage as a temperature
reading.
• Similarly, a photosensor might convert light energy to a
voltage then output a numeric reading. 14
Types of Sensors

• Sensors can be active or passive.


– Active sensors inject energy into the environment to detect
changes of some sort.
– Passive sensors detect energy that is already there.

The Samsung Galaxy


S5 has an active The Dropcam
sensor that can be connected camera
used to measure contains a passive
heart rate; it fires a infrared sensor to
red light through the detect motion
user’s finger, using
changes in light
level to measure
changes in blood flow
that indicate a pulse
15
Motion Detectors

• Working Principal: The motion detection systems used in stores


use beams of light shone across a room at photosensors: when
something (such as a robber) breaks the beam, the sensor
measures the loss of light.
• How??Motion detectors used in home security alarms tend to be
passive infrared sensors: human beings radiate infrared energy
with a wavelength of around 9–10 micrometers, so alarm sensors
are tuned to respond to rapid changes on this wavelength that
indicate a person moving around.
• Slower changes might simply mean that the room is warming up
as the sun moves around.
16
Location Sensor

• Location sensing is commonly used in applications for


mobile devices.
• A GPS receiver calculates its position by timing
transmissions received from GPS satellites.
• The tiny compasses found in mobile phones use
magnetic field sensing to tell which direction is north.
• Bluetooth beacons, can be used to enable indoor location
detection based on the proximity and signal strength of
the beacons.
17
Cont.

18
Accelerometers

• Accelerometers measure acceleration based on vibration.


• Used in mobile phones and tablets to detect screen orientation and
present the UI in landscape or portrait mode.
• Some alarm clocks use accelerometers to identify the best time to
wake the user.
• The clock is placed on the mattress and detects differences in the
sleeper’s movement during different sleep phases, waking them
during light sleep.
• Gyroscopes measure angular acceleration (rotation around an
axis), and can be used for more accurate movement measurement
than an accelerometer alone.
19
Cont.

The Remote uses an accelerometer to detect rotation; the WiiMotionPlus adds a gyroscope for more
accurate movement detection—this is used in many sports games

20
Activity tracking

• Requires a separate sensor but can now be achieved using a


smartphone’s onboard sensors.
• However, a dedicated sensor (such as a wearable tracker) may be
more accurate or a better fit for the context of use.

21
ACTUATORS

• Provide the means for a digital system to act on the


environment.
• They convert electrical energy into mechanical energy,
producing movement in the real world.
• This might control a motor, or simply turn something on or
off.
• Connected door locks, ceiling fans, and window shade
motors are all examples of consumer actuators. Even
bubble machines have been used as actuators
22
The Danalock connected door lock The Fortrezz water shutoff valve can
allows users to lock and unlock a door be programmed and controlled
from a smartphone remotely via a home automation app

23
Wireless Sensor Networks (WSN)

• WSN (Wireless sensor network) is an amalgamation of numerous


tiny nodes known as IoT devices, having sensors that are
emerging in a 5G environment area that is easily affected by
malicious users.
• Each sensor contains components like transceiver, microcontroller,
external memory, power source, etc.
• Due to ease of deployment and inexpensive nature of sensor
nodes, WSN is utilized in many important applications like armed
forces and security applications, seismic monitoring, health
monitoring, industrialized automation, robust monitoring, etc.

24
Cont.

• The healthcare WSN is considered as a broad area of research


because many critical applications in healthcare settings directly
or indirectly depend upon sensor networks.
• IoT devices communicate through various routing protocols.
Nodes with sensing capacity may be itinerant and motionless.
Itinerant sensor nodes can communicate through MANETs
(Mobile Ad-hoc Networks).
• Security is a major concern as any malicious user can misuse
critical information by launching dangerous types of attacks like
passive attack, routing attack, active attack, denial of service
attack, node replication attack, spoofing attack, etc.
25
Cont.
• The small-sized nodes have inherent limitations and thus privacy is a crucial
concern in IoT WSNs. Such networks are insecure due to malicious and
substantial attacks by means of transmission, untrusted communication, and
neglected scenery.
• The sensors in IoT devices have inadequate strength; therefore it is very
exigent to offer security to IoT devices with storage, energy, and computation
requirement.

26
Structure of IoT-WSNs
The components of IoT-WSN are:
• Sensor field: A sensor field is like a coverage area such as a forest, ocean,
home, etc., in which sensors are deployed in a distributed manner.
• Sensor node: This is a miniature machine or IoT device that contains
following components: transceiver, power source, microcontroller, sensing
unit, and processor. IoT devices collect, process, and record all the data
traffic that is communicated through the whole network.
• Sink: The sink is the point where every IoT device forwards the collected
healthcare data, which is later aggregated in order to start communication
with the sink station.
• Base station: It provides all the services to the user according to their
requirements. It manages all the communication tasks between the sensor
nodes or IoT devices.
27
Cont.

28
Characteristics of IoT-WSNs
• Scalability: Sensor networks possess dynamic topology in which we can
either increase or decrease the number of sensor nodes (IoT devices).
• Resilience: IoT-WSNs are highly resilient and provide an immediate service if
any fault or node failure occurs within the network.
• Self-organized: The randomly deployed IoT devices can adjust easily and
work in a cooperative manner. IoT devices may be mobile or static depending
upon whether we are using an ad-hoc network or not.
• Multi-hop communication: Sensor nodes (IoT devices) transmit the data
packets of healthcare systems through the multiple hops present among
sources and destinations.
• Application-oriented: Due to its very nature, IoT-WSNs can be effectively
used for application-oriented problems. The deployment of the IoT devices
done accordingly and its behaviour vary from application to application
29
Challenges of IoT-WSNs
• Real-time operation: Most critical applications of IoT-WSNs deal with real-time environments.
Successful transmission of medical data packets in real time is somewhat difficult. Message
loss by intermediate nodes, congestion, disturbing noise, and other transmission problems
delay the operation of IoT devices. Thus, the delivery of packets cannot be done in time,
which is the main challenge in WSNs.
• Security: Maintaining the security in WSNs is the biggest challenge. IoT networks are
developed in an environment where they can easily be affected by malicious activities. There
should be security methods associated with every sensor node.
• Unreliable communication: All the medical data packets are broadcasted through multiple
hops with connectionless routing protocols for large distances. In this way communication
between nodes is not reliable. Thus, there is a need to use connection-oriented protocols.
• Energy: Maintaining the overall energy of a sensor network is a big challenge. Every sensor
node has its own energy, which is consumed when the node transmits the medical data
packets. If there are large numbers of sensors, then more energy is required. There may be
the case when regular power becomes low or negligible. Thus, there should be technology
that works in the area of energy utilization of IoT-WSNs.
30
Security Concerns in IoT-WSNs

31
Class Activity

Arduino code examples

32
Tasks

• Problem: Read an analog input pin, map the result, and then use
that data to dim or brighten an LED.
• Algo: Reads an analog input pin, maps the result to a range from
0 to 255 and uses the result to set the pulse width modulation
(PWM) of an output pin. Also prints the results to the Serial
Monitor.
• The circuit: potentiometer connected to analog pin 0. Center pin of
the potentiometer goes to the analog pin.side pins of the
potentiometer go to +5V and ground. LED connected from digital
pin 9 to ground through 220 ohm resistor.

33
Code
• const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
• const int analogOutPin = 9; // Analog output pin that the LED is attached to
• int sensorValue = 0; // value read from the pot
• int outputValue = 0; // value output to the PWM (analog out)
• void setup() {
• Serial.begin(9600);
• }
• void loop() {
• sensorValue = analogRead(analogInPin);
• outputValue = map(sensorValue, 0, 1023, 0, 255); // map it to the range of the analog out:
• analogWrite(analogOutPin, outputValue); // change the analog out value:
• Serial.print("sensor = ");
• Serial.print(sensorValue);
• Serial.print("\t output = ");
• Serial.println(outputValue);
• delay(2);
• }
34
Task 2

• Problem: Use a potentiometer to control the blinking of an LED.


• Algo: Demonstrates analog input by reading an analog sensor on
analog pin 0 and turning on and off a light emitting diode(LED)
connected to digital pin 13. The amount of time the LED will be on
and off depends on the value obtained by analogRead().
• The circuit: - potentiometer: center pin of the potentiometer to the
analog input 0, one side pin (either one) to ground, the other side
pin to +5V
• - LED: anode (long leg) attached to digital output 13 through 220
ohm resistor, cathode (short leg) attached to ground

35
Code
• int sensorPin = A0; // select the input pin for the potentiometer
• int ledPin = 13; // select the pin for the LED
• int sensorValue = 0; // variable to store the value coming from the sensor

• void setup() {
• pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT:
• }
• void loop() {
• sensorValue = analogRead(sensorPin); // read the value from the sensor:
• digitalWrite(ledPin, HIGH); // turn the ledPin on
• delay(sensorValue); // stop the program for <sensorValue> milliseconds:
• digitalWrite(ledPin, LOW); // turn the ledPin off:
• delay(sensorValue); // stop the program for <sensorValue> milliseconds:
• }
36

You might also like