- Follow the general prerequisites
- Install Python
- Install Pip
The following variables will need to be expanded in the sample:
Variable | Description | Example |
---|---|---|
iothub_name | The name of the created IoT Hub (NOT FQDN/HostName) | iothub |
device_id | The name of the device created in the IoT Hub | mosquitto_pub |
sas_token | The SAS token generated for the device | SharedAccessSignature sr=*.azure-devices.net%2Fdevices%2F*&sig=* |
-
Open main.py and edit the following fields with the correct IoT Hub and device information
- IOT_HUB_NAME
- IOT_HUB_DEVICE_ID
- IOT_HUB_SAS_TOKEN
-
Install Paho MQTT
pip install paho-mqtt
-
Change into the
python
directory in the cloned repository:cd python
-
Run the script
python main.py
-
Observe the telemetry being sent
sending message[0]: Accio connect: 0 publish: 1 sending message[1]: Aguamenti publish: 2 sending message[2]: Alarte Ascendare publish: 3 sending message[3]: Expecto Patronum publish: 4 sending message[4]: Homenum Revelio publish: 5