Aluminum Die Casting Manufacturers in China - BIAN Diecast
IoT with Arduino
1. Internet of Things Workshop
with Arduino
This work by http://tamberg.org/ is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
A CC licensed workshop by @tamberg, first held 07.07.2012 at SGMK MechArtLab Zürich, Switzerland,
in collaboration with Zürich IoT Meetup, Perey Research & Consulting, Thomas Brühlmann and SGMK.
3. Internet of Things (IoT)
Computers, sensors and actuators connected
through Internet protocols
Measure or manipulate physical properties
http://e-home.com/tamberg/kitchen/light
6. IoT hardware
Any Internet-connected computer with an
interface to the real world (sensors, actuators)
Small => can be embedded into things
Small computer = microcontroller (or board),
e.g. Arduino, Netduino Plus, BeagleBone, …
Note: connecting your board to the Internet via a
desktop PC and USB is also fine, just a bit overkill
8. IoT infrastructure services
Thingspeak and Xively to store and use sensor measurements
e.g. https://thingspeak.com/channels/9
Twitter allows objects to talk to humans or receive commands
e.g. @twrbrdg_itself (f.k.a. @towerbridge)
Yaler enables remote access to Internet-connected devices
e.g. http://try.yaler.net/~arduino/led (Disclosure: I’m a founder)
Zapier and IFTTT allow mash-ups of Webservices
e.g. http://goo.gl/7Y8a7z
9. Just a beginning
Reactive buildings, flying / crawling IoT devices,
underused devices selling themselves on Ebay…
Connected products become service avatars, or
“everything becomes a service” (e.g. car sharing,
home sharing, shoe sharing)
“Once it’s here it will no longer be called
the Internet of Things” Open IoT Assembly 2012
10. Topics of this workshop
Getting started
(setup and programming of IoT hardware)
Measuring and manipulating
(physical computing: sensors and actuators)
Connecting your device to the Internet
(IoT: monitoring sensors, controlling actuators)
Mash-ups with Web-enabled devices
(together, if time permits)
How the Internet works under the hood
11. Hands on
Broad range of topics => learn by doing
Copy&paste examples, make 'em work for you,
https://bitbucket.org/tamberg/iotworkshop/get/tip.zip
Focus on end-to-end results, not details
Google, help each other, ask us
12. Note: Once it has been programmed, your board
can run on its own, without another computer
Getting started
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
13. 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
15. 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
16. The resistor
Resistors are the workhorse of electronics
Resistance is measured in Ω (Ohm) and adds up
in series; a resistors orientation doesn’t matter
A resistors Ω value is color-coded right on it
Note: color codes are great, but it’s easier to use a
multi-meter if you’ve got one, and just measure Ω
17. 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
18. The breadboard
A breadboard lets you wire electronic
components without any soldering
Its holes are connected
“under the hood” as
shown here
19. 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
+
20. 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
21. Actuator bonus stage
Try a switched power outlet instead of a LED
(black wire = GND)
Use a multicolor LED with the breadboard, as in
http://www.ladyada.net/learn/arduino/lesson3.html
Or solder resistors to a multicolor LED, as in
http://www.instructables.com/id/Arduino-Web-LED/
22. 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
23. 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
24. 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
25. 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
26. 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
27. 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
28. Sensor bonus stage
Switch the LED
depending on
analog input
Read analog values from a bathroom scale
Or use sensors with other wire protocols, e.g. i2c
30. Note: in this workshop we focus on Ethernet and Wi-Fi
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
31. 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
32. Note: open the serial monitor window to see the log
http://learn.adafruit.com/adafruit-cc3000-wifi/cc300
File > Examples > Adafruit_CC3000 > WebClient
#define WLAN_SSID "..." // set your network
#define WLAN_PASS "..." // set your password
Using CC3000 Wi-Fi with Arduino
33. 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
35. 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)
36. Pachube (now Xively)
The Pachube (now Xively) service lets you store,
monitor and share sensor data in open formats
PUT /v2/feeds/<your feed id>.csv HTTP/1.1rn
Host: api.xively.comrn
X-ApiKey: <your API key>rn
Content-Length: <content length>rn
rn
<sensor name>,<sensor value>
GET /v2/feeds/<feed id>.json HTTP/1.1rn
Host and X-ApiKey as above…rnrn
Note: please visit
http://xively.com/
to sign up, create a
feed with a data
stream per sensor
and get an API key
37. Pachube with Arduino + Ethernet
Use Xively’s template or open Arduino IDE >
Examples > Ethernet > PachubeClient
Check MAC, IP, FEED ID, API KEY
and the data stream’s name
Analog input: LDR on A0
http://xively.com/feeds/<feed-id>
Note: to send data
to xively.com make
sure your Arduino
is connected to the
Internet
Open the Arduino
IDE serial monitor
to see log output
38. Pachube with Arduino + CC3000
To connect an Arduino to Pachube (now Xively)
follow the steps in
http://learn.adafruit.com/adafruit-cc3000-wifi-and-x
40. Controlling actuators
Service offers UI or API to control actuators
Device polls service for control data with GET
Or, service pushes control data to device with
POST or PUT
Device writes control data to actuators
41. Web service with Arduino
https://bitbucket.org/tamberg/iotworkshop/raw/e1
Please change the MAC address,
wait for DHCP to assign an IP and
visit the URL displayed in the log
Make sure to add
an EthernetShield
to your Arduino &
plug it into a LAN
Open the serial
monitor window
to see log output
Note: your Arduino is now a (local) Web server
42. The Yaler relay provides a public and stable URL
to access Web services behind a firewall or NAT
Yaler
Note: please visit
http://yaler.net/
and sign up to get
your relay domain
and API key (free)
43. For remote Web access with Ethernet, see
https://yaler.net/arduino
For the WiFi shield, see
https://yaler.net/arduino-wifi
And for the CC3000, see
https://yaler.net/arduino-cc3000
Yaler with Arduino
45. Mash-ups
A mash-up combines two or more Web services
Once devices have APIs, they become scriptable
Logic moves out of device, into the Cloud, e.g.
Web-enabled LED + Yahoo Weather API =
ambient weather notification
Note: the IoT enables physical mash-ups of things
46. Mash-ups
HTML combining data from multiple APIs on the
Web client, using Javascript XMLHttpRequest to
get data (in JSONP, to bypass same origin policy)
Scripting (C#, Python, Go, …) glue code hosted
on a desktop or in the cloud (EC2, AppEngine …)
Mash-up platforms (IFTTT.com, Zapier.com, …)
Note: open data formats and APIs enable mash-ups
47. If you wonder what TCP/IP, HTTP or DNS means
- or care about the difference between protocol,
data format and API, read on...
How the Internet works
48. Note: protocols are layered, e.g. HTTP messages
transported in TCP/IP packets sent over Ethernet
Protocols
Parties need to agree on how to exchange data
(communicating = exchanging data according to
a protocol)
e.g. Ethernet links local computers physically,
TCP/IP is the foundation of the Internet, and
HTTP is the protocol that enables the Web
49. TCP/IP
IP (Internet Protocol) deals with host addressing
(each host has an IP address) and packet routing
TCP (Transmission Control Protocol): connection
oriented, reliable data stream (packets in-order,
errors corrected, duplicates removed, discarded
or lost packets resent) from client to server
Note: DHCP assigns an IP address to your device
which is mapped to the device’s MAC address
50. HTTP (Hypertext Transfer Protocol) enables the
distributed, collaborative system we call the Web
The client sends an HTTP request,
the server replies with a response
HTTP Message = Request|Response
Request = (GET|POST|…) Path CRLF *(Header CRLF) CRLF Body
Response = "HTTP/1.1" (200|404|…) CRLF *(Header CRLF) CRLF Body
CRLF = "rn"
(Read the spec: http://tools.ietf.org/html/rfc2616)
HTTP
Note: HTTP is human readable, i.e. it’s easy to debug
51. The URI (Uniform Resource Identifier) is a string
of characters used to identify a resource
http://blog.tamberg.org/2011-10-17/side-projects.html
(Read the spec: http://tools.ietf.org/html/rfc3986)
QR codes, NFC tags can contain a machine readable URI
IoT: URIs can refer to things or their physical properties
URIs
Note: good URIs can be hand-written on a napkin
and re-typed elsewhere, without any ambiguity
authority = host [‘:’ port] pathscheme
52. DNS
DNS (Domain Name System) maps Internet
domain names to one or more IP addresses
Try it in your desktop computer terminal, e.g.
$ nslookup google.com
173.194.35.6 …
Note: if your device doesn’t support DNS you can
connect to the server’s IP, but beware of changes
53. Data formats
Parties need to agree on what is valid content
(parsing = reading individual content tokens)
CSV: easy to parse, suited for tables, old school
JSON: easy to parse, de facto standard
XML: used by many services, W3C standard
Semi-structured text, e.g. Twitter’s @user, #tag
Binary formats, e.g. PNG, MP3, …
54. RSS
In addition to generic data formats like CSV,
JSON, XML there are refinements that add
semantics to the document
RSS (or Atom) is a data format for lists of items
Invented for blogs, RSS is great for data feeds
Note: RSS documents are also XML documents,
but not all XML documents contain valid RSS
55. HTML
HTML (Hypertext Markup Language) is a data
format describing how a Web page should be
structured and displayed
Look at the HTML (and Javascript) code of any
Web page with "view source" in your browser
Note: HTML documents are not always valid XML
documents, but Web browsers are very forgiving
56. APIs
An API (Application Programming Interface), is
an agreement between clients and providers of
a service on how to access a service, how to get
data out of it or put data into it
The UI (User Interface) of a service is made for
humans, the API is made for other computers
Note: good APIs are documented or self-explanatory
57. REST
REST (Representational State Transfer) is a style
of designing an API so that it is easy to use
REST APIs use HTTP methods (GET, PUT, POST,
DELETE) to let you perform actions on resources
REST APIs can be explored by following links
Note: good Web UIs are often built following the
same principles, therefore REST APIs feel natural
58. Sharing network connections
Most newer computer operating systems allow
sharing network connections with other devices
Mac OSX: System Preferences > Sharing > Internet
Sharing > From Wi-Fi to Ethernet
Windows 7: Control Panel > View network status and
tasks > Change adapter settings > right click Wireless
Network Connection > Properties > Sharing > [x] Allow
other network users to connect … > Local Area
Connection
Note: helpful for demos, if there’s Wi-Fi but no LAN
59. Debugging Web services
Chrome > Inspect Element > Network, Console
cURL for HTTP requests (http://curl.haxx.se/)
Requestbin for Webhooks (http://requestb.in/)
Fiddler (http://www.fiddler2.com/)
WireShark (http://www.wireshark.org/)
60. Debugging USB or Bluetooth
On Mac OSX and Linux
list connected devices with ls /dev/tty*
display output with screen /dev/tty... 9600
On Windows
list devices, fix drivers with devmgmt.msc
display serial output with PuTTY
61. Energy
Wall socket, Power over Ethernet (w/ adapters),
batteries (direct or Minty Boost USB charger),
LiPo batteries (also shields), solar panels, …
Low power: lets hardware sleep to save energy
Future: new battery technologies, ultra low
power hardware, energy harvesting
Note: Moore’s law does not apply to batteries
62. Note: MechArtLab Zürich has an OpenLab on Tuesdays
Learning more
Electronics: Ohm’s law, Kirchhoff’s current and voltage
law (KCL & KVL), Make: Electronics by Charles Platt
Interaction Design: Smart Things by Mike Kuniavsky,
Emoticomp blog post by Ben Bashford, BERG blog
Physical Computing: Making Things Talk by Tom Igoe
REST: RESTful Web Services by Leonard Richardson
Programming: read other people’s code
IoT: Designing the Internet of Things by Adrian McEwen
and Hakim Cassimally, Postscapes.com, IoTList.co
63. Reducing E-waste
Tired of hacking?
Donate your hardware to a local hackerspace…
e.g. MechArtLab
Hohlstrasse 52
8004 Zürich
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
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.
Ein paar Beispiele Internet-verbundener Objekte (Produkte und DIY Projekte)
Hier ein Internet of Things Referenzmodell
Das Modell erklärt, wie solche Produkte funktionieren: Ein Gerät oder Objekt mit Sensoren und Aktuatoren erlaubt eine direkte, physische Interaktion. Da es zudem per Internet mit einem Server verbunden ist, kann ich auch virtuell damit interagieren, mittels Browser oder App - lokal, oder aus der Ferne.
&gt;&gt;
There are many such models. This one helps us to understand the previous examples.
Computer (incl. keyboard / mouse / display) is considered separately (not as an IoT device).
Device can have only sensor or only actuator
Device / thing can be same or device embedded in otherwise dumb thing.
User can be local or remote with respect to device.
There can be many devices / many users.
Devices can be connected to other devices rather than users.
HTTP / TCP/IP is the lingua franca, decouples devices from each other and servers / services.
How exactly a device is connected to the Internet (via Wifi, LAN, …) is not shown here.
Draw the model on a whiteboard and refer to it during the workshop
Internet of Things Hardware
Jeder Internet-verbundene Computer mit Schnittstelle zur realen Welt (Sensoren / Aktuatoren)
Klein =&gt; Kann in Dinge eingebettet werden
Kleine Computer heissen auch Mikrocontroller (oder Board), z.B. Arduino, Netduino Plus oder BeagleBone
Bemerkung: solche Boards können auch via USB und einen Desktop PC mit dem Internet vebrunden werden. Das ist OK, aber es geht auch ohne.
Bemerkung: Dank TCP/IP und HTTP als gemeinsame Sprache kann jeder Client mit jedem Server kommunizieren, egal welche Hardware man wählt.
Internet of Things Infrastruktur
Thingspeak und Xively zum Speichern von Sensor-Messwerten
Twitter erlaubt Objekten mit Menschen zu sprechen oder Kommandos zu empfangen
Yaler erlaubt den Fernzugriff auf Internet-verbundene Geräte (Offenlegung: Ich bin ein Gründer)
Zapier und IFTTT erlauben &quot;mash-ups&quot; von Web Services, d.h. Verknüpfen von Online-Diensten
Nur ein Anfang
Reaktive Gebäude, fliegende / krabbelnde IoT Geräte, zu wenig benutzte Geräte versteigern sich selbst auf Ebay...
Internet-verbundene Produkte werden &quot;Service-Avatars&quot;, d.h. Stellvertreter für Dienstleistungen, oder alles wird zum Service (z.B. Car-Sharing wie Mobility, Home-Sharing wie Airbnb oder Schuh-Sharing)
&quot;Wenn es mal hier ist, heisst es nicht mehr Internet of Things&quot;
&gt;&gt;
Mike Kuniavsky
Sharing: Quote from OpenIoT Assembly 2012; car: zippcar,… home: airbnb, shoes: … (Mike K.)
Flying…: Quote from OpenIoT Assembly 2012
Toaster: Usman Haque
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
Hands on
Viele Themen =&gt; Lernen durch selbermachen
Cop&paste aus Beispielen, ändern, bis es läuft
Auf Endresultat fokussieren, nicht Details
Googeln, einander helfen, und fragen
Erste Schritte
Die Entwicklungsumgebung erlaubt es ein Board zu programmieren, d.h. &quot;dem Gerät etwas neues beizubringen&quot;
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.
Erste Schritte mit Arduino
Um die Entwicklungsumgebung zu installieren und das Arduino Board mit dem Computer zu verbinden, siehe die folgenden Links.
Messen und manipulieren
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
Der Widerstand
Widerstand wird in Ohm gemessen. Widerstände in Serie können addiert werden. Die Orientierung eines Widerstandes ist egal.
Der Wert eines Widerstands ist mit einem Farbcode gekennzeichnet.
Bemerkung: Farbcodes sind super, aber es ist noch einfacher ein Multimeter zu verwenden um den Widerstand auszumessen.
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).
Das Breadboard
Ein Breadboard erlaubt es elektronische Komponenten ohne Löten zusammenzustecken
Die Löcher sind unterirdisch durch Metall verbunden, wie hier angedeutet
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
Digitaler Output mit Arduino
Bemerkung: die blinkende LED ist das &quot;Hello World&quot; 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.
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.
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.
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 &gt; Beispiele &gt; Digital &gt; Button
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
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
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
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
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
Benutzung des CC3000 Wi-Fi mit Arduino
Bemerkung: Das Serial Monitor Fenster in der Arduino Entwicklungsumgebung zeigt den Log Output an
&gt;&gt;
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
Benutzung von Ethernet mit Arduino
Ethernet-Shield auf den Arduino stecken
Datei &gt; Beispiele &gt; Ethernet &gt; WebClient
Bemerkung: Bitte uns fragen um eine MAC und IP Adresse zu bekommen
&gt;&gt;
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
Sensoren überwachen
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
&gt;&gt;
Cosm: Supports push and pull, stores and renders content, knows format
Twitter: Push only, doesn’t know anything about content format of Tweet
Pachube (neu Xively)
Der Dienst ermöglicht das Speichern, Anzeigen und Publizieren von Sensordaten in offenen Datenformaten
Bemerkung: Bitte Xively.com besuchen um einen Account und API Key (Schlüssel) zu bekommen, der das Kreieren von Feeds ermölicht
Pachube mit Arduino + Ethernet
Xively bietet ein Programm Template, oder einfach in der Arduino IDE auf
Beispiele &gt; Ethernet &gt; PachubeClient
MAC, IP, FEED ID, API KEY und Feed Name einsetzen
Das Serial Monitor Fenster in der Arduino Entwicklungsumgebung zeigt den Log Output an
https://cosm.com/feeds/61114
http://learn.adafruit.com/adafruit-cc3000-wifi-and-xively
https://api.cosm.com/v2/feeds/61114/datastreams/button.png?width=730&height=100&colour=%23f15a24&duration=5minutes&stroke_size=7&scale=manual&min=0&max=1&timezone=UTC
Pachube mit Arduino + CC3000
Um den Arduino mit Pachube (neu Xively) zu verbinden, siehe Link
Aktuatoren fernsteuern
Aktuatoren fernsteuern
Manche Platformen bieten eine Benutzerschnittstelle (User Interface, UI) oder eine Programmierschnittstelle (API) um Aktuatoren fernzusteuern
Ein Gerät pollt den online Dienst um Kontrolldaten mit GET abzufragen
Oder, der Dienst pusht Kontrolldaten zum Gerät mit POST oder PUT
Das Gerät schreibt Kontrolldaten bzw. Sollwerte auf die Aktuatoren
Web Service mit Arduino
Bitte MAC Adresse ändern, warten, bis DHCP eine IP Adresse zugewiesen hat und die URL besuchen, die im Log angezeigt wird
Dieses Beispiel erfordert einen Ethernet Shield auf dem Arduino, und ein eingestecktes LAN Kabel
Bemerkung: der Arduino ist jetzt ein (lokaler) Web Server
Yaler
Das Yaler Relay ermöglicht den Fernzugriff auf Geräte hinter einem NAT Server oder Firwall, an einer öffentlichen, stabilen Adresse (URI).
Bitte https://yaler.net/ besuchen, um einen Gratisaccount und API Key zu bekommen
Yaler mit Arduino
Falls ein Ethernet Shield verwendet wird, gibt&apos;s auf https://yaler.net/arduino eine Anleitung zum Einschalten des Fernugriffs
Das CC3000 Wi-Fi Modul wird noch nicht unterstützt
Mash-ups
Mash-ups
Ein Mash-up kombiniert zwei oder mehr online Dienste
Wenn Geräte einmal APIs haben, werden sie per Skript ansteuerbar
Logik wander so aus dem Gerät raus, in die Cloud, z.B. Internet-verbundene LED + Yahoo Wetterdienst API = &quot;Wetter-Anzeige&quot; Objekt
Bemerkung: Das IoT ermögliche physikalische Mash-ups
Mash-ups
HTML kombiniert Daten von mehreren APIs auf dem Web Client, mittels Javascript XMLHttpRequest (Daten im JSONP, um &quot;Same Origin Policy&quot; zu umgehen)
Glue-code (Programm als Leim oder Kitt) Skripts kann auf einem Desktop Computer oder in der Cloud abgelegt werden
Noch einfacher geht&apos;s mit Mash-up Platfromen (IFTTT.com, Zapier.com, ...)
Bemerkung: Offene Datenformate ermöglichen Mash-ups
&gt;&gt;
http://msdn.microsoft.com/en-us/library/system.net.webclient.headers.aspx (WebClient Headers)
http://msdn.microsoft.com/en-us/library/d0d3595k.aspx (WebClient UploadString)
Image Source : &quot;Casting the Net&quot;, page 56. See also The Computer Museum&apos;s Timeline.
http://personalpages.manchester.ac.uk/staff/m.dodge/cybergeography/atlas/historical.html
Computer als Hotspot verwenden
Die meisten neueren Computer erlauben es, die Netzwerkverbindung mit anderen Geräten zu teilen.
Bemerkung: Nützlich für Demos, wenn es Wi-Fi hat, aber keine Kabelverbindung (LAN).