Featured Samples
-
Device-to-Cloud Telemetry and Cloud-to-Device Commands
Learn how to send telemetry data from your IoT devices to IoT Hub and send commands back to control them.
View Sample -
Device Provisioning Service (DPS) Integration
Understand how to securely and efficiently onboard devices to IoT Hub using the Device Provisioning Service.
View Sample -
IoT Hub Routing and Endpoint Management
Configure custom routing rules to direct IoT Hub messages to different Azure services like Azure Storage, Service Bus, and Event Hubs.
View Sample -
Device Twins and Direct Methods
Utilize device twins for state synchronization and implement direct methods for synchronous communication with devices.
View Sample
Common Code Snippets
// Example: Sending a device-to-cloud message
// Using Azure IoT SDK for .NET
// var deviceClient = DeviceClient.CreateFromConnectionString("YOUR_CONNECTION_STRING");
// var message = new Message(Encoding.ASCII.GetBytes("Hello, IoT Hub!"));
// await deviceClient.SendEventAsync(message);
// Console.WriteLine("Message sent.");
// Example: Receiving a cloud-to-device command
// Using Azure IoT SDK for Python
// while True:
// message = await device_client.receive_message()
// print("Received message: {}".format(message))
// await device_client.complete_message(message)