pdf-icon

Azure

Connect to Azure IoT cloud service platform.

Micropython API IoT_Hub


# Initialize connection
azure = IoT_Hub(connection_string='')

# Certificate access method
azure = IoT_Hub(device_id='', host_name='', ssl=True, cert_file_path='', private_key_path='')

# Enable connection
azure.start()

# Subscribe to direct_method messages
azure.subscribe_direct_method(topic, azure_direct_fun)

# Callback for listening to cloud-side data
azure.subscribe_C2D_message(azure_C2D_cb)

# Publish data to the cloud
azure.publish_D2C_message()

# Upload data to the cloud device instance (Device Twin)
azure.update_twin_reported_properties(key1='value',key2='value')

# Callback response for passing data to the cloud device instance (Device Twin)
azure.subscribe_twin_desired_response(azure_desired_cb)

# Retrieve the properties owned by the cloud device instance (Device Twin)
azure.retrieve_twin_properties()

Micropython API IoT_Central


# Initialize connection
azure = IoT_Central(scope_id='', device_id='', device_key='')

# Enable connection
azure.start()

# Subscribe to direct_method messages
azure.subscribe_direct_method(topic, azure_direct_fun)

# Callback for listening to cloud-side data
azure.subscribe_C2D_message(azure_C2D_cb)

# Publish data to the cloud
azure.publish_D2C_message()

# Upload data to the cloud device instance (Device Twin)
azure.update_twin_reported_properties(key1='value',key2='value')

# Callback response for passing data to the cloud device instance (Device Twin)
azure.subscribe_twin_desired_response(azure_desired_cb)

# Retrieve the properties owned by the cloud device instance (Device Twin)
azure.retrieve_twin_properties()
On This Page