azure-iot-hubazure-iot-sdk

How do I use Azure IoT SDK (C#) to develop code to send data from my robotic arm to my IoT hub?


The objective is to develop code based on the Azure IoT SDK to send data on real-time basis from my robotic arm to the IoT hub. I found the tutorials quite helpful but the codebase (on github) is quite tedious to understand as there are many subdirectories and examples provided.

What I've tried:

I followed the code-sample for temperature controller and was able to understand how to send telemetry data, but I am not sure how to develop the code for my robot.

What I need:

I need some guidance about which code samples/templates to follow to develop code to achieve my objective. I'll be thankful for any guidance.


Solution

  • Welcome to the community! To be able to integrate or consume the data from your robotic arm, you would need an SKD or a public API provided by Promorobotics for your Franka device. Looking at the System Integration support document, the device does support integration with programming. However, there is no public documentation provided on their website sharing more information on this. You can reach to them through their Contact page and request this information.

    Update

    Robotic arm data can be read through the implementation of the following GitHub sample code

    Once you can consume your robotic telemetry data programmatically, you can create a simple device client using the Microsoft.Azure.Devices.Client class and send the data programatically to Azure IoT Hub. Below is a simplified sample program for sending data to Azure IoT Hub.

    using Microsoft.Azure.Devices.Client;
    using System;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace IoTHubDevice
    {
        class Program
        {
            private static DeviceClient deviceClient;
            private readonly static string connectionString = "Your IoT Hub device connection string";
    
            static async Task Main(string[] args)
            {
                Console.WriteLine("IoT Hub Quickstarts #1 - Simulated device\n");
                deviceClient = DeviceClient.CreateFromConnectionString(connectionString, TransportType.Mqtt);
    
                while (true)
                {
                    string messageString = "{\"temperature\":" + new Random().Next(20, 30) + ",\"humidity\":" + new Random().Next(60, 80) + "}";
                    var message = new Message(Encoding.ASCII.GetBytes(messageString));
                    message.ContentEncoding = "utf-8";
                    message.ContentType = "application/json";
                    await deviceClient.SendEventAsync(message);
                    await Task.Delay(10000);
                }
            }
        }
    }
    

    You can modify the messageString to include your telemetry data.