For a while, I wanted to explorer the possibility of integrating Raspberry PI with Azure IoT Hub and even though, this board does not have a security chip as AZ3166 board does, it still represents a viable option for integrating different sensors with Azure. Moreover, compared to Arduino, which relies on timeless C language, PI allows me to use multiple development options. I’ve experimented with both Node.js and Python to build the integration. In this example, you’ll see how easy it is to integrate PI with Azure IoT using Python.

To get started, I used the remote capabilities of VSCode to develop and debug Python code directly on the device. Check this article on how to connect and configure the remote-ssh extension.

Next, we need to connect Load Cell(HX711) to Raspberry PI. Please check this diagram for details:

Finally, I needed to configure Load Cell(HX711) and Azure IoT Libraries for Python on raspberry PI and provision Azure IoT Hub. Please check this article on how to provision Azure IoT Hub in VSCode.

pip install azure-iot-device

pip install HX711

Testing Solution: The following sample code will measure load cell data and will submit it to Azure IoT hub. Just update the connection string and tune reference units, to adjust the scale. Please check this sample script for more detail on how to calibrate the scale.