platform | device | language |
---|---|---|
Debian |
midori box |
python |
About this document
This document describes how to connect Midori Box device running Debian with Azure IoT SDK. This multi-step process includes:
- Configuring Azure IoT Hub
- Registering your IoT device
- Build and deploy Azure IoT SDK on device
You should have the following items ready before beginning the process:
- Prepare your development environment
- Setup your IoT hub
- Provision your device and get its credentials
- Midori Box device.
- Insert the AC adapter into an outlet.
- Setup your Midori Box according to the manual
- Connect to the device by SSH or USB serial
- Log in with username pi, and password (Please contact our support, if you want to know password).
-
Open a PuTTY session and connect to the device.
-
Install the prerequisite packages for the Microsoft Azure IoT Device SDK for Python by issuing the following commands from the command line on your board:
sudo apt-get update sudo apt-get install -y curl libcurl4-openssl-dev build-essential cmake git python2.7-dev libboost-python-devi uuid-dev
-
Change the configuration in the file /etc/dphys-swapfile, in order to change swapfile size.
-
default:
CONF_SWAPSIZE=100
-
change this to:
CONF_SWAPSIZE=1024
-
Restart the service
sudo /etc/init.d/dphys-swapfile stop sudo /etc/init.d/dphys-swapfile start
-
-
Download the Microsoft Azure IoT Device SDK to the board by issuing the following command on the board::
git clone --recursive https://github.com/Azure/azure-iot-sdks.git
-
Run following commands to build the SDK:
cd python/build_all/linux sudo ./build.sh
-
After a successful build, the
iothub_client.so
Python extension module is copied to the python/device/samples folder. -
Navigate to samples folder by executing following command:
cd azure-iot-sdks/python/device/samples/
-
Edit the following file using any text editor of your choice:
For AMQP protocol:
nano iothub_client_sample_amqp.py
For HTTP protocol:
nano iothub_client_sample_http.py
For MQTT protocol:
nano iothub_client_sample_mqtt.py
-
Find the following place holder for device connection string:
connectionString = "[device connection string]"
-
Replace the above placeholder with device connection string you obtained in Step 1 and save the changes.
-
Run the sample application using the following command:
For AMQP protocol:
python iothub_client_sample_amqp.py
For HTTP protocol:
python iothub_client_sample_http.py
For MQTT protocol:
python iothub_client_sample_mqtt.py
-
See Manage IoT Hub to learn how to observe the messages IoT Hub receives from the application.
- See Manage IoT Hub to learn how to send cloud-to-device messages to the application.