lopy lorawan iot workshoplopy lorawan iot workshop university of edinburgh pycom october 2016 the...

17
LoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016

Upload: others

Post on 19-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

LoPy LoRaWAN IoTWorkshopUniversityofEdinburgh

PycomOctober2016

Page 2: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

ThePlanforToday

• Twohourworkshop• weareworkinginpairs,eachpairneedsalaptop.

• We’llgiveabitofbackgroundonLoRaWAN• Thewe’llgetstuckintoPycom LoPy programming• Gettingsetup• SimpleLoRaWAN communication• HookingupaLightSensor

• At4pmpresentationbyFreddeHaro CEOofPycom• Alldoneby5pm

Page 3: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

LoRaWANforLowPowerWideAreaNetworking

Page 4: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

LoRaWAN SpecificationEuropeLoRaWAN™forEuropeLoRaWAN definestenchannels,eightofwhicharemultidataratefrom250bpsto5.5kbps,asinglehighdatarateLoRa®channelat11kbps,andasingleFSKchannelat50kbps.ThemaximumoutputpowerallowedbyETSIinEuropeis+14dBM,withtheexceptionoftheG3bandwhichallows+27dBm.TherearedutycyclerestrictionsunderETSIbutnomaxtransmissionorchanneldwelltimelimitations.

Page 5: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

LoRaWAN Architecture

Page 6: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

LoRaWAN performancecharacteristics

Page 7: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

Green=5kmRed=10kmradiuscoveragecentred onGeorgeSquare

UniversityofEdinburghisputtinginplace5Kerlink gateways.

Multiplegatewaysalsoenabletriangulationofpositionofsensors(LoRaWAN 2.0).

Page 8: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

LoRaWAN DeviceClasses

“Aloha”

Page 9: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

KeyLoRaWAN NetworkingConcepts• Dataisencryptedatthenetworklayer(metadata)andseparatelyattheapplicationlayer(payload).• Application

• AnApplicationisidentifiedbyaunique64-bitApplicationEUI.• DevicesmustberegisteredwithaspecificApplication.

• Device• Adevicehasaunique64-bitDeviceEUIassignedbythemanufacturer.• Thenetworkwillrefertothedevicebyassigningita32-bitDeviceAddress.

• ActivationByPersonalisation (ABP)[insecure]• Requiresyouknowyourassigned32-bitDeviceAddress,and128-bitApplicationSessionKeyand128-bitNetworkSession

Key– astaticconfiguration.• OverTheAirActivation(OTAA)[secure]

• RequiresyouknowyourApplication’sKey(whichisassignedwhentheApplicationiscreated),ApplicationEUIandDeviceEUI.

• Sessionkeysareassigneddynamicallybythenetworkaspartofthejoinprocedure.• Framecountsaremaintainedbythenetworkanddeviceforuplink(devicetogateway)anddownlink(gatewaytodevice).Thenetworkwillrejectnewframesreceivedthathaveanearlierframecount.

WewillonlybeusingABPtoday.

Page 10: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

Whatweareaimingtobuildtoday

Page 11: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

Thisisourfirsttime!Pleasebepatient…Thisisreallynewtechnologyandyouhavetheverylatestfirmwarereleaseinyourhandsbeforeanyoneelse(!),andtherewillbelotsforallofustolearntodayJ

Page 12: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

Initialsetup

• DownloadandinstallthePymakr IDE• PlugyourLoPy inviatheUSBcabletoyourlaptop• Ifworking,youshouldseeaperiodicflashingbluelight

• RunPymakr IDE• TheLoPy willbeconnectedtoviaUSBserialport

• IfnottryexitingandrestartingPymakr…

Page 13: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

TurnofftheflashingblueLED

AttheMicro-Pythonprompttype:

import pycompycom.heartbeat(False)

Page 14: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

Let’ssendamessageviaLoRaWAN

• OpenanewsourcecodefileinPymakr tosaveyourcodein.• Youcansimplyrunthecontentsofthisfile(greenplaybutton)ontheLoPy.• Youwillneedtosetthevariousauth keystothoseforyourLoPy.

from network import LoRaimport timeimport socketlora = LoRa(mode=LoRa.LORAWAN)# ABP auth tuple (NwkSKey, AppSKey, DevAddr)auth = (bytes([…]), bytes([…]), …)lora.join(activation=LoRa.ABP, auth=auth)while not lora.has_joined():time.sleep(2.5)

s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)s.setblocking(False)s.send(“hello-X”) # X = your group number

Page 15: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

AndnowfortheLightSensor

• LightSensor drivercodewillbedistributedviaemail/USBstick.• Pleasetakecarewiringuptheboard,andusetheantistaticwriststrapprovided.• Therestisuptoyou!

• Thegoalistotransfertheluxlightreadingonceevery30secondstotheUoE LoRaWAN backend.

Page 16: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

WiringuptheLightSensorboard

• Pleasenoteontheexpansionboardpinout:G16=SDAG17=SCL

• Wewillconnect3V3ontheexpansionboardtoVINonthesensor,andGNDtoGNDasyouwouldexpect.

Page 17: LoPy LoRaWAN IoT WorkshopLoPy LoRaWAN IoT Workshop University of Edinburgh Pycom October 2016 The Plan for Today • Two hour workshop • we are working in pairs, each pair needs

That’sallfolks!Thankssomuchforyourparticipationandpleasesendusyourfeedbackbyemail,good/baditallhelpsimprovethetechandourworkshopdelivery,andpleasedoalsotelluswhatwouldyoulikeafutureworkshoptocoverwiththeLoPy?