SlideShare a Scribd company logo
Internet of
Things (IoT)
with Arduino
Dr. Anurag Singh
IIIT Naya Raipur
Outline of
the Talk
Introduction to IoT and Sensors
Introduction to Arduino
(Hardware and Programming)
Getting started with Arduino
(setup and basic programming for an IoT
hardware)
Arduino-based Demonstration
• Demo 1: Controlling an LED's Blink
• Demo-2: Controlling LED's fading
• Demo-3: Heart-rate computation
Introduction
• The evolution of communication technologies bring
Internet connection to devices at lower cost, less power
consumption and smaller sizes.
• As the results devices are able to be parts of the so called
Internet of Things (IoT).
• Arduino: flexible micro-controller and development
environment.
 Used to control devices, and to read data from all kinds of
sensors.
 Arduino is the best way to be introduced to the IoT
Internet
Computers,
connected
through Internet
protocols
Display or
manipulate
data/documents
Internet of Things (IoT)
Computers, sensors and
actuators connected
through Internet
protocols
Measure or manipulate
physical properties
Imagine having small device connected that can sense temperature, smoke,
humidity, and light condition of your room and report them to a web services
IoT
A global network of smart
devices that can sense and
interact with their
environment using internet
for their communication
and interaction.
A network of Physical
Objects that can interact
with each other to share
information and take
Action.
IoT Concept
IoT
device
Requirements common to all of IoT Device include
• Sensing and data collection capability (sensing
nodes)
• Layers of local embedded processing capability
(local embedded processing nodes)
• Wired and/or wireless communication
capability (connectivity nodes)
• Software to automate tasks and enable new classes
of services
• Remote network/cloud-based embedded
processing capability (remote embedded processing
nodes)
• Full security across the signal path
Feature of IoT
device
Thingspeak and Xively to store and use
sensor measurements​
e.g. https://thingspeak.com/channels/9​
Interaction with The Internet
• The ability to communicate directly or
indirectly with the internet make IoT device
different from other devices.
 Why need to communicate with internet?
 Sensors generate lot of data that need to be
managed.
 Embedded memory is limited
 Internet provide web application for data storage
which can be accessed anywhere or anytime.
 Provide data exchanges between other applications.
