SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
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!

Contenu connexe

Tendances

Tendances (20)

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)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
From Python to smartphones: neural nets @ Saint-Gobain, François Sausset
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 Sausset
 
Node js meetup
Node js meetupNode js meetup
Node js meetup
 
Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applications
 
Lua vs python
Lua vs pythonLua vs python
Lua vs python
 
OSDC 2017 - Casey Callendrello -The evolution of the Container Network Interface
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
 
Golang
GolangGolang
Golang
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 
WebRTC と Native とそれから、それから。
WebRTC と Native とそれから、それから。 WebRTC と Native とそれから、それから。
WebRTC と Native とそれから、それから。
 
Dependency management in golang
Dependency management in golangDependency management in golang
Dependency management in golang
 
Wonders of Golang
Wonders of GolangWonders of Golang
Wonders of Golang
 
Inroduction to golang
Inroduction to golangInroduction to golang
Inroduction to golang
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
 
Network Test Automation - Net Ops Coding 2015
Network Test Automation - Net Ops Coding 2015Network Test Automation - Net Ops Coding 2015
Network Test Automation - Net Ops Coding 2015
 
Beachhead implements new opcode on CLR JIT
Beachhead implements new opcode on CLR JITBeachhead implements new opcode on CLR JIT
Beachhead implements new opcode on CLR JIT
 
Polyglot Applications with GraalVM
Polyglot Applications with GraalVMPolyglot Applications with GraalVM
Polyglot Applications with GraalVM
 
Reactive Programming by UniRx for Asynchronous & Event Processing
Reactive Programming by UniRx for Asynchronous & Event ProcessingReactive Programming by UniRx for Asynchronous & Event Processing
Reactive Programming by UniRx for Asynchronous & Event Processing
 
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...
The BlackBox Project: Safely store secrets in Git/Mercurial (originally for P...
 
Golang from Scala developer’s perspective
Golang from Scala developer’s perspectiveGolang from Scala developer’s perspective
Golang from Scala developer’s perspective
 
Caffe2 on Android
Caffe2 on AndroidCaffe2 on Android
Caffe2 on Android
 

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

An hour with WebRTC FIC UDC
An hour with WebRTC FIC UDCAn hour with WebRTC FIC UDC
An hour with WebRTC FIC UDC
Quobis
 

Similaire à Using Python for IoT: a return of experience, Alexandre Abadie (20)

Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
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
 
Tranquilizer
TranquilizerTranquilizer
Tranquilizer
 
La web de las Cosas
La web de las CosasLa web de las Cosas
La web de las Cosas
 
Adding IEEE 802.15.4 and 6LoWPAN to an Embedded Linux Device
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 Device
 
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...
The Crucial Component of IoT Products by Aravinth Panchadcharam [ Senior Embe...
 
Monkey Server
Monkey ServerMonkey Server
Monkey Server
 
APIs at the Edge
APIs at the EdgeAPIs at the Edge
APIs at the Edge
 
Возможности интерпретатора Python в NX-OS
Возможности интерпретатора Python в NX-OSВозможности интерпретатора Python в NX-OS
Возможности интерпретатора Python в NX-OS
 
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....
Internet of Things - protocols review (MeetUp Wireless & Networks, Poznań 21....
 
PyQt Application Development On Maemo
PyQt Application Development On MaemoPyQt Application Development On Maemo
PyQt Application Development On Maemo
 
IoT with Apache ActiveMQ, Camel & Spark
IoT with Apache ActiveMQ, Camel & SparkIoT with Apache ActiveMQ, Camel & Spark
IoT with Apache ActiveMQ, Camel & Spark
 
P4+ONOS SRv6 tutorial.pptx
P4+ONOS SRv6 tutorial.pptxP4+ONOS SRv6 tutorial.pptx
P4+ONOS SRv6 tutorial.pptx
 
ORTC Library - Introduction
ORTC Library - IntroductionORTC Library - Introduction
ORTC Library - Introduction
 
Serial Data from Arduino to Raspberry Pi to MySQL using CoAP Protocol
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
 
An hour with WebRTC FIC UDC
An hour with WebRTC FIC UDCAn hour with WebRTC FIC UDC
An hour with WebRTC FIC UDC
 
From the internet of things to the web of things course
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
 
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...
Master-Master Replication and Scaling of an Application Between Each of the I...
 
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 ...
swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ...
 
End-to-end IoT solutions with Java and Eclipse IoT
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
 
Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024
 

Plus de Pôle Systematic Paris-Region

Plus de Pôle Systematic Paris-Region (20)

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...
OSIS19_IoT :Transparent remote connectivity to short-range IoT devices, by Na...
 
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 ...
OSIS19_Cloud : SAFC: Scheduling and Allocation Framework for Containers in a ...
 
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 ...
OSIS19_Cloud : Qu’apporte l’observabilité à la gestion de configuration? par ...
 
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, ...
OSIS19_Cloud : Performance and power management in virtualized data centers, ...
 
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 ...
OSIS19_Cloud : Des objets dans le cloud, et qui y restent -- L'expérience du ...
 
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...
OSIS19_Cloud : Attribution automatique de ressources pour micro-services, Alt...
 
OSIS19_IoT : State of the art in security for embedded systems and IoT, by Pi...
OSIS19_IoT : State of the art in security for embedded systems and IoT, by Pi...OSIS19_IoT : State of the art in security for embedded systems and IoT, by Pi...
OSIS19_IoT : State of the art in security for embedded systems and IoT, by Pi...
 
Osis19_IoT: Proof of Pointer Programs with Ownership in SPARK, by Yannick Moy
Osis19_IoT: Proof of Pointer Programs with Ownership in SPARK, by Yannick MoyOsis19_IoT: Proof of Pointer Programs with Ownership in SPARK, by Yannick Moy
Osis19_IoT: Proof of Pointer Programs with Ownership in SPARK, by Yannick Moy
 
Osis18_Cloud : Pas de commun sans communauté ?
Osis18_Cloud : Pas de commun sans communauté ?Osis18_Cloud : Pas de commun sans communauté ?
Osis18_Cloud : Pas de commun sans communauté ?
 
Osis18_Cloud : Projet Wolphin
Osis18_Cloud : Projet Wolphin Osis18_Cloud : Projet Wolphin
Osis18_Cloud : Projet Wolphin
 
Osis18_Cloud : Virtualisation efficace d’architectures NUMA
Osis18_Cloud : Virtualisation efficace d’architectures NUMAOsis18_Cloud : Virtualisation efficace d’architectures NUMA
Osis18_Cloud : Virtualisation efficace d’architectures NUMA
 
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur BittorrentOsis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
 
Osis18_Cloud : Software-heritage
Osis18_Cloud : Software-heritageOsis18_Cloud : Software-heritage
Osis18_Cloud : Software-heritage
 
OSIS18_IoT: L'approche machine virtuelle pour les microcontrôleurs, le projet...
OSIS18_IoT: L'approche machine virtuelle pour les microcontrôleurs, le projet...OSIS18_IoT: L'approche machine virtuelle pour les microcontrôleurs, le projet...
OSIS18_IoT: L'approche machine virtuelle pour les microcontrôleurs, le projet...
 
OSIS18_IoT: La securite des objets connectes a bas cout avec l'os et riot
OSIS18_IoT: La securite des objets connectes a bas cout avec l'os et riotOSIS18_IoT: La securite des objets connectes a bas cout avec l'os et riot
OSIS18_IoT: La securite des objets connectes a bas cout avec l'os et riot
 
OSIS18_IoT : Solution de mise au point pour les systemes embarques, par Julio...
OSIS18_IoT : Solution de mise au point pour les systemes embarques, par Julio...OSIS18_IoT : Solution de mise au point pour les systemes embarques, par Julio...
OSIS18_IoT : Solution de mise au point pour les systemes embarques, par Julio...
 
OSIS18_IoT : Securisation du reseau des objets connectes, par Nicolas LE SAUZ...
OSIS18_IoT : Securisation du reseau des objets connectes, par Nicolas LE SAUZ...OSIS18_IoT : Securisation du reseau des objets connectes, par Nicolas LE SAUZ...
OSIS18_IoT : Securisation du reseau des objets connectes, par Nicolas LE SAUZ...
 
OSIS18_IoT : Ada and SPARK - Defense in Depth for Safe Micro-controller Progr...
OSIS18_IoT : Ada and SPARK - Defense in Depth for Safe Micro-controller Progr...OSIS18_IoT : Ada and SPARK - Defense in Depth for Safe Micro-controller Progr...
OSIS18_IoT : Ada and SPARK - Defense in Depth for Safe Micro-controller Progr...
 
OSIS18_IoT : RTEMS pour l'IoT professionnel, par Pierre Ficheux (Smile ECS)
OSIS18_IoT : RTEMS pour l'IoT professionnel, par Pierre Ficheux (Smile ECS)OSIS18_IoT : RTEMS pour l'IoT professionnel, par Pierre Ficheux (Smile ECS)
OSIS18_IoT : RTEMS pour l'IoT professionnel, par Pierre Ficheux (Smile ECS)
 
PyParis 2017 / Un mooc python, by thierry parmentelat
PyParis 2017 / Un mooc python, by thierry parmentelatPyParis 2017 / Un mooc python, by thierry parmentelat
PyParis 2017 / Un mooc python, by thierry parmentelat
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

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