in Internet of Things, IoT Hub, Microsoft Azure

This post describes how to communicate to Azure IoT Hub from Raspbian Jessie Python 2.7 on a Raspberry pi 3.

At Sogeti we are working on a great project, called miniature smart living room. Microsoft Azure is one of the cloud platforms we integrated in the solution. In this post I’ll describe how we enabled the bidirectional communication between a Raspberry pi 3 and the Azure IoT Hub. Please let me know if you are missing steps, then I can update the post.

  1. Write raspbian Jessie on sd card https://www.raspberrypi.org/documentation/installation/installing-images/README.md
  2. Connect your raspberry to a screen and move on with step 3. Or work headless and move on to step 2.1.
  • 2.1 Share your internet connection
  • 2.2 Connect your raspberry with your PC with a UTP cable
  • 2.3 Find your raspberry IP with arp -a in cmd
  • 2.4 Connect to you raspberry with ssh, default credentials u:pi p:raspberry (I use WinSCP and Putty)
  1. Update stuff sudo apt-get update
  2. Upgrade stuff sudo apt-get upgrade
  3. Configure wifi (or keep using the UTP cable and move on to step 6), navigate to network config sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
  4. Enter settings at bottom of file, after connected to wifi you can find the ip address on the router network={ ssid=”ssid” psk=”password” }

 

Followed this instruction: https://github.com/Azure/azure-iot-sdks/blob/master/c/doc/devbox_setup.md

  1. Install cmake sudo apt-get install cmake
  2. Clone repo git clone –recursive https://github.com/Azure/azure-iot-sdks.git
  3. Run script sudo ./setup.sh in c/build_all/linux
  4. Run script sudo ./build.sh in c/build_all/linux

ERROR: first time error missing CMakeLists.txt in a subdirectory.

Solution: Removed azure-iot-sdks directory, cloned again and run setup and build with sudo. Worked. So maybe it was because of the sudo, maybe the first clone was not completed (submodules stuff).

 

Followed this instruction: https://github.com/Azure/azure-iot-sdks/blob/master/doc/get_started/python-devbox-setup.md

  1. Run script sudo ./setup.sh in python/build_all/linux
  2. Run script sudo ./build.sh in python/build_all/linux
  3. Find iothub_client in python/device/samples

ERROR: after 100% costs a lot of time, ends with some makefile recipe error.

Solution: https://www.bitpi.co/2015/02/11/how-to-change-raspberry-pis-swapfile-size-on-rasbian/

 

Followed this instruction: https://github.com/Azure/azure-iot-sdks/blob/master/doc/get_started/python-run-sample.md

  1. Install nodejs npm sudo apt-get install nodejs npm
  2. Update stuff sudo apt-get update
  3. Upgrade stuff sudo apt-get upgrade
  4. Update npm sudo npm install -g npm
  5. Install iothub-explorer sudo npm install -g iothub-explorer
  6. Register device iothub-explorer “<iothub-connection-string>” create <device-name> –connection-string
  7. Open python/device/samples/iothub_client_sample_amqp.py nano iothub_client_sample_amqp.py
  8. Replace [device connection string] with the connection string for your device
  9. Run the script python iothub_client_sample_amqp.py

Write a Comment

Comment

Webmentions

  • Azure IoT Hub from Raspberry Pi 3

    […] Originally published on http://iottopic.com […]