Building Blocks of the IoT
• Control Units
• Sensors
• Communication Modules
• Power sources
Control Units
IoT device utilize microcontroller as the main
control unit
• A microcontroller: Is a small computer in a
single integrated circuit.
It contain a processor core, a memory, and
programmable I/O peripheral.
• MCU
The ‘brain’ controls everything
Reads input from sensors
Drives outputs
LED, Switch, Motor,…
Sensors: Integral part of an IoT device
• Device that can sense the physical quantities and
convert into signal which can be interpreted by the
MCU.
• Fall into two types
Analog and Digital Sensor
Arduino: A Computing Platform
• What is Arduino?
• An open-source physical computing platform based on
A simple microcontroller board and
A development environment for writing software for
the board.
• Used to develop stand-alone interactive objects
• It can be connected to a computer to retrieve or send
data to the Arduino.
The board can be assembled by hand or purchased
preassembled.
Arduino Platform
• Why Arduino used mostly
• It is inexpensive
• cross-platform (the Arduino software runs on Windows,
Mac OS X, and Linux), and
• easy to program.
• Both Arduino hardware and software are open source
and extensible
Arduino boards
IoT applications With Arduino coding and real life examples
Analog
INPUTS
Digital IO
PWM(3, 5, 6, 9, 10, 11)
PWR IN USB
(to Computer)
SCLSDA
(I2C Bus)
POWER
5V / 3.3V / GND
RESET
IoT applications With Arduino coding and real life examples
Note: Once it has been programmed, your board
can run on its own, without another computer
Getting started with Arduino
The IDE (Integrated Development Environment)
allows you to program your board, i.e. “make it
do something new”
You edit a program on your computer, then
upload it to your board where it’s stored in the
program memory (flash) and executed in RAM
Measuring and manipulating
IoT hardware has an interface to the real world
GPIO (General Purpose Input/Output) pins
Measure: read sensor value from input pin
Manipulate: write actuator value to output pin
Inputs and outputs can be digital or analog
Getting started with Arduino
To install the Arduino IDE and connect your
Arduino board to your computer via USB, see
http://arduino.cc/en/Guide/MacOSX or
http://arduino.cc/en/Guide/Windows or
http://arduino.cc/playground/Learning/Linux
Arduino
Programming:
Bare minimum
code
void setup() {
// put your setup code here, to
run once:
}
void loop() {
// put your main code here, to
run repeatedly:
}
Bare
minimum
code
setup : It is called only when
the Arduino is powered on or
reset. It is used to initialize
variables and pin modes
loop : The loop functions runs
continuously till the device is
powered off. The main logic of
the code goes here. Similar to
while (1) for micro-controller
programming.
PinMode
• A pin on arduino can be set as input
or output by using pinMode
function.
• pinMode(13, OUTPUT); // sets pin
13 as output pin
• pinMode(13, INPUT); // sets pin 13
as input pin
Reading/writing
digital values
• digitalWrite(13, LOW); //
Makes the output voltage
on pin 13 , 0V
• digitalWrite(13, HIGH); //
Makes the output voltage
on pin 13 , 5V
• int buttonState = digitalRea
d(2); // reads the value of
pin 2 in buttonState
Demonstrations
IoT applications using Arduino
Demo-1
Controlling an LED's Blink
The LED
The LED (Light Emitting Diode)
is a simple, digital actuator
LEDs have a short leg (-) and a long leg (+)
and it matters how they are oriented in a circuit
To prevent damage, LEDs are used together with
a 1KΩ resistor (or anything from 300Ω to 2KΩ)
+ -
+ -
Anode Cathode
The breadboard
A breadboard lets you wire electronic
components without any soldering
Its holes are connected
“under the hood” as
shown here
Wiring a LED with Arduino
The long leg of the
LED is connected to
pin 13, the short leg
to ground (GND)
Note: the additional
1K Ω resistor should
be used to prevent
damage to the pins /
LED if it’s reversed
The Ethernet Shield
is not needed here
+
HIGH = digital 1 (5V)
means LED is on,
LOW = digital 0 (0V)
means LED is off
Set ledPin as wired
in your LED circuit
Digital output with Arduino
int ledPin = 13;
void setup () {
pinMode(ledPin, OUTPUT);
}
void loop () {
digitalWrite(ledPin, HIGH);
delay(500); // wait 500ms
digitalWrite(ledPin, LOW);
delay(500);
}
Note: blinking a LED
is the Hello World of
embedded software
A few simple challenges
Let’s make LED#13 blink!
• Challenge 1a – blink with a 200 ms second
interval.
• Challenge 1b – blink to mimic a heartbeat
• Challenge 1c – find the fastest blink that the
human eye can still detect…
• 1 ms delay? 2 ms delay? 3 ms
delay???
Demo-2
Controlling Fading of an LED's
Fading in and Fading Out
(Analog or Digital?)
• A few pins on the Arduino allow for us to
modify the output to mimic an analog signal.
• This is done by a technique called:
• Pulse Width Modulation (PWM)
Arduino Programming: LED Fading
int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 25; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
Demo# 2 – Fading challenge
• Challenge 2a – Change the rate of the fading
in and out. There are at least two different
ways to do this – can you figure them out?
• Challenge 2b – Use 2 (or more) LEDs – so that
one fades in as the other one fades out.
Demo-3
Heart Rate Computation using Pulse
Sensor
Arduino-based Applications
Many more are there
A switch is a simple, digital sensor
Switches come in different forms, but all of them
in some way open or close a gap in a wire
The pushbutton switch has four legs for easier
mounting, but only two of them are needed
Note: you can also easily build your own switches,
for inspiration see e.g. http://vimeo.com/2286673
The switch
Wiring a switch with Arduino
Pushbutton switch
10K Ω resistor
5V
GND
D2 (max input 5V!)
Note: the resistor in
this setup is called
pull-down ‘cause it
pulls the pin voltage
down to GND (0V) if
the switch is open
Digital input with Arduino
int sensorPin = 2; // e.g. button switch
void setup () {
Serial.begin(9600); // setup log
pinMode(sensorPin, INPUT);
}
void loop () {
int sensorValue = digitalRead(sensorPin);
Serial.println(sensorValue); // log 0 or 1
}
Or run Arduino IDE
> File > Examples >
Digital > Button for
an example of how
to switch an LED
Open the Arduino
IDE serial monitor
to see log output
Photoresistor (LDR)
A photoresistor or LDR
(light dependent resistor) is
a resistor whose resistance
depends on light intensity
An LDR can be used as a simple, analog sensor
The orientation of an LDR does not matter
Wiring an LDR with Arduino
Photoresistor (LDR)
10K Ω resistor
5V
GND
A0
Note: this setup is a
voltage-divider, as
the 5V total voltage
is divided between
LDR and resistor to
keep 0V < A0 < 2.5V
int sensorPin = A0; // e.g. LDR
void setup () {
Serial.begin(9600); // setup log
}
void loop () {
int sensorValue = analogRead(sensorPin);
Serial.println(sensorValue); // log value
}
Analog input with Arduino
Open the Arduino
IDE serial monitor
to see log output
Note: use e.g. Excel to visualize values over time
IoT Based Humidity and Temperat
ure Monitoring Using Arduino Un
o
Driving Motors or other High
Current Loads
• NPN Transistor (Common Emitter “Amplifier” Circuit)
to Digital
Pin 9
Connecting to the Internet
Ethernet (built-in or shield), plug it in anywhere
Wi-Fi (module), configured once per location
3G (module), configured once, easy to use
Bluetooth/BLE (module), via 3G/Wi-Fi of phone
ZigBee (module), via ZigBee gateway
USB (built-in), via desktop computer
Wiring CC3000 Wi-Fi with Arduino
CC3000 VIN to 5V
GND to GND
CLK to D13, MISO to
D12, MOSI to D11,
CS to D10, VBEN to
D5, IRQ to D3
Note: make sure to
use a reliable power
source, e.g. plug the
Arduino via USB or
use a LiPo battery
http://androidcontrol.blogspot.com/2015/05/arduino-wifi-control-with-esp8266-
module.html
Note: open the serial monitor window to see the log
http://learn.adafruit.com/adafruit-cc3000-wifi/c
c3000-library-software
File > Examples > Adafruit_CC3000 > WebClient
#define WLAN_SSID "..." // set your network
#define WLAN_PASS "..." // set your password
Using CC3000 Wi-Fi with Arduino
Note: please ask for assistance to get a unique address
Add an Ethernet shield to the Arduino, plug it in
File > Examples > Ethernet > WebClient
byte mac[] = { ... }; // set a unique MAC address
IPAddress ip(...); // set a local, unique IP address
Using Ethernet with Arduino
Monitoring sensors
Devices read (and cache) sensor data
Devices push data to a service with POST, PUT
Some services pull data from devices with GET
Service stores measurements, to be consumed
by humans or computers (incl. other devices)
Thank you

