Transmit Sensor Data using Gateway Device
Last updated
Last updated
In this quickstart, you send telemetry from a physical Raspberry Pi device through Azure IoT Hub to a back-end application for processing. IoT Hub is an Azure service that enables you to ingest high volumes of telemetry from your IoT devices into the cloud for storage or processing. This quickstart uses a pre-written Python application to send the telemetry. Before you run this application, you create an IoT hub and register a device with the hub.
An Azure account with an active subscription. .
. For other versions of Python supported, see .
.
Port 8883 open in your firewall. The device sample in this quickstart uses MQTT protocol, which communicates over port 8883. This port may be blocked in some corporate and educational network environments. For more information and ways to work around this issue, see .
Install azure.iot.device using the following command in the terminal. Click Terminal > New Terminal in VS Code and run the following command.
Use of python3
-m option with pip
command ensures that the correct version of pip
is used for package installation. In the above command pip
version corresponding to the default python3 will be used.
Download the in Raspberry Pi.
Right click the downloaded archive (.zip) and select Extract here
Rename the extracted folder azure-iot-samples-python-master to azure-iot-samples-python and move it to the Documents folder in Raspberry Pi.
Open azure-iot-samples-python folder in VS Code and navigate to azure-iot-samples-python/iot-hub/Quickstarts/simulated-device/SimulatedDeviceSync.py.
Replace the value of variable, CONNECTION_STRING
, with the primary connection string copied from process in SimulatedDeviceSync.py
.
Run
You will see the following output in the terminal.
You can monitor . A sample output is shown below.