Using Python for IoT: a return of experience, Alexandre Abadie

Pôle Systematic Paris-Region
Pôle Systematic Paris-RegionPôle Systematic Paris-Region
Python for IoT
A return of experience
Alexandre Abadie, Inria
Outline
What IoT are we talking about ?
The usual protocols for IoT
Pyaiot, connecting objects to the web
How we built Pyaiot
Lessons learned
Conclusion
What IoT are we talking about ?
The Internet of Things today
High-end devices
Low-end devices
⇒ adapted protocols are required
Outline
What IoT are we talking about ?
⇒ The usual protocols for IoT
Pyaiot, connecting objects to the web
How we built Pyaiot
Lessons learned
Conclusion
Usual protocols for IoT: CoAP
Core WG at IETF specifications (2010)
RFC 7252
Similar to HTTP REST:
GET/PUT/POST/DELETE + OBSERVE
Works on UDP with small payload
overhead
More information at http://coap.technology/
source: https://fr.wikipedia.org/wiki/CoAP
CoAP: available implementations in Python
3 available implementations:
TxThings: Twisted based, Python 2 & 3
https://github.com/mwasilak/txThings
Aiocoap: asyncio based, Python 3 only
https://github.com/chrysn/aiocoap
CoaPthon: Threading based, Python 2 & 3
https://github.com/Tanganelli/CoAPthon
Implementations exist for other languages: http://coap.technology/impls.html
Usual protocols for IoT: MQTT
Based on publication/subscriptions to topics pattern
Topics have a path form: this/is/a/topic
MQTT v3.1.1 is an OASIS standard
MQTT Sensor Network (MQTT-SN): adapted for constrained devices
source: https://dev.to/kenwalger/overview-of-the-mqtt-protocol
MQTT: available implementations in Python
2 available implementations:
Paho-mqtt: threading based, considered as the reference implementation
https://pypi.python.org/pypi/paho-mqtt
HBMQTT: asyncio based
https://github.com/beerfactory/hbmqtt
Outline
What IoT are we talking about ?
The usual protocols for IoT
⇒ Pyaiot, connecting objects to the web
How we built Pyaiot
Lessons learned
Conclusion
Why Pyaiot?
Need for a web application able to communicate with contrained devices
⇒ but constrained devices cannot use usual web protocols
Why Pyaiot?
Need for a web application able to communicate with contrained devices
⇒ but constrained devices cannot use usual web protocols
Need for multi-site support
⇒ but constrained devices cannot be exposed directly to the web
Why Pyaiot?
Need for a web application able to communicate with contrained devices
⇒ but constrained devices cannot use usual web protocols
Need for multi-site support
⇒ but constrained devices cannot be exposed directly to the web
Heterogeneous protocol support
⇒ various IoT protocols exist
General guidelines
Open-Source and simple design⇒ can be deployed by anyone
https://github.com/pyaiot/pyaiot
General guidelines
Open-Source and simple design⇒ can be deployed by anyone
https://github.com/pyaiot/pyaiot
Multiprotocol: CoAP, MQTT, etc ⇒ interoperability
General guidelines
Open-Source and simple design⇒ can be deployed by anyone
https://github.com/pyaiot/pyaiot
Multiprotocol: CoAP, MQTT, etc ⇒ interoperability
Modular ⇒ extensible
General guidelines
Open-Source and simple design⇒ can be deployed by anyone
https://github.com/pyaiot/pyaiot
Multiprotocol: CoAP, MQTT, etc ⇒ interoperability
Modular ⇒ extensible
Bi-directionnal and real time access to nodes ⇒ reactive
General guidelines
Open-Source and simple design⇒ can be deployed by anyone
https://github.com/pyaiot/pyaiot
Multiprotocol: CoAP, MQTT, etc ⇒ interoperability
Modular ⇒ extensible
Bi-directionnal and real time access to nodes ⇒ reactive
No constraint regarding the backend language ⇒ let's choose Python!
General guidelines
Open-Source and simple design⇒ can be deployed by anyone
https://github.com/pyaiot/pyaiot
Multiprotocol: CoAP, MQTT, etc ⇒ interoperability
Modular ⇒ extensible
Bi-directionnal and real time access to nodes ⇒ reactive
No constraint regarding the backend language ⇒ let's choose Python!
Pyaiot targets contrained nodes running RIOT: https://riot-os.org
Pyaiot overview
Permanent web showcase for RIOT available at
http://riot-demo.inria.fr
Pyaiot: The web dashboard
Outline
What IoT are we talking about ?
The usual protocols for IoT
Pyaiot, connecting objects to the web
⇒ How we built Pyaiot
Lessons learned
Conclusion
Pyaiot overview
Pyaiot services
Gateways are clients running in private networks
Nodes are kept isolated from Internet
Messages exchanged in JSON format
Works with low-end devices (RIOT) and high-end devices (Python)
Technical choices
Web dashboard developed with Vue.js   http://vuejs.org
Service applications based on Tornado framework with:
HTTP server
Websocket server and client
Aiocoap for CoAP protocol support
HBMQTT for MQTT protocol support
Technical choices
Web dashboard developed with Vue.js   http://vuejs.org
Service applications based on Tornado framework with:
HTTP server
Websocket server and client
Aiocoap for CoAP protocol support
HBMQTT for MQTT protocol support
⇒ All python packages are asyncio based/compatible ⇒ simplify integration
The MQTT gateway in detail
MQTT-SN is required for low-end device
⇒ a MQTT to MQTT-SN gateway/broker is required
No implementation in Python
⇒ let's go for mosquitto.rsmb
The MQTT gateway in detail
MQTT-SN is required for low-end device
⇒ a MQTT to MQTT-SN gateway/broker is required
No implementation in Python
⇒ let's go for mosquitto.rsmb
Node/Gateway
subscribe/publish to topic publish/subscribe to topics
gateway//discover node/check
node//resources
node//
Outline
What IoT are we talking about ?
The usual protocols for IoT
Pyaiot, connecting objects to the web
How we built Pyaiot
⇒ Lessons learned
Conclusion
Using asyncio
Easy to read asynchronous programming language
Using asyncio
Easy to read asynchronous programming language
Asyncio new syntax available with Python >= 3.5
Using asyncio
Easy to read asynchronous programming language
Asyncio new syntax available with Python >= 3.5
... but Python 3.4.2 available on Raspbian
@asyncio.coroutine
def my_coroutine():
my_long_call()
yield from my_coroutine() # wait until done
asyncio.get_event_loop().create_task(my_coroutine) # scheduled in ioloop
asyncio.ensure_future(my_coroutine) # scheduled in ioloop, requires python 3.4.4
Using asyncio
Easy to read asynchronous programming language
Asyncio new syntax available with Python >= 3.5
... but Python 3.4.2 available on Raspbian
@asyncio.coroutine
def my_coroutine():
my_long_call()
yield from my_coroutine() # wait until done
asyncio.get_event_loop().create_task(my_coroutine) # scheduled in ioloop
asyncio.ensure_future(my_coroutine) # scheduled in ioloop, requires python 3.4.4
with python 3.5 new syntax:
async def my_coroutine():
my_long_call()
await my_coroutine() # wait until done
asyncio.ensure_future(my_coroutine) # scheduled in ioloop
The benefits of Python
Develop fast, even with complex things
The benefits of Python
Develop fast, even with complex things
Can run on any high-end device : from a Raspberry PI to a Cloud server
The benefits of Python
Develop fast, even with complex things
Can run on any high-end device : from a Raspberry PI to a Cloud server
Off-the-shelf packages for IoT available: Aiocoap, HBMQTT
The benefits of Python
Develop fast, even with complex things
Can run on any high-end device : from a Raspberry PI to a Cloud server
Off-the-shelf packages for IoT available: Aiocoap, HBMQTT
⇒ Python is adapted to IoT
Conclusion
Widely used protocol in IoT is MQTT
Adapted protocols are required for constrained devices (microcontrollers)
⇒ CoAP, MQTT-SN
Conclusion
Widely used protocol in IoT is MQTT
Adapted protocols are required for constrained devices (microcontrollers)
⇒ CoAP, MQTT-SN
We easily built an application following the initial requirements
⇒ Pyaiot: https://github.com/pyaiot/pyaiot
Conclusion
Widely used protocol in IoT is MQTT
Adapted protocols are required for constrained devices (microcontrollers)
⇒ CoAP, MQTT-SN
We easily built an application following the initial requirements
⇒ Pyaiot: https://github.com/pyaiot/pyaiot
Asyncio made things simpler... after some headaches
Conclusion
Widely used protocol in IoT is MQTT
Adapted protocols are required for constrained devices (microcontrollers)
⇒ CoAP, MQTT-SN
We easily built an application following the initial requirements
⇒ Pyaiot: https://github.com/pyaiot/pyaiot
Asyncio made things simpler... after some headaches
Pyaiot is still work in progress... even if it works pretty well
Demo!
http://riot-demo.inria.fr
Thanks!
1 of 44

Recommended

Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and... by
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...Pôle Systematic Paris-Region
2.3K views57 slides
Is Python still production ready ? Ludovic Gasc by
Is Python still production ready ? Ludovic GascIs Python still production ready ? Ludovic Gasc
Is Python still production ready ? Ludovic GascPôle Systematic Paris-Region
649 views68 slides
PyParis 2017 / Writing a C Python extension in 2017, Jean-Baptiste Aviat by
PyParis 2017 / Writing a C Python extension in 2017, Jean-Baptiste Aviat PyParis 2017 / Writing a C Python extension in 2017, Jean-Baptiste Aviat
PyParis 2017 / Writing a C Python extension in 2017, Jean-Baptiste Aviat Pôle Systematic Paris-Region
997 views42 slides
Building a high-performance, scalable ML & NLP platform with Python, Sheer El... by
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...Pôle Systematic Paris-Region
3.1K views27 slides
PyParis 2017 / Pandas - What's new and whats coming - Joris van den Bossche by
PyParis 2017 / Pandas - What's new and whats coming - Joris van den BosschePyParis 2017 / Pandas - What's new and whats coming - Joris van den Bossche
PyParis 2017 / Pandas - What's new and whats coming - Joris van den BosschePôle Systematic Paris-Region
865 views48 slides
平行化你的工作 part1 by
平行化你的工作 part1平行化你的工作 part1
平行化你的工作 part1Shuen-Huei Guan
1.1K views25 slides

More Related Content

What's hot

Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011) by
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Fabrice Bernhard
3.8K views52 slides
From Python to smartphones: neural nets @ Saint-Gobain, François Sausset by
From Python to smartphones: neural nets @ Saint-Gobain, François SaussetFrom Python to smartphones: neural nets @ Saint-Gobain, François Sausset
From Python to smartphones: neural nets @ Saint-Gobain, François SaussetPôle Systematic Paris-Region
404 views7 slides
Node js meetup by
Node js meetupNode js meetup
Node js meetupAnsuman Roy
275 views37 slides
Debugging of (C)Python applications by
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applicationsRoman Podoliaka
691 views40 slides
Lua vs python by
Lua vs pythonLua vs python
Lua vs pythonHoChul Shin
17.8K views17 slides
OSDC 2017 - Casey Callendrello -The evolution of the Container Network Interface by
OSDC 2017 - Casey Callendrello -The evolution of the Container Network InterfaceOSDC 2017 - Casey Callendrello -The evolution of the Container Network Interface
OSDC 2017 - Casey Callendrello -The evolution of the Container Network InterfaceNETWAYS
91 views61 slides

What's hot(20)

Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011) by Fabrice Bernhard
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard3.8K views
Debugging of (C)Python applications by Roman Podoliaka
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applications
Roman Podoliaka691 views
Lua vs python by HoChul Shin
Lua vs pythonLua vs python
Lua vs python
HoChul Shin17.8K views
OSDC 2017 - Casey Callendrello -The evolution of the Container Network Interface by NETWAYS
OSDC 2017 - Casey Callendrello -The evolution of the Container Network InterfaceOSDC 2017 - Casey Callendrello -The evolution of the Container Network Interface
OSDC 2017 - Casey Callendrello -The evolution of the Container Network Interface
NETWAYS91 views
Import golang; struct microservice by Giulio De Donato
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
Giulio De Donato4.2K views
WebRTC と Native とそれから、それから。 by tnoho
WebRTC と Native とそれから、それから。 WebRTC と Native とそれから、それから。
WebRTC と Native とそれから、それから。
tnoho5.8K views
Dependency management in golang by Ramit Surana
Dependency management in golangDependency management in golang
Dependency management in golang
Ramit Surana1.4K views
Wonders of Golang by Kartik Sura
Wonders of GolangWonders of Golang
Wonders of Golang
Kartik Sura923 views
10 reasons to be excited about go by Dvir Volk
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
Dvir Volk11.2K views
Network Test Automation - Net Ops Coding 2015 by Hiroshi Ota
Network Test Automation - Net Ops Coding 2015Network Test Automation - Net Ops Coding 2015
Network Test Automation - Net Ops Coding 2015
Hiroshi Ota2K views
Beachhead implements new opcode on CLR JIT by Kouji Matsui
Beachhead implements new opcode on CLR JITBeachhead implements new opcode on CLR JIT
Beachhead implements new opcode on CLR JIT
Kouji Matsui18.2K views
Polyglot Applications with GraalVM by jexp
Polyglot Applications with GraalVMPolyglot Applications with GraalVM
Polyglot Applications with GraalVM
jexp1.9K views
Reactive Programming by UniRx for Asynchronous & Event Processing by Yoshifumi Kawai
Reactive Programming by UniRx for Asynchronous & Event ProcessingReactive Programming by UniRx for Asynchronous & Event Processing
Reactive Programming by UniRx for Asynchronous & Event Processing
Yoshifumi Kawai65.5K views
The BlackBox Project: Safely store secrets in Git/Mercurial (originally for P... by Tom Limoncelli
The BlackBox Project: Safely store secrets in Git/Mercurial (originally for P...The BlackBox Project: Safely store secrets in Git/Mercurial (originally for P...
The BlackBox Project: Safely store secrets in Git/Mercurial (originally for P...
Tom Limoncelli14.2K views
Golang from Scala developer’s perspective by Sveta Bozhko
Golang from Scala developer’s perspectiveGolang from Scala developer’s perspective
Golang from Scala developer’s perspective
Sveta Bozhko2.6K views
Caffe2 on Android by Koan-Sin Tan
Caffe2 on AndroidCaffe2 on Android
Caffe2 on Android
Koan-Sin Tan1.8K views

Similar to Using Python for IoT: a return of experience, Alexandre Abadie

Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT by
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoTInria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoTStéphanie Roger
323 views48 slides
Tranquilizer by
TranquilizerTranquilizer
TranquilizerAlbert DeFusco
60 views19 slides
La web de las Cosas by
La web de las CosasLa web de las Cosas
La web de las CosasAgile Express Ecuador / Thoughtworks
662 views28 slides
Adding IEEE 802.15.4 and 6LoWPAN to an Embedded Linux Device by
Adding IEEE 802.15.4 and 6LoWPAN to an Embedded Linux DeviceAdding IEEE 802.15.4 and 6LoWPAN to an Embedded Linux Device
Adding IEEE 802.15.4 and 6LoWPAN to an Embedded Linux DeviceSamsung Open Source Group
31.9K views42 slides
The Crucial Component of IoT Products by Aravinth Panchadcharam [ Senior Embe... by
The Crucial Component of IoT Products by Aravinth Panchadcharam [ Senior Embe...The Crucial Component of IoT Products by Aravinth Panchadcharam [ Senior Embe...
The Crucial Component of IoT Products by Aravinth Panchadcharam [ Senior Embe...Next Big Thing AG
349 views29 slides
Monkey Server by
Monkey ServerMonkey Server
Monkey ServerEduardo Silva Pereira
1.7K views63 slides

Similar to Using Python for IoT: a return of experience, Alexandre Abadie(20)

Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT by Stéphanie Roger
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoTInria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
Stéphanie Roger323 views
The Crucial Component of IoT Products by Aravinth Panchadcharam [ Senior Embe... by Next Big Thing AG
The Crucial Component of IoT Products by Aravinth Panchadcharam [ Senior Embe...The Crucial Component of IoT Products by Aravinth Panchadcharam [ Senior Embe...
The Crucial Component of IoT Products by Aravinth Panchadcharam [ Senior Embe...
Next Big Thing AG349 views
Возможности интерпретатора Python в NX-OS by Cisco Russia
Возможности интерпретатора Python в NX-OSВозможности интерпретатора Python в NX-OS
Возможности интерпретатора Python в NX-OS
Cisco Russia 1.5K views
Internet of Things - protocols review (MeetUp Wireless & Networks, Poznań 21.... by Marcin Bielak
Internet of Things - protocols review (MeetUp Wireless & Networks, Poznań 21....Internet of Things - protocols review (MeetUp Wireless & Networks, Poznań 21....
Internet of Things - protocols review (MeetUp Wireless & Networks, Poznań 21....
Marcin Bielak1.8K views
PyQt Application Development On Maemo by achipa
PyQt Application Development On MaemoPyQt Application Development On Maemo
PyQt Application Development On Maemo
achipa2.8K views
P4+ONOS SRv6 tutorial.pptx by tampham61268
P4+ONOS SRv6 tutorial.pptxP4+ONOS SRv6 tutorial.pptx
P4+ONOS SRv6 tutorial.pptx
tampham612683 views
ORTC Library - Introduction by Erik Lagerway
ORTC Library - IntroductionORTC Library - Introduction
ORTC Library - Introduction
Erik Lagerway24.9K views
Serial Data from Arduino to Raspberry Pi to MySQL using CoAP Protocol by Sanjay Kumar
Serial Data from Arduino to Raspberry Pi to MySQL using CoAP ProtocolSerial Data from Arduino to Raspberry Pi to MySQL using CoAP Protocol
Serial Data from Arduino to Raspberry Pi to MySQL using CoAP Protocol
Sanjay Kumar1.9K views
An hour with WebRTC FIC UDC by Quobis
An hour with WebRTC FIC UDCAn hour with WebRTC FIC UDC
An hour with WebRTC FIC UDC
Quobis1.8K views
From the internet of things to the web of things course by Dominique Guinard
From the internet of things to the web of things courseFrom the internet of things to the web of things course
From the internet of things to the web of things course
Dominique Guinard1.2K views
Master-Master Replication and Scaling of an Application Between Each of the I... by vsoshnikov
Master-Master Replication and Scaling of an Application Between Each of the I...Master-Master Replication and Scaling of an Application Between Each of the I...
Master-Master Replication and Scaling of an Application Between Each of the I...
vsoshnikov356 views
swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ... by Ivan Kravets
swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ...swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ...
swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ...
Ivan Kravets7.4K views
End-to-end IoT solutions with Java and Eclipse IoT by Benjamin Cabé
End-to-end IoT solutions with Java and Eclipse IoTEnd-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoT
Benjamin Cabé5K views
Openshift 3.10 & Container solutions for Blockchain, IoT and Data Science by John Archer
Openshift 3.10 & Container solutions for Blockchain, IoT and Data ScienceOpenshift 3.10 & Container solutions for Blockchain, IoT and Data Science
Openshift 3.10 & Container solutions for Blockchain, IoT and Data Science
John Archer4.4K views

More from Pôle Systematic Paris-Region

OSIS19_IoT :Transparent remote connectivity to short-range IoT devices, by Na... by
OSIS19_IoT :Transparent remote connectivity to short-range IoT devices, by Na...OSIS19_IoT :Transparent remote connectivity to short-range IoT devices, by Na...
OSIS19_IoT :Transparent remote connectivity to short-range IoT devices, by Na...Pôle Systematic Paris-Region
686 views39 slides
OSIS19_Cloud : SAFC: Scheduling and Allocation Framework for Containers in a ... by
OSIS19_Cloud : SAFC: Scheduling and Allocation Framework for Containers in a ...OSIS19_Cloud : SAFC: Scheduling and Allocation Framework for Containers in a ...
OSIS19_Cloud : SAFC: Scheduling and Allocation Framework for Containers in a ...Pôle Systematic Paris-Region
293 views24 slides
OSIS19_Cloud : Qu’apporte l’observabilité à la gestion de configuration? par ... by
OSIS19_Cloud : Qu’apporte l’observabilité à la gestion de configuration? par ...OSIS19_Cloud : Qu’apporte l’observabilité à la gestion de configuration? par ...
OSIS19_Cloud : Qu’apporte l’observabilité à la gestion de configuration? par ...Pôle Systematic Paris-Region
349 views38 slides
OSIS19_Cloud : Performance and power management in virtualized data centers, ... by
OSIS19_Cloud : Performance and power management in virtualized data centers, ...OSIS19_Cloud : Performance and power management in virtualized data centers, ...
OSIS19_Cloud : Performance and power management in virtualized data centers, ...Pôle Systematic Paris-Region
288 views27 slides
OSIS19_Cloud : Des objets dans le cloud, et qui y restent -- L'expérience du ... by
OSIS19_Cloud : Des objets dans le cloud, et qui y restent -- L'expérience du ...OSIS19_Cloud : Des objets dans le cloud, et qui y restent -- L'expérience du ...
OSIS19_Cloud : Des objets dans le cloud, et qui y restent -- L'expérience du ...Pôle Systematic Paris-Region
271 views30 slides
OSIS19_Cloud : Attribution automatique de ressources pour micro-services, Alt... by
OSIS19_Cloud : Attribution automatique de ressources pour micro-services, Alt...OSIS19_Cloud : Attribution automatique de ressources pour micro-services, Alt...
OSIS19_Cloud : Attribution automatique de ressources pour micro-services, Alt...Pôle Systematic Paris-Region
229 views9 slides

More from Pôle Systematic Paris-Region(20)

Recently uploaded

Data-centric AI and the convergence of data and model engineering: opportunit... by
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...Paolo Missier
34 views40 slides
The Research Portal of Catalonia: Growing more (information) & more (services) by
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)CSUC - Consorci de Serveis Universitaris de Catalunya
73 views25 slides
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Safe Software
225 views86 slides
Special_edition_innovator_2023.pdf by
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdfWillDavies22
16 views6 slides
1st parposal presentation.pptx by
1st parposal presentation.pptx1st parposal presentation.pptx
1st parposal presentation.pptxi238212
9 views3 slides
DALI Basics Course 2023 by
DALI Basics Course  2023DALI Basics Course  2023
DALI Basics Course 2023Ivory Egg
14 views12 slides

Recently uploaded(20)

Data-centric AI and the convergence of data and model engineering: opportunit... by Paolo Missier
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...
Paolo Missier34 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software225 views
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2216 views
1st parposal presentation.pptx by i238212
1st parposal presentation.pptx1st parposal presentation.pptx
1st parposal presentation.pptx
i2382129 views
DALI Basics Course 2023 by Ivory Egg
DALI Basics Course  2023DALI Basics Course  2023
DALI Basics Course 2023
Ivory Egg14 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri15 views
6g - REPORT.pdf by Liveplex
6g - REPORT.pdf6g - REPORT.pdf
6g - REPORT.pdf
Liveplex9 views
Perth MeetUp November 2023 by Michael Price
Perth MeetUp November 2023 Perth MeetUp November 2023
Perth MeetUp November 2023
Michael Price15 views
Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec11 views
Black and White Modern Science Presentation.pptx by maryamkhalid2916
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptx
maryamkhalid291614 views
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada130 views
Case Study Copenhagen Energy and Business Central.pdf by Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana12 views
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta15 views

Using Python for IoT: a return of experience, Alexandre Abadie

  • 1. Python for IoT A return of experience Alexandre Abadie, Inria
  • 2. Outline What IoT are we talking about ? The usual protocols for IoT Pyaiot, connecting objects to the web How we built Pyaiot Lessons learned Conclusion
  • 3. What IoT are we talking about ? The Internet of Things today
  • 5. Low-end devices ⇒ adapted protocols are required
  • 6. Outline What IoT are we talking about ? ⇒ The usual protocols for IoT Pyaiot, connecting objects to the web How we built Pyaiot Lessons learned Conclusion
  • 7. Usual protocols for IoT: CoAP Core WG at IETF specifications (2010) RFC 7252 Similar to HTTP REST: GET/PUT/POST/DELETE + OBSERVE Works on UDP with small payload overhead More information at http://coap.technology/ source: https://fr.wikipedia.org/wiki/CoAP
  • 8. CoAP: available implementations in Python 3 available implementations: TxThings: Twisted based, Python 2 & 3 https://github.com/mwasilak/txThings Aiocoap: asyncio based, Python 3 only https://github.com/chrysn/aiocoap CoaPthon: Threading based, Python 2 & 3 https://github.com/Tanganelli/CoAPthon Implementations exist for other languages: http://coap.technology/impls.html
  • 9. Usual protocols for IoT: MQTT Based on publication/subscriptions to topics pattern Topics have a path form: this/is/a/topic MQTT v3.1.1 is an OASIS standard MQTT Sensor Network (MQTT-SN): adapted for constrained devices source: https://dev.to/kenwalger/overview-of-the-mqtt-protocol
  • 10. MQTT: available implementations in Python 2 available implementations: Paho-mqtt: threading based, considered as the reference implementation https://pypi.python.org/pypi/paho-mqtt HBMQTT: asyncio based https://github.com/beerfactory/hbmqtt
  • 11. Outline What IoT are we talking about ? The usual protocols for IoT ⇒ Pyaiot, connecting objects to the web How we built Pyaiot Lessons learned Conclusion
  • 12. Why Pyaiot? Need for a web application able to communicate with contrained devices ⇒ but constrained devices cannot use usual web protocols
  • 13. Why Pyaiot? Need for a web application able to communicate with contrained devices ⇒ but constrained devices cannot use usual web protocols Need for multi-site support ⇒ but constrained devices cannot be exposed directly to the web
  • 14. Why Pyaiot? Need for a web application able to communicate with contrained devices ⇒ but constrained devices cannot use usual web protocols Need for multi-site support ⇒ but constrained devices cannot be exposed directly to the web Heterogeneous protocol support ⇒ various IoT protocols exist
  • 15. General guidelines Open-Source and simple design⇒ can be deployed by anyone https://github.com/pyaiot/pyaiot
  • 16. General guidelines Open-Source and simple design⇒ can be deployed by anyone https://github.com/pyaiot/pyaiot Multiprotocol: CoAP, MQTT, etc ⇒ interoperability
  • 17. General guidelines Open-Source and simple design⇒ can be deployed by anyone https://github.com/pyaiot/pyaiot Multiprotocol: CoAP, MQTT, etc ⇒ interoperability Modular ⇒ extensible
  • 18. General guidelines Open-Source and simple design⇒ can be deployed by anyone https://github.com/pyaiot/pyaiot Multiprotocol: CoAP, MQTT, etc ⇒ interoperability Modular ⇒ extensible Bi-directionnal and real time access to nodes ⇒ reactive
  • 19. General guidelines Open-Source and simple design⇒ can be deployed by anyone https://github.com/pyaiot/pyaiot Multiprotocol: CoAP, MQTT, etc ⇒ interoperability Modular ⇒ extensible Bi-directionnal and real time access to nodes ⇒ reactive No constraint regarding the backend language ⇒ let's choose Python!
  • 20. General guidelines Open-Source and simple design⇒ can be deployed by anyone https://github.com/pyaiot/pyaiot Multiprotocol: CoAP, MQTT, etc ⇒ interoperability Modular ⇒ extensible Bi-directionnal and real time access to nodes ⇒ reactive No constraint regarding the backend language ⇒ let's choose Python! Pyaiot targets contrained nodes running RIOT: https://riot-os.org
  • 21. Pyaiot overview Permanent web showcase for RIOT available at http://riot-demo.inria.fr
  • 22. Pyaiot: The web dashboard
  • 23. Outline What IoT are we talking about ? The usual protocols for IoT Pyaiot, connecting objects to the web ⇒ How we built Pyaiot Lessons learned Conclusion
  • 25. Pyaiot services Gateways are clients running in private networks Nodes are kept isolated from Internet Messages exchanged in JSON format Works with low-end devices (RIOT) and high-end devices (Python)
  • 26. Technical choices Web dashboard developed with Vue.js   http://vuejs.org Service applications based on Tornado framework with: HTTP server Websocket server and client Aiocoap for CoAP protocol support HBMQTT for MQTT protocol support
  • 27. Technical choices Web dashboard developed with Vue.js   http://vuejs.org Service applications based on Tornado framework with: HTTP server Websocket server and client Aiocoap for CoAP protocol support HBMQTT for MQTT protocol support ⇒ All python packages are asyncio based/compatible ⇒ simplify integration
  • 28. The MQTT gateway in detail MQTT-SN is required for low-end device ⇒ a MQTT to MQTT-SN gateway/broker is required No implementation in Python ⇒ let's go for mosquitto.rsmb
  • 29. The MQTT gateway in detail MQTT-SN is required for low-end device ⇒ a MQTT to MQTT-SN gateway/broker is required No implementation in Python ⇒ let's go for mosquitto.rsmb Node/Gateway subscribe/publish to topic publish/subscribe to topics gateway//discover node/check node//resources node//
  • 30. Outline What IoT are we talking about ? The usual protocols for IoT Pyaiot, connecting objects to the web How we built Pyaiot ⇒ Lessons learned Conclusion
  • 31. Using asyncio Easy to read asynchronous programming language
  • 32. Using asyncio Easy to read asynchronous programming language Asyncio new syntax available with Python >= 3.5
  • 33. Using asyncio Easy to read asynchronous programming language Asyncio new syntax available with Python >= 3.5 ... but Python 3.4.2 available on Raspbian @asyncio.coroutine def my_coroutine(): my_long_call() yield from my_coroutine() # wait until done asyncio.get_event_loop().create_task(my_coroutine) # scheduled in ioloop asyncio.ensure_future(my_coroutine) # scheduled in ioloop, requires python 3.4.4
  • 34. Using asyncio Easy to read asynchronous programming language Asyncio new syntax available with Python >= 3.5 ... but Python 3.4.2 available on Raspbian @asyncio.coroutine def my_coroutine(): my_long_call() yield from my_coroutine() # wait until done asyncio.get_event_loop().create_task(my_coroutine) # scheduled in ioloop asyncio.ensure_future(my_coroutine) # scheduled in ioloop, requires python 3.4.4 with python 3.5 new syntax: async def my_coroutine(): my_long_call() await my_coroutine() # wait until done asyncio.ensure_future(my_coroutine) # scheduled in ioloop
  • 35. The benefits of Python Develop fast, even with complex things
  • 36. The benefits of Python Develop fast, even with complex things Can run on any high-end device : from a Raspberry PI to a Cloud server
  • 37. The benefits of Python Develop fast, even with complex things Can run on any high-end device : from a Raspberry PI to a Cloud server Off-the-shelf packages for IoT available: Aiocoap, HBMQTT
  • 38. The benefits of Python Develop fast, even with complex things Can run on any high-end device : from a Raspberry PI to a Cloud server Off-the-shelf packages for IoT available: Aiocoap, HBMQTT ⇒ Python is adapted to IoT
  • 39. Conclusion Widely used protocol in IoT is MQTT Adapted protocols are required for constrained devices (microcontrollers) ⇒ CoAP, MQTT-SN
  • 40. Conclusion Widely used protocol in IoT is MQTT Adapted protocols are required for constrained devices (microcontrollers) ⇒ CoAP, MQTT-SN We easily built an application following the initial requirements ⇒ Pyaiot: https://github.com/pyaiot/pyaiot
  • 41. Conclusion Widely used protocol in IoT is MQTT Adapted protocols are required for constrained devices (microcontrollers) ⇒ CoAP, MQTT-SN We easily built an application following the initial requirements ⇒ Pyaiot: https://github.com/pyaiot/pyaiot Asyncio made things simpler... after some headaches
  • 42. Conclusion Widely used protocol in IoT is MQTT Adapted protocols are required for constrained devices (microcontrollers) ⇒ CoAP, MQTT-SN We easily built an application following the initial requirements ⇒ Pyaiot: https://github.com/pyaiot/pyaiot Asyncio made things simpler... after some headaches Pyaiot is still work in progress... even if it works pretty well