Azure IoT DeviceClient SDK Python demonstration, the basics

In the past, I wrote a blog about the Azure IoT device SDK. This example was written in C#.

Last year, I noticed an increased number of questions coming from Python users trying to connect devices to the cloud. Luckily, the driving force behind this is the growing community of ML developers using Python. They are increasingly involved in IoT projects.

That’s why I scrambled some samples together into one demonstration showing the capabilities of Azure IoT Hub-connected devices.

We will see how device-to-cloud messages are sent from the device to your IoT Hub. And we will see several ways of cloud-to-device communication so we can enforce actions on the device.

Update: recently, I added a second Python script with an individual Device Provisioning Service Enrollment based on a symmetric key. The example is exactly the same, you only need to provide other variables for this provisioning.

This introduction will get you started within a moment.

Doorgaan met het lezen van “Azure IoT DeviceClient SDK Python demonstration, the basics”

Raspberry Pi NoIR camera pictures by daylight

The Raspberry Pi is considered a great IoT device but it is was designed to let children find out how computers work.

And what is a better way to let them learn to develop programs if they can interact with electrical component for a fart detector, a grandpa scarer or a parent detector?

That last example uses the dedicated Raspberry Pi Camera (sold separately) but I like the Raspberry Pi concept so I bought one.

There are actually two camera’s. There is a regular one and a No Infra Red Filter one.

I bought the NoIR one so it could be used as a surveillance camera or just for fun, filming at night (My oldest son want to put the camera on a Nerf gun so he has a kill cam 😉 )

To get the camera running is not that difficult just follow this and that.

The pictures and movies are pretty good but the colours are terrible of course:

image image_without filter

Yes, I know, it’s for nigh vision.

And the camera can also record video for several seconds/minutes in H264 format. Although this an excellent quality for the price of this device, the format is not that handy. H264 has to be converted to another format before you can show it to your friends.

And this is possible on the Raspberry Pi itself.

So I changed the emaple code slightly to get MP4 instead of H264:

import picamera
from time import sleep
from subprocess import call

camera = picamera.PiCamera()




call(['MP4Box -add video2.h264 video2.mp4'], shell=True)

call(['rm video2.h264'], shell=True)

After the recording I convert the H264 into MP4 and delete the old video.

And now we have nice video from the Raspberry Pi in MP4 (which can be played within the browser of the Pi) with that very seventies polaroid effect.

An example is shown at :