Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

46
Insert Speaker Name 9/29/15 Arduino Zero Pro und Bluetooth LE - Neues für Elektroniker Tam HANNA w/ Annette Heidi BOSBACH New Technologies

Transcript of Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Page 1: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Insert Speaker Name9/29/15

Arduino Zero Pro und Bluetooth LE - Neues für Elektroniker

Tam HANNA w/ Annette Heidi BOSBACH

New Technologies

Page 2: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

About /me

● Tam HANNA– CEO, Tamoggemon

Holding k.s.

Page 3: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

NICHT abschreiben!

● Folien warten unter– http://www.tamoggemon.com/cota.pdf

● Fotos auf Twitter, etc – JA BITTE● @tamhanna

Page 4: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Was gibt's heute?

● Arduino Zero / Zero Pro● Bluetooth LE● iBeacons● Ein kleines Helferlein

Page 5: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015
Page 6: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Ausgangssituation

● AVR-Architektur an Wachstumsgrenze– Ist nur ein 8-bitter

– “Maturing market”

● Problem: neue Hardware ist inkompatibel– Kombinatorischer Prozessrechner

– Beschränkung auf Wirsing-API

Page 7: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015
Page 8: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Kleine Gegenüberstellung

UnoUno ZeroZero

2KB RAM 32KB RAM

Dediziertes Flash Emuliertes Flash

PWM DAC

5V Signalspannung NUR 3V3

XX MhZ AVR-CPU 48 MhZ ARM-CPU

Page 9: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Echte Spannungsausgabe

void setup() {

analogWriteResolution(10);

}

void loop() {

analogWrite(A0,0);

analogWrite(A0,1024/2);

analogWrite(A0,1024;

analogWrite(A0,1024/2);

analogWrite(A0,0);

}

Page 10: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015
Page 11: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Echtzeituhr zu Diensten

● Läuft im Sleep-Mode weiter– Lässt sich zum Aufwecken der MCU einspannen

● KEINE Pufferbatterie– Zeit geht verloren, wenn keine Energie vorhanden

● Fertige Bibliothek– https://www.arduino.cc/en/Reference/RTC

– Beispiel via Arturo Guadalupi

Page 12: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

#include <RTCZero.h>

/* Create an rtc object */

RTCZero rtc;

void setup()

{

Serial.begin(9600);

rtc.begin(H24); // initialize RTC 24H format. The dual option is H12

rtc.setTime(hours, minutes, seconds);

rtc.setDate(day, month, year);

}

Page 13: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

void loop(){ Serial.print(rtc.getDay()); Serial.print(rtc.getMonth()); Serial.print(rtc.getYear()); Serial.print(rtc.getHours()); Serial.print(rtc.getMinutes()); Serial.print(rtc.getSeconds());}

Page 14: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Debuggen ist haarig

● Arduino-IDE kann es (noch) nicht– Wird es mE nach auch nie können

● Kombination aus zwei Windows-Programmen– Embedded Visual Studio 2010

● Installation SEHR komplex– http://www.heise.de/developer/artikel/Review-Ein-

Blick-auf-den-Arduino-Zero-2749795.html

Page 15: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Vielfalt ist schön!

● Arduino.org– M0 OHNE EDBG, OHNE USB2

● Leider noch nicht erhältlich ;)

– M0 Pro mit EDBG

● Arduino.cc– Nur mit EDBG

Page 16: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015
Page 17: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

TAMHAN ist B.Ö.S.E (c)

● Lösung: Annette Systems ErsBöserTam● Spielt Snup Tok – Ana Si Sayed● Sprachformat: XML

Page 18: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Antrag bei Bluetooth SIG

● Ich möchte Profil “Bestrafungsgerät”● Antrag wird geprüft...

Page 19: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Antrag bei Bluetooth SIG

● Ich möchte Profil “Bestrafungsgerät”● Antrag wird geprüft...leider nein...

Page 20: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Antrag bei Bluetooth SIG

● Ich möchte Profil “Bestrafungsgerät”● Antrag wird geprüft...leider nein...

– FAUCHUSbösesKITTEN

– Spielt DJ Shadow – Organ Donor

– Sprachformat CSV

Page 21: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Bluetooth LE / Bluetooth Smart

● Physikalisch mit Bluetooth verwandt– Frequenzhopping, Profile etc

● Technisch anders– Für IoT vorgesehen

– Geringer Stromverbrauch

– Sehr geringe Latenz, “bursty transmissions”

– Geringe Komplexität (wo möglich)

Page 22: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Normatives

● Von der Bluetooth SIG betreuter Standard● Offizielle Spezifikationen kostenlos● https://www.bluetooth.org/en-

us/specification/adopted-specifications

Page 23: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Mind the GAP!