More Related Content

Similar to IoT applications With Arduino coding and real life examples (20)

PPTX
Introduction to Arduino Hardware and Programming
Emmanuel Obot
 
PPTX
Arduino
Jerin John
 
PPT
Intro to Arduino
avikdhupar
 
PDF
02 Sensors and Actuators Understand .pdf
engsharaf2025
 
PPTX
Shriram Vidyasdzsbhhflay School (4).pptx
bhagyashri99
 
PDF
Arduino electronics cookbook
Felipe Belarmino
 
PPTX
Tech Talk IOT
Jayant Rajwani
 
PPTX
Embedded system application
Dhruwank Vankawala
 
DOCX
embedded manual for students to learn and do
areeba15775n
 
PPTX
Arduino basics & programming skill development
ssuser478d0e
 
PPTX
Arduino Introduction PPT for school students
stusanthosh5195
 
PPTX
Arduino workshop
mayur1432
 
PDF
arduinocourse-180308074529 (1).pdf
ssusere5db05
 
PPTX
Arduino course
Ahmed Shelbaya
 
PDF
manual Internet of ThingsArduino_IOTArdu
deepikayadav216323
 
PPTX
Robotics Session day 1
Afzal Ahmad
 
PPSX
Arduino اردوينو
salih mahmod
 
PPTX
embedded_in_Arduino_with_basic_embedded.pptx
acloudinfo2023
 
PDF
IOT WORKSHEET 1.4.pdf
MayuRana1
 
PPTX
Arduino Programming Familiarization
Amit Kumer Podder
 
Introduction to Arduino Hardware and Programming
Emmanuel Obot
 
Arduino
Jerin John
 
Intro to Arduino
avikdhupar
 
02 Sensors and Actuators Understand .pdf
engsharaf2025
 
Shriram Vidyasdzsbhhflay School (4).pptx
bhagyashri99
 
Arduino electronics cookbook
Felipe Belarmino
 
Tech Talk IOT
Jayant Rajwani
 
Embedded system application
Dhruwank Vankawala
 
embedded manual for students to learn and do
areeba15775n
 
Arduino basics & programming skill development
ssuser478d0e
 
Arduino Introduction PPT for school students
stusanthosh5195
 
Arduino workshop
mayur1432
 
arduinocourse-180308074529 (1).pdf
ssusere5db05
 
Arduino course
Ahmed Shelbaya
 
manual Internet of ThingsArduino_IOTArdu
deepikayadav216323
 
Robotics Session day 1
Afzal Ahmad
 
Arduino اردوينو
salih mahmod
 
embedded_in_Arduino_with_basic_embedded.pptx
acloudinfo2023
 
IOT WORKSHEET 1.4.pdf
MayuRana1
 
Arduino Programming Familiarization
Amit Kumer Podder
 

Recently uploaded (20)

PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
Functions in Python Programming Language
BeulahS2
 
PPTX
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
PDF
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
PDF
Bayesian Learning - Naive Bayes Algorithm
Sharmila Chidaravalli
 
PPTX
UNIT 1 - INTRODUCTION TO AI and AI tools and basic concept
gokuld13012005
 
PPTX
FSE_LLM4SE1_A Tool for In-depth Analysis of Code Execution Reasoning of Large...
cl144
 
PDF
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
PPTX
Diabetes diabetes diabetes diabetes jsnsmxndm
130SaniyaAbduNasir
 
PDF
Tesia Dobrydnia - An Avid Hiker And Backpacker
Tesia Dobrydnia
 
PPTX
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
PDF
Designing for Tomorrow – Architecture’s Role in the Sustainability Movement
BIM Services
 
PPTX
CM Function of the heart pp.pptxafsasdfddsf
drmaneharshalid
 
PPTX
Computer network Computer network Computer network Computer network
Shrikant317689
 
PDF
CLIP_Internals_and_Architecture.pdf sdvsdv sdv
JoseLuisCahuanaRamos3
 
PPTX
Engineering Quiz ShowEngineering Quiz Show
CalvinLabial
 
PPTX
Precooling and Refrigerated storage.pptx
ThongamSunita
 
PPTX
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
PDF
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
PPTX
darshai cross section and river section analysis
muk7971
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
Functions in Python Programming Language
BeulahS2
 
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
Bayesian Learning - Naive Bayes Algorithm
Sharmila Chidaravalli
 
UNIT 1 - INTRODUCTION TO AI and AI tools and basic concept
gokuld13012005
 
FSE_LLM4SE1_A Tool for In-depth Analysis of Code Execution Reasoning of Large...
cl144
 
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
Diabetes diabetes diabetes diabetes jsnsmxndm
130SaniyaAbduNasir
 
Tesia Dobrydnia - An Avid Hiker And Backpacker
Tesia Dobrydnia
 
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
Designing for Tomorrow – Architecture’s Role in the Sustainability Movement
BIM Services
 
CM Function of the heart pp.pptxafsasdfddsf
drmaneharshalid
 
Computer network Computer network Computer network Computer network
Shrikant317689
 
CLIP_Internals_and_Architecture.pdf sdvsdv sdv
JoseLuisCahuanaRamos3
 
Engineering Quiz ShowEngineering Quiz Show
CalvinLabial
 
Precooling and Refrigerated storage.pptx
ThongamSunita
 
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
darshai cross section and river section analysis
muk7971
 
Ad

IoT applications With Arduino coding and real life examples

  • 1. Internet of Things (IoT) with Arduino Dr. Anurag Singh IIIT Naya Raipur
  • 2. Outline of the Talk Introduction to IoT and Sensors Introduction to Arduino (Hardware and Programming) Getting started with Arduino (setup and basic programming for an IoT hardware) Arduino-based Demonstration • Demo 1: Controlling an LED's Blink • Demo-2: Controlling LED's fading • Demo-3: Heart-rate computation
  • 3. Introduction • The evolution of communication technologies bring Internet connection to devices at lower cost, less power consumption and smaller sizes. • As the results devices are able to be parts of the so called Internet of Things (IoT). • Arduino: flexible micro-controller and development environment.  Used to control devices, and to read data from all kinds of sensors.  Arduino is the best way to be introduced to the IoT
  • 5. Internet of Things (IoT) Computers, sensors and actuators connected through Internet protocols Measure or manipulate physical properties Imagine having small device connected that can sense temperature, smoke, humidity, and light condition of your room and report them to a web services
  • 6. IoT A global network of smart devices that can sense and interact with their environment using internet for their communication and interaction. A network of Physical Objects that can interact with each other to share information and take Action.
  • 8. IoT device Requirements common to all of IoT Device include • Sensing and data collection capability (sensing nodes) • Layers of local embedded processing capability (local embedded processing nodes) • Wired and/or wireless communication capability (connectivity nodes) • Software to automate tasks and enable new classes of services • Remote network/cloud-based embedded processing capability (remote embedded processing nodes) • Full security across the signal path
  • 9. Feature of IoT device Thingspeak and Xively to store and use sensor measurements​ e.g. https://thingspeak.com/channels/9​
  • 10. Interaction with The Internet • The ability to communicate directly or indirectly with the internet make IoT device different from other devices.  Why need to communicate with internet?  Sensors generate lot of data that need to be managed.  Embedded memory is limited  Internet provide web application for data storage which can be accessed anywhere or anytime.  Provide data exchanges between other applications.
  • 11. Building Blocks of the IoT • Control Units • Sensors • Communication Modules • Power sources
  • 12. Control Units IoT device utilize microcontroller as the main control unit • A microcontroller: Is a small computer in a single integrated circuit. It contain a processor core, a memory, and programmable I/O peripheral. • MCU The ‘brain’ controls everything Reads input from sensors Drives outputs LED, Switch, Motor,…
  • 13. Sensors: Integral part of an IoT device • Device that can sense the physical quantities and convert into signal which can be interpreted by the MCU. • Fall into two types Analog and Digital Sensor
  • 14. Arduino: A Computing Platform • What is Arduino? • An open-source physical computing platform based on A simple microcontroller board and A development environment for writing software for the board. • Used to develop stand-alone interactive objects • It can be connected to a computer to retrieve or send data to the Arduino. The board can be assembled by hand or purchased preassembled.
  • 15. Arduino Platform • Why Arduino used mostly • It is inexpensive • cross-platform (the Arduino software runs on Windows, Mac OS X, and Linux), and • easy to program. • Both Arduino hardware and software are open source and extensible
  • 18. Analog INPUTS Digital IO PWM(3, 5, 6, 9, 10, 11) PWR IN USB (to Computer) SCLSDA (I2C Bus) POWER 5V / 3.3V / GND RESET
  • 20. Note: Once it has been programmed, your board can run on its own, without another computer Getting started with Arduino The IDE (Integrated Development Environment) allows you to program your board, i.e. “make it do something new” You edit a program on your computer, then upload it to your board where it’s stored in the program memory (flash) and executed in RAM
  • 21. Measuring and manipulating IoT hardware has an interface to the real world GPIO (General Purpose Input/Output) pins Measure: read sensor value from input pin Manipulate: write actuator value to output pin Inputs and outputs can be digital or analog
  • 22. Getting started with Arduino To install the Arduino IDE and connect your Arduino board to your computer via USB, see http://arduino.cc/en/Guide/MacOSX or http://arduino.cc/en/Guide/Windows or http://arduino.cc/playground/Learning/Linux
  • 23. Arduino Programming: Bare minimum code void setup() { // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: }
  • 24. Bare minimum code setup : It is called only when the Arduino is powered on or reset. It is used to initialize variables and pin modes loop : The loop functions runs continuously till the device is powered off. The main logic of the code goes here. Similar to while (1) for micro-controller programming.
  • 25. PinMode • A pin on arduino can be set as input or output by using pinMode function. • pinMode(13, OUTPUT); // sets pin 13 as output pin • pinMode(13, INPUT); // sets pin 13 as input pin
  • 26. Reading/writing digital values • digitalWrite(13, LOW); // Makes the output voltage on pin 13 , 0V • digitalWrite(13, HIGH); // Makes the output voltage on pin 13 , 5V • int buttonState = digitalRea d(2); // reads the value of pin 2 in buttonState
  • 29. The LED The LED (Light Emitting Diode) is a simple, digital actuator LEDs have a short leg (-) and a long leg (+) and it matters how they are oriented in a circuit To prevent damage, LEDs are used together with a 1KΩ resistor (or anything from 300Ω to 2KΩ) + - + - Anode Cathode
  • 30. The breadboard A breadboard lets you wire electronic components without any soldering Its holes are connected “under the hood” as shown here
  • 31. Wiring a LED with Arduino The long leg of the LED is connected to pin 13, the short leg to ground (GND) Note: the additional 1K Ω resistor should be used to prevent damage to the pins / LED if it’s reversed The Ethernet Shield is not needed here +
  • 32. HIGH = digital 1 (5V) means LED is on, LOW = digital 0 (0V) means LED is off Set ledPin as wired in your LED circuit Digital output with Arduino int ledPin = 13; void setup () { pinMode(ledPin, OUTPUT); } void loop () { digitalWrite(ledPin, HIGH); delay(500); // wait 500ms digitalWrite(ledPin, LOW); delay(500); } Note: blinking a LED is the Hello World of embedded software
  • 33. A few simple challenges Let’s make LED#13 blink! • Challenge 1a – blink with a 200 ms second interval. • Challenge 1b – blink to mimic a heartbeat • Challenge 1c – find the fastest blink that the human eye can still detect… • 1 ms delay? 2 ms delay? 3 ms delay???
  • 35. Fading in and Fading Out (Analog or Digital?) • A few pins on the Arduino allow for us to modify the output to mimic an analog signal. • This is done by a technique called: • Pulse Width Modulation (PWM)
  • 36. Arduino Programming: LED Fading int led = 9; // the PWM pin the LED is attached to int brightness = 0; // how bright the LED is int fadeAmount = 25; // how many points to fade the LED by // the setup routine runs once when you press reset: void setup() { // declare pin 9 to be an output: pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { // set the brightness of pin 9: analogWrite(led, brightness); // change the brightness for next time through the loop: brightness = brightness + fadeAmount; // reverse the direction of the fading at the ends of the fade: if (brightness <= 0 || brightness >= 255) { fadeAmount = -fadeAmount; } // wait for 30 milliseconds to see the dimming effect delay(30);
  • 37. Demo# 2 – Fading challenge • Challenge 2a – Change the rate of the fading in and out. There are at least two different ways to do this – can you figure them out? • Challenge 2b – Use 2 (or more) LEDs – so that one fades in as the other one fades out.
  • 38. Demo-3 Heart Rate Computation using Pulse Sensor
  • 40. A switch is a simple, digital sensor Switches come in different forms, but all of them in some way open or close a gap in a wire The pushbutton switch has four legs for easier mounting, but only two of them are needed Note: you can also easily build your own switches, for inspiration see e.g. http://vimeo.com/2286673 The switch
  • 41. Wiring a switch with Arduino Pushbutton switch 10K Ω resistor 5V GND D2 (max input 5V!) Note: the resistor in this setup is called pull-down ‘cause it pulls the pin voltage down to GND (0V) if the switch is open
  • 42. Digital input with Arduino int sensorPin = 2; // e.g. button switch void setup () { Serial.begin(9600); // setup log pinMode(sensorPin, INPUT); } void loop () { int sensorValue = digitalRead(sensorPin); Serial.println(sensorValue); // log 0 or 1 } Or run Arduino IDE > File > Examples > Digital > Button for an example of how to switch an LED Open the Arduino IDE serial monitor to see log output
  • 43. Photoresistor (LDR) A photoresistor or LDR (light dependent resistor) is a resistor whose resistance depends on light intensity An LDR can be used as a simple, analog sensor The orientation of an LDR does not matter
  • 44. Wiring an LDR with Arduino Photoresistor (LDR) 10K Ω resistor 5V GND A0 Note: this setup is a voltage-divider, as the 5V total voltage is divided between LDR and resistor to keep 0V < A0 < 2.5V
  • 45. int sensorPin = A0; // e.g. LDR void setup () { Serial.begin(9600); // setup log } void loop () { int sensorValue = analogRead(sensorPin); Serial.println(sensorValue); // log value } Analog input with Arduino Open the Arduino IDE serial monitor to see log output Note: use e.g. Excel to visualize values over time
  • 46. IoT Based Humidity and Temperat ure Monitoring Using Arduino Un o
  • 47. Driving Motors or other High Current Loads • NPN Transistor (Common Emitter “Amplifier” Circuit) to Digital Pin 9
  • 48. Connecting to the Internet Ethernet (built-in or shield), plug it in anywhere Wi-Fi (module), configured once per location 3G (module), configured once, easy to use Bluetooth/BLE (module), via 3G/Wi-Fi of phone ZigBee (module), via ZigBee gateway USB (built-in), via desktop computer
  • 49. Wiring CC3000 Wi-Fi with Arduino CC3000 VIN to 5V GND to GND CLK to D13, MISO to D12, MOSI to D11, CS to D10, VBEN to D5, IRQ to D3 Note: make sure to use a reliable power source, e.g. plug the Arduino via USB or use a LiPo battery http://androidcontrol.blogspot.com/2015/05/arduino-wifi-control-with-esp8266- module.html
  • 50. Note: open the serial monitor window to see the log http://learn.adafruit.com/adafruit-cc3000-wifi/c c3000-library-software File > Examples > Adafruit_CC3000 > WebClient #define WLAN_SSID "..." // set your network #define WLAN_PASS "..." // set your password Using CC3000 Wi-Fi with Arduino
  • 51. Note: please ask for assistance to get a unique address Add an Ethernet shield to the Arduino, plug it in File > Examples > Ethernet > WebClient byte mac[] = { ... }; // set a unique MAC address IPAddress ip(...); // set a local, unique IP address Using Ethernet with Arduino
  • 52. Monitoring sensors Devices read (and cache) sensor data Devices push data to a service with POST, PUT Some services pull data from devices with GET Service stores measurements, to be consumed by humans or computers (incl. other devices)

Editor's Notes

  • #1: Arduino Gadgeteer Beagle Bone … Aim: require no previous experience (because almost nobody understands IoT end-to-end) use simple language be resourceful provide links for further reading
  • #2: Themen dieses Workshops Erste Schritte (Einrichten und programmieren von IoT Hardware) Messen und Manipulieren (Physical Computing: Sensoren und Aktuatoren) Verbinden von Geräten mit dem Internet (IoT: Sensoren überwachen, Aktuatoren fernsteuern) Mash-ups mit Internet-verbundenen Geräten (zusammen, falls genug Zeit bleibt) Wie das Internet funktioniert
  • #5: Das Internet der Dinge entsteht, wenn Internet-verbundene Computer mit Sensoren und Aktuatoren ausgestattet werden. Statt virtuelle Ressourcen, wie bisher im Web, werden damit physikalische Eigenschaften gemessen und manipuliert.
  • #18: Look up analog ref
  • #20: Erste Schritte Die Entwicklungsumgebung erlaubt es ein Board zu programmieren, d.h. "dem Gerät etwas neues beizubringen" Man editiert ein Programm auf dem Computer, lädt das Programm auf das Board. Dort wird es im Programmspeicher (Flash) abgelegt und im RAM ausgeführt. Bemerkung: Wenn es einmal programmiert ist, funktioniert das Board allein, ohne den Desktop-Computer.
  • #21: Messen und manipulieren IoT Hardware hat immer eine Schnittstelle zur Realität GPIO (General Purpose Input/Output) Pins Messen: Sensor-Messwert vom Input-Pin lesen Manipulieren: Aktuator Sollwert auf einen Output-Pin schreiben Inputs und Outputs önnen digital oder analog sein
  • #22: Erste Schritte mit Arduino Um die Entwicklungsumgebung zu installieren und das Arduino Board mit dem Computer zu verbinden, siehe die folgenden Links.
  • #29: Die LED Eine LED (Leuchtdiode) ist ein einfacher digitaler Aktuator. LEDs habe ein kurzes Bein (-) und ein langes (+) und es kommt drauf an, wie eine LED in die Schaltung eingebaut wird. Um Schäden an der LED zu verhindern, wird ein Widerstand vorgeschaltet (irgendwas zwischen 300 Ohm und 2 Kilo-Ohm).
  • #30: Das Breadboard Ein Breadboard erlaubt es elektronische Komponenten ohne Löten zusammenzustecken Die Löcher sind unterirdisch durch Metall verbunden, wie hier angedeutet
  • #31: Verdrahten einer LED mit Arduino Bemerkung: der zusätzliche 1K Ohm Widerstand sollte benutzt werden um Schäden an Pins / LED zu vermeiden, falls sie verkehrt eingesteckt wird. Das längere Bein der LED ist mit Pin 13 verbunden, das kürzere mit Erde, oder Ground (GND) Der Ethernet shield wird hier nicht benötigt
  • #32: Digitaler Output mit Arduino Bemerkung: die blinkende LED ist das "Hello World" Programm der embedded Sofware Der LED Pin sollte entsprechend der Verdrahtung gesetzt werden, in der Schaltung HIGH bedeutet die LED ist an, LOW bedeutet die LED ist aus.
  • #40: Der Schalter Ein Schalter ist ein einfacher, digitaler Sensor Schalter gibt es in verschiedenen Formen, aber alle davon öffnen und schliessen eine Lücke in einem Kabel. Der Druckknopf hat vier Beine um die Montage zu vereinfachen, aber nur zwei davon werden benötigt Bemerkung: Schalter kann man auch einfach selber bauen, siehe z.B. diesen Link.
  • #41: Schalter Verkabeln mit Arduino Bemerkung: der Widerstand hier wird auch pull-down Widerstand genannt, weil er die Pin Spannung auf Ground (0V) runterzieht, wenn der Schalter offen ist.
  • #42: Digitaler Input mit Arduino Das Serial Monitor Fenster in der Arduino Entwicklungsumgebung zeigt den Log Output an Für ein Beispiel das eine LED ein- und ausschaltet, siehe Datei > Beispiele > Digital > Button
  • #43: Fotowiderstand Ein Fotowiderstand (LDR, Licht-abhängiger Widerstand) ist ein Widerstand dessen Wert von der einfallenden Lichtstärke abhängt Ein Fotowiderstand kann als einfacher analoger Sensor benutzt werden Die Orientierung eines LDR in der Schaltung ist egal
  • #44: LDR verkabeln mit Arduino Bemerkung: diese Schaltung heisst auch Spannungsteiler, weil die 5V Spannung zwischen dem LDR und einem Widerstanf aufgeteilt werden, damit A0 zwischen 0 und 2.5V bleibt
  • #45: Analoger Input mit Arduino Das Serial Monitor Fenster in der Arduino Entwicklungsumgebung zeigt den Log Output an Bemerkung: eine Reihe von Messwerten kann z.B. mit Excel einfach visualisiert werden
  • #48: Verbinden mit dem Internet Ethernet (eingebaut oder als Shield), überall einfach einstecken Wi-Fi (Modul), muss einmal pro Location konfiguriert werden 3G (Modul), muss ein einziges mal konfiguriert werden, einfach zu benutzen Bluetooth / Bluetooth Low Energy (BLE), via 3G oder Wi-Fi eines Smartphones ZigBee (Modul), via ZigBee Gateway USB (eingebaut), via Dekstop Computer Bemerkung: In diesem Workshop fokussieren wir auf Ethernet und Wi-Fi
  • #49: Verkabeln von CC3000 Wi-Fi mit Arduino Bemerkung: sicherstellen, dass eine zuverlässige Stromquelle benutzt wird, z.B. via USB oder mit einem LiPo Akku
  • #50: Benutzung des CC3000 Wi-Fi mit Arduino Bemerkung: Das Serial Monitor Fenster in der Arduino Entwicklungsumgebung zeigt den Log Output an >> http://learn.adafruit.com/adafruit-cc3000-wifi/cc3000-library-software http://learn.adafruit.com/adafruit-cc3000-wifi/buildtest http://learn.adafruit.com/adafruit-cc3000-wifi/webclient
  • #51: Benutzung von Ethernet mit Arduino Ethernet-Shield auf den Arduino stecken Datei > Beispiele > Ethernet > WebClient Bemerkung: Bitte uns fragen um eine MAC und IP Adresse zu bekommen >> http://learn.adafruit.com/adafruit-cc3000-wifi/cc3000-library-software http://learn.adafruit.com/adafruit-cc3000-wifi/buildtest http://learn.adafruit.com/adafruit-cc3000-wifi/webclient
  • #52: Sensoren überwachen Gerät liest und speichert Sensor Daten Gerät pusht Daten auf eine online Platform mit POST, PUT Manche Services pullen (ziehen) Daten vom Gerät mit GET Platformspeichert Messwerte, die dann von Menschen oder anderen Computern (inkl. embedded Geräten) konsumiert werden >> Cosm: Supports push and pull, stores and renders content, knows format Twitter: Push only, doesn’t know anything about content format of Tweet