We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Python & Internet of Things

00:00

Formal Metadata

Title
Python & Internet of Things
Title of Series
Part Number
138
Number of Parts
173
Author
License
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language
Production PlaceBilbao, Euskadi, Spain

Content Metadata

Subject Area
Genre
Abstract
Ravi Vagadia - Python & Internet of Things There is a lot buzz about the Internet of things and how it's going to be the next big thing in computing. Python can power "things" and is used extensively in network applications, however there isn't much information out there about where Python can be used to build end-to- end IoT products. Goals : To put into perspective the usefulness of Python in building IoT products. Spread awareness on possibilities of using Python on embedded hardware.
Keywords
InternetworkingMobile WebOffice suiteNeuroinformatikComputer animation
Spherical capSpacetimeSoftware developerSource codeInternet der DingeOffice suiteMobile WebProduct (business)Dependent and independent variablesWeb 2.0JSONComputer animation
Disk read-and-write headFood energyJSONComputer animation
2 (number)Inequality (mathematics)Order (biology)Covering spaceLevel (video gaming)MeasurementPressureDemo (music)Bit rateVideoconferencingRight angleElectronic program guide
GradientResultantComputer animation
Computer programmingPrototypeExterior algebraSoftware frameworkJSONComputer animation
PrototypeBuildingProduct (business)Shared memoryPrototypeUniverse (mathematics)Gateway (telecommunications)Client (computing)JSONComputer animation
Gateway (telecommunications)Universe (mathematics)Software developerGateway (telecommunications)SummierbarkeitGame controllerRepresentational state transferComputer animation
Representational state transferOrder (biology)NeuroinformatikMereologyServer (computing)TelecommunicationForm (programming)SummierbarkeitComputer animation
Computer architectureFront and back endsBitDebuggerMessage passingQueue (abstract data type)MereologyComputer animation
InferenceParticle systemHand fanOperator (mathematics)SmartphonePhysical systemGame theoryWordComputer animation
Library (computing)Cross-correlationView (database)Cross-platformWrapper (data mining)Similarity (geometry)Interface (computing)
Execution unitInterface (computing)InternetworkingMereologyTelecommunication
Gateway (telecommunications)Computer architectureForm (programming)QuadrilateralDuality (mathematics)
Gateway (telecommunications)AnalogyHoaxService (economics)Message passingSoftware developerServer (computing)Cartesian coordinate systemSoftwareDemo (music)Multiplication signProjective planeWeb 2.0Client (computing)Figurate numberTablet computerMereologyEstimatorComputer animation
Wireless LANPresentation of a groupMereologyWhiteboardOrder (biology)Connectivity (graph theory)MicrocontrollerComputer animation
MicrocontrollerWhiteboardCartesian coordinate systemWebsiteLogic gateCentralizer and normalizerPower (physics)Connected spaceNeuroinformatikQuicksortFood energyMessage passingGame controllerService (economics)Computer animation
NeuroinformatikTelecommunicationModule (mathematics)Service (economics)WhiteboardSource codeReading (process)Virtual machineParameter (computer programming)Computer animation
Wireless LANModule (mathematics)Computer animation
Group actionGroup actionNeuroinformatikConnected spaceMultiplication signEvent horizonService (economics)JSONComputer animation
Virtual machineEvent horizonMultiplication signIntegrated development environmentMultilaterationMIDIComputer animation
Group actionSlide ruleConnected spacePoint (geometry)TelecommunicationState of matterJSON
Endliche ModelltheorieSlide ruleMobile appServer (computing)Event horizonAbsolute valueLibrary (computing)InjektivitätJSON
Noise (electronics)Normal (geometry)WindowEndliche ModelltheorieFormal languageComputer configurationModule (mathematics)Right angleMultiplication signJSONComputer animation
Connected spaceLine (geometry)View (database)CodeComputer animation
OvalEvent horizonMultiplication signKeyboard shortcutInstance (computer science)Computer animation
Keyboard shortcutEvent horizonEvent horizonSlide ruleCartesian coordinate systemComputer animation
PrototypeStandard deviationComputing platformInterpreter (computing)Product (business)Cartesian coordinate systemBuildingPrototypeSoftware testingType theoryComputer animation
MicrocontrollerWhiteboardMicrocontrollerComputer configurationAnalogyWordLevel (video gaming)Projective planeComputer animation
WhiteboardCartesian coordinate systemData storage deviceComputer configurationLibrary (computing)Video gameFile systemInterface (computing)BefehlsprozessorOrder (biology)Schmelze <Betrieb>Online helpSerial communicationComputer hardwareLoginComputer fileMotion captureComputer animation
Order (biology)Projective planeWhiteboard
InternetworkingSoftware frameworkPhysical systemMechanism designQuicksortInteractive televisionJSONComputer animation
Endliche Modelltheorie1 (number)Serial portLibrary (computing)Web 2.0Computer animation
outputGame controllerEndliche ModelltheorieComputer animationJSON
Reading (process)Library (computing)Data structureFormal languageJSON
Compilation albumData structureProduct (business)Programming languageElectric generatorComputer fileRadiusJava appletCartesian coordinate systemJSON
Formal languageParsingMessage passingCASE <Informatik>Valuation (algebra)JSON
MultiplicationCommunications protocolImplementationJSONComputer animation
SoftwareOrder (biology)TelecommunicationEndliche ModelltheorieUniform boundedness principleCondition numberComputer animation
Set (mathematics)Condition numberHydraulic motorRight angleSoftware testingOctahedronConnected spaceComputer animation
Web 2.0Virtual machineCartesian coordinate systemCodeJSONComputer animation
Information managementVector spaceComputer animation
Game controllerComputer animation
Connectivity (graph theory)WhiteboardSoftware developerQuicksortInterface (computing)Library (computing)Right angleComputer animation
Library (computing)Software frameworkDistribution (mathematics)Normal (geometry)Software developerProcess (computing)Computer animation
Control flowBitMultiplication signScaling (geometry)Product (business)CASE <Informatik>Form (programming)Computer animation
Outline of industrial organizationOcean currentProjective planeProduct (business)Demo (music)CASE <Informatik>Computer animation
Traffic reportingOrder (biology)Cartesian coordinate systemComputer animation
Cartesian coordinate systemMultiplication signTwitterFrequencyUniverse (mathematics)Coma BerenicesMathematicsComputer animation
MathematicsVideo gameCASE <Informatik>Disk read-and-write headCartesian coordinate systemTheoryComputer animation
Cartesian coordinate systemInformationSmartphoneCASE <Informatik>outputForm (programming)Computer animation
Connectivity (graph theory)Computer animation
AlgorithmService (economics)SynchronizationCloud computingWeb 2.0PrototypeRight angleForm (programming)Computer programmingComputer animation
Order (biology)Connected spaceIterationHypermediaComputer animation
Software frameworkFirmwareWhiteboardComputer animation
Traffic reportingLibrary (computing)FirmwareSoftware frameworkMedical imagingBackupService (economics)Computer animation
AreaMedical imagingCASE <Informatik>CodeWhiteboardPoint cloudComputer animation
InformationMedical imagingCartesian coordinate systemGoodness of fitHeat transferMathematicsProduct (business)CASE <Informatik>Game theoryMereologyComputer animation
Communications protocolCASE <Informatik>Software bugMedical imagingStandard deviationSoftware frameworkView (database)Data storage deviceService (economics)Computer animation
Service (economics)CASE <Informatik>Field (computer science)INTEGRALComputer animation
QuicksortRight angleComputer animation
Computer animation
Standard deviationWhiteboardLatent heatComputer animation
WhiteboardProduct (business)Computer animation
Computer hardwareQuicksortMereologyInterface (computing)Computer animation
Computer animation
Transcript: English(auto-generated)
to you Ravi. Thank you. I'm Audible, right? How many of you have used Arduino or Raspberry Pi? Yeah. So, the talk covers about Raspberry Pi and Arduino. So, I've come all the way
from India. So, this is my first talk. I work with a company called Azoi. Azoi, at Azoi we basically focus on health and mobile computing. We have offices in US and India. I take
care of software development responsibilities at Azoi. So, I started my career with web and mobile technologies and from like last two years I've been working in the space of Internet of Things. So, at Azoi we have built this product called Keto. It's a smart which monitors
your health. So, I'll just give a quick overview of Keto. So, it has, it works on Bluetooth low energy. It has its own battery. Battery lasts for like two months. There are some sensors on
back of the cover where you place your fingers and like hold it for a few seconds and it will measure your ECG, heart rate, respiration, blood oxygen level and blood pressure. I'll demo.
It's a video. I couldn't get the device right now. So, basically those are the electrodes for ECG. The sensors are for your temperature and SPO2 readings. If you are
interested, it gets all the results with like medical grade accuracy. So, yeah. So, in this talk I'll be focusing more on the challenges that we face when we, you know,
when we are in the prototype and those and what are the alternatives that we can use to overcome those challenges and I'll talk about some frameworks which we use and which are like
really good frameworks for where we want to, you know, have devices communicate with each other. So, before I start, I want to share some of my experiences with building few product prototypes. So, the first experience is from when I was in my university and we had to build
a gateway in Python. So, at university we decided the requirements. So, we were our own clients
and an API which allows developers to send and receive SMS because SMS gateways back in 2008 were very expensive. So, we thought of building REST APIs which, where developers can send and receive SMS using a cell phone connected with server. So, in order to do that,
we needed a phone and some communication channel between the phone and the server and this was a part of our distributed computing curriculum. So, we decided to use oriented architecture.
We also built a front end where you can see the messages that were in queue and the status of incoming messages. So, basic part was that we used a Symbian phone. How many of you are
Symbian fans over here? So, yeah. Back in 2008, Symbian was, I guess, the best operating system in like smartphone world before like iPhone came. So, yeah. We decided to use
Symbian and as Symbian has this Python support, so we used a library called Lightbue. Lightbue is a wrapper which is cross platform across Linux, Mac and Symbian. So, we used
same interface both on Linux and as well as on Symbian and to communicate it, to make communication channel between both the devices. So, initially we thought of doing it using AT commands and stuff like that, but then we realized that use Lightbue, it would be
much easier using Python. Yeah, and for the UI, so basically the architecture, yeah, we used this phone. It wasn't that powerful like no dual core, quad core, but pretty enough to SQL, PHP and basic Python. So, the basic architecture was, yeah. So, we
had application service running on Symbian phone which would connect to the server and where we would store the incoming messages and the request for sending outgoing messages.
And so we, using web services, basically developers would send a request and that request would be then transferred to the phone and from there to the network, our cellular network.
So using this, we also built some of the applications which would utilize this APIs, basic chat clients like GTOC. Back in 2008, we could chat on GTOC using SMS via the services.
So that was part of demo. So, yeah, that was, so this experience like figured out that using Python, so this was the first time when I was like using Python on a project and I figured that using it was, like it was quick to build. So second experience
is building a wireless presenter using Arduino. So this was part of 24 hour hackathon. So we basically collected a few devices and boards. So in order to build a wireless
presenter in 24 hours, we first had to finalize the components. So we needed a microcontroller board which would run the application, a switch to navigate through the slides, some sort of power source because it was a handheld device, connectivity with the computer
so that it could send the control messages and a control service running on the computer. So we used Arduino because it's pretty easy to start with and we use tactile switch,
connected it with Arduino, we connected battery source. We chose to use Wi-Fi for communication because of this module which I will talk about later and we had a simple service running on the machine, on the computer. So there is an interesting board called Cactus Micro.
It's basically Arduino plus ESP, the Wi-Fi module and gives you a very neat and tiny package of Arduino and Wi-Fi chip. So we decided to use that and so the size of Cactus Micro
is this tiny. So these were the actions we wanted to perform. So all the basic actions like navigating through the slides, making connection with the computer like pairing
for the first time and a service which would accept those signals and fire events on the host machine. So we did it using Arduino IDE but it was little time consuming so we
thought how can we optimize it further or maybe other techniques to do it quickly. So these were the actions that we decided like next slide, one click, previous slide double click on the button and for connection we set it up as a Wi-Fi access point and
connected so communication happens over HTTP. So it's a basic GET request from Arduino would switch it to the next slide and another request would switch it to previous slide. So for firing events we used a model based app server plus PY, there is an interesting
library called PY user which helps you inject event in OS no matter which OS you use, basically it supports all three of the major OS's, Windows, Linux and Mac. So then we realized
that this module itself is more powerful than Arduino. So the way it works is that and Arduino talks via serial, it happens to be that this module supports MicroPython
so this was the time to try MicroPython because we don't have as many options when it comes to the Python world as we have in other languages. So yeah, using MicroPython
the connection and setup was as simple as this. So all like hundreds of lines of Arduino code and we replaced it with this. So it's pretty simple, you just connect to any SSID with WPA key, data socket, you register your callable, connect to the server and
so it was pretty neat and we used button events from Arduino. This is the code from the hotend which is equally simple because we basically get an instance of PY keyboard
and then we just use key event to switch the slide on the get request. So yeah, this is when again we realized that using Python can like speed up our prototyping process
and because it makes it easy to make demo-able applications. Yeah, so we extensively use Arduino, Raspberry Pi, BeagleBone, so we basically build on platform and use standard
Python interpreter build applications and quickly test and come up with prototype products. So if we look at the microcontroller options for Python, there aren't that many boards available in market but there are few of them and more are coming. One is PY board,
PY board is again a micro Python project. Another one is a kick starter, is on kick starter, it's Wipy. It's quite powerful, PY board itself has like accelerometer,
168 megahertz CPU, GPIOs and some LEDs and a switch. So building simple applications using this board is very straightforward. It gives us the Pythonic interface to interact with all the hardware which we connect with this device. It also has a micro SD slot,
it lets you access file system, so if you want to build something which let's say captures some logs and stores it locally and syncs periodically in order to save battery or something then we can do it. But the problem is this one doesn't have Wi-Fi
in it, we can do it using the serial interface. Another option is Wi-Fi, this one is interesting, it comes with Wi-Fi and micro SD slot. Problem is it's pre-order, they'll start
shipping it in September I think. So this one is a kick starter project. So if we have more of such boards, I think it would make it easy for hobbyist makers to quickly develop their ideas. So on the frameworks and we have protobups, like any internet
of things system would need some sort of mechanism to interact with each other. So there are a few of them are like MQTT and protobup, mostly it's used together like protobups are used for serialization and transferred via MQTT. There is this interesting
library called Web IOPI, this library lets you install this library on your Raspberry Pi, it lets you access and see, monitor all the IOPI controllers, all the inputs.
So I think how many of you have used protobups? Yeah, quite a lot. So this is like if you are building something where multiple devices are communicating, I think this is something
that it's a must have library, because it takes a lot of work from our end, because it's basically a language neutral library, wherein you just declare your data structure and using protobup compilers it will generate files for various programming languages.
Let's say you are building an application using Java and another application is using Python, third one is using C++, then the exchange happens using binary and is compatible with all the languages, because the parsers are available for all the languages. It also
provides validations, so in case you receive a protobup message and want to check if it's valid, you can easily do it without writing any code. It also provides backward compatibility, so let's say if two of your devices, multiple devices are communicating and you want to
upgrade the protocol containing previous devices, you can handle it in the new protocol, new implementation. So MQTT is again, it's like HTTP, mostly binary, so people use
it with like protobuf and MQTT in order to make a communication network between two devices. It also supports pubsub model. This is a very good documentation, including protobuf.
protobuf also has the best documentation. This one is very simple, if you want to connect some LEDs or motors with your Pi and want to see if it's working or not, if you want to quickly test if your connections are proper or not, you can install biopie and
then you can access the web UI from another machine and see if things are connected properly or not. Basically you can control GPIOs using web-based UI. It also provides rest interface, so for basic application you may not even need to write any code on the embedded end.
So yeah, I think that's it. So before closing, I would like to know if there are any questions for me. Thank you for that talk. It was very insightful to get started with something. I was wondering,
obviously when I would start with experiments, connecting an Arduino controller and so on,
how do you do the debugging around these components? Because I'm sure that the first thing that I'm going to be plugging together will not work. So on Raspberry Pi it's still very simple, but on the other boards it gets difficult because most of the development boards have some sort of proprietary interface and libraries
or framework tools, which some of them are quite expensive. So without that you cannot debug. But yeah, on Raspberry Pi it's straightforward. Because it provides you a complete distribution, you can use all the tools that we use in normal development process.
Any more questions? We have a little bit more time. There's I think a coffee break after this session. Maybe a Symbian question. Okay, just kidding. Down there, okay.
So you showed us the case on the phone that could monitor stuff. Is it kind of production ready and what do you intend to do with this project? So yeah, it's production ready. We have started shipping in UK. I can show you the demo offline.
So I mean, what's the typical use cases out there? What users can, so are they expected to hold the phone or get their health report while talking
and holding the phone by hand? So what do you plan with it? So the purpose is to maintain a healthy lifestyle. So in order to maintain a healthy lifestyle, you will have to keep monitoring your vitals and see if everything is okay. So the application
is designed in such a way that it collects your data. Like if you take reading twice a day, so it will basically, using it over a period of time you'll start seeing some trends. Start some activities in your, if there is any change in your lifestyle, you'll see how
it's impacting your health. So that's one of the use cases. And maybe a question from my side and this application is also done with the Raspberry or embedded Python or how do you reading out the information? So yeah, that application is available for both Android
and iOS. Basically works with all the smartphones. The case is such that you stick it on your back of your phone. It has nothing to do with phone as such. It basically is an independent component which talks to your phone and which you, we just visualized there. Sorry?
Where is Python? Yeah, Python is used extensively in building the product, not on the embedded side
because it's used to test our algorithm. We have a backend service where you can sync all the data. So using this cloud platform is powered by Django. So we use all the web stack is on Python and we for, as I said, for prototype Python extensively because we, so in
order to connect the sensors and easily try and see if it works or not. So the iteration that we in Python is much much quicker than doing it the traditional way. Okay, there's another question.
Hi, thanks for talking. I'd like to ask you how do you guys handle firmware upgrades? Sorry?
firmware upgrades. How do you guys, like if you're working with the Pi board or the wi-pi or other boards, can you do wi-fi firmware upgrades or you are forced to do, I don't know, over the over the wire? It's generally done over the air. So basically we maintain two
separate images. So once you flash these images you switch to the backup image and you erase the other area, you upgrade it and then you again switch back to the newer image. So that's how we do it. Okay, in case you want to deploy or kind of upgrade your own code
running on the board, how do you guys? So it's done using, so on the cloud and will basically a new image which is delivered to the application. Application is on the downloads the image and then it transfers to the product the Keto case. You don't never change
the Keto case itself? I mean if you want to upgrade the the protocol, if you happen to find a bug in the case and you want to upgrade the case that is receiving and handling the data but you know the case itself? The case itself, so you are talking about the embedded side of it
right? Yeah, so we we can update the image using a standard bluetooth framework. So we have built a BLE service via which we can we transfer some over to the case where it stores it in us as allocated a pre-allocated area and once it receives all the data it will verify
whether the data received is basically a checksum integrity check and then once it ensures that the data received is correct then it will basically reboot to the new working that's how we deliver upgrades. Okay, so that's sort of custom made right?
No, that's something that you get. Yeah, yeah, that's because there is no way for doing this. Thank you very much. Yeah, thank you. Okay, yeah, yeah, I think Wi-Fi looks very promising. You can always try
micro-python on like standard boards but Wi-Fi is like built for this specific purpose so I think
once it's out in market I feel that it will definitely help a lot of people get started with building products you know if you want to build something like like then you can use one of these boards you can connect and you because I feel pythonic ways where you know it gets very very simple
to communicate with hardware so like you can connect all sort of hardware with Wi-Fi and use a micro-python interface to operate them. So I just wanted to recommend
you some sessions on Thursday, I think.