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

Post on 19-Jun-2020

1 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

LoPy LoRaWAN IoTWorkshopUniversityofEdinburgh

PycomOctober2016

ThePlanforToday

• Twohourworkshop• weareworkinginpairs,eachpairneedsalaptop.

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

• At4pmpresentationbyFreddeHaro CEOofPycom• Alldoneby5pm

LoRaWANforLowPowerWideAreaNetworking

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

LoRaWAN Architecture

LoRaWAN performancecharacteristics

Green=5kmRed=10kmradiuscoveragecentred onGeorgeSquare

UniversityofEdinburghisputtinginplace5Kerlink gateways.

Multiplegatewaysalsoenabletriangulationofpositionofsensors(LoRaWAN 2.0).

LoRaWAN DeviceClasses

“Aloha”

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.

Whatweareaimingtobuildtoday

Thisisourfirsttime!Pleasebepatient…Thisisreallynewtechnologyandyouhavetheverylatestfirmwarereleaseinyourhandsbeforeanyoneelse(!),andtherewillbelotsforallofustolearntodayJ

Initialsetup

• DownloadandinstallthePymakr IDE• PlugyourLoPy inviatheUSBcabletoyourlaptop• Ifworking,youshouldseeaperiodicflashingbluelight

• RunPymakr IDE• TheLoPy willbeconnectedtoviaUSBserialport

• IfnottryexitingandrestartingPymakr…

TurnofftheflashingblueLED

AttheMicro-Pythonprompttype:

import pycompycom.heartbeat(False)

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

AndnowfortheLightSensor

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

• Thegoalistotransfertheluxlightreadingonceevery30secondstotheUoE LoRaWAN backend.

WiringuptheLightSensorboard

• Pleasenoteontheexpansionboardpinout:G16=SDAG17=SCL

• Wewillconnect3V3ontheexpansionboardtoVINonthesensor,andGNDtoGNDasyouwouldexpect.

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

top related