● Generic Access Profile● Legt Geräterollen fest

– PERIPHERAL: IoT-”Gadget”, passiv

– CENTRAL: Smartphone, etc

Page 24: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Ich lebe!

● Peripheriegerät sendet regelmäßig Pakete aus– Advertising Interval

● Kann bis zu 31 Bytes an “Nutzdaten” tragen● Optional: Scan Response Request

– Von Central an Peripheral

– Peripheral kann auch hier antworten

Page 25: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Eine Frage der Frequenz

● Senden von Daten braucht Strom● Permanentes Senden: leerer Akku

● Seltenes Senden führt zu Latenz

Page 26: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

I got a GATT!

● Generic ATTribute profile– Folgt auf Verbindungsaufbau

– Exklusiv: pro Peripheral immer nur ein Center

● “KV-Speicher” des Bluetooth LE– GATT Server: Peripheral, hält Daten

– GATT Client: Sendet Anfragen nach Daten

Page 27: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Profile

● Profil: Sammlung von KV-Speicherschemata● Willst du X bauen, so tue Y

– Batteriestatus

– Blutdruckmesser

– Uhrzeit

– Etc

● https://developer.bluetooth.org/TechnologyOverview/Pages/Profiles.aspx#GATT

Page 28: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015
Page 29: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Services

● KV-Speicherschema● Wie speichere ich meine Daten?

● https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx

Page 30: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Characteristics

● Eine Art KV-Speicher● Schreiben und Lesen möglich

● https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicsHome.aspx

Page 31: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

“Serial Characteristics”

● In China populäre “Einfach-Implementierung”● Characteristic 1: Eingang

– Daten seriell raus

● Characteristic 2: Ausgang– Daten seriell rein

● Geschriebene bzw eingelesene Daten– Achtung: maximale Paketlänge!

Page 32: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Futter für Prozessrechner

● Transistor, Diode und Antenne bleiben daheim– Bekannte wollte BT 1.0 implementieren

– Arbeitet immer noch daran

● Fertige Module im Angebot– Fragen Sie ihren Distributor

Page 33: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

HM-Serie

● Chinesischer Hersteller mit TI-IS● Preiswert● Agieren als Master und Slave● ABER

– Firmware oft fehlerhaft

– Support extrem arrogant

– Dokumentation mangelhaft

Page 34: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Nordic Semicon (nRF)

● Bekannter Hersteller mit gutem Support● ABER

– Module teuer

– Teilweise auf “Client”-Rolle beschränkt

– Lies kein P2P

– nRF8001 ist veraltet

Page 35: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Wie kommuniziere ich damit?

● Elektronische Verbindung– UART (klassisch seriell)

– SPI

● Befehle kommen in Form von AT-Commands– Von Modems bekannter Standard

Page 36: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Wie kommuniziere ich damit? - II

● Kommandos beginnen mit AT; enden mit Return● Verkettung mit ;

– AT+CMGL;AT+CGMI<CR> ist FALSCH

● ? bedeutet: Anfrage– AT+BAUD?

● Genaue Syntax => Datenblatt

Page 37: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015
Page 38: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Navigiere indoors

● GLONASS / GPS: geht schlecht● Inertialnavigation: aufwändig

● Lösung: “Dreieckspeilung” ala Apple– Nah

– Mittel

– Weit

Page 39: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Erweitere Bekanntes

● Bluetooth LE und GATT liefern “alles”● Beacon: sendet Advertisements

Via http://www.warski.org/blog/2014/01/how-ibeacons-work/

Page 40: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Module können es selbst

● Manuelles Programmieren oft unnötig● Beispiel JNHuaMao HM10/HM11

– Firmwareupgrade erforderlich

– Funktioniert “teilweise”

Page 41: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Androider Beacon

● Android 4.2, 4.3– BT-Stack stürzt wegen “Overload” ab

● Android ab incl. 4.4– Empfängt Signale

● Android ab 5.0– Vollwertiges Beacon

Page 42: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015
Page 43: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Oszillographen sind zweitrangig

● Oszi: “abbildendes Gerät”– Stellt Wellenform genauestmöglich dar

– WIE wird geredet (Kisuaheli? Alttalmudisch?)

● Logikanalysator: “analysierendes Gerät”– Zeigt Kommunikation auf Paketebene

– WAS sogt a, da' Rasta?

Page 44: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Para yok!

● AliExpress● Ab rund 25 Euro

● Rentiert sich WIRKLICH

Page 45: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015
Page 46: Tam Hanna & Annette Heidi Bosbach - Arduino Zero Pro und Bluetooth LE - code.talks 2015

Thanks !

?!? - !?!

[email protected]

@tamhanna

Pictures from : Drew Jacksich,Martin Lewison, Derek Grossman;via Wikimedia Commons