Help with a data transfer between 2 controllers connected via Azure.

Stefan Kraus 0 Reputation points
2023-10-20T08:36:52.1333333+00:00

Hello Community,

This is my first time working with Azure and I'm getting into the IoT topic.

I'm doing a test setup for a customer project where two PLC controllers (Codesys) need to exchange few bits of data.

I get the connection setup of the 2 controllers working, sending data works, though I can't see where the messages end up or where I can view them in the hub.

However, the overview at devices shows me that the messages arrive in the hub.

Through the IoT hub itself, I can also send messages through the device selection in the hub and I receive that message on the PLC and can evaluate it.

However, I don't know how to get the sent message from the 1st PLC to the hub, directly to the second PLC.

My guess lies with the message routing, however, much is still unclear on this.

The test project is first to check the possibility and then at the customer to a paid Azure subscription, for the purpose of message limit to be extended.

Briefly summarized:

  1. IoT Hub in Azure is created, free subscription is active.
  2. both devices are created in the hub
  3. Codesys software is created to the point that both controllers can connect. Both devices can send messages to the hub and the graph in the hub shows the reception.
  4. both devices can also receive messages, which can also be tested via the hub. When the device is selected in the hub and the item message to device is used.

I hope you guys can help me out here and maybe give me some tips on what doc would be most helpful here. Unfortunately Azure is so vast and experience so limited that the docs I've looked through so far haven't really pointed me in the right direction.

Thanks already in advance

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2023-10-20T08:36:52.1366667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    It sounds like you are trying to send data directly from one PLC controller to another through Azure IoT Hub. One way to achieve this is through message routing. You can create a custom endpoint for the second PLC controller and route messages that meet certain criteria to that endpoint.

    To set up message routing, you can use the az iot hub routing-endpoint create command to create a custom endpoint that points to the storage container you made in the previous section. Then, use the az iot hub route create command to create a route that passes any message where level=storage to the storage container endpoint.

    For more information on how to set up message routing in Azure IoT Hub, you can refer to the following tutorial:

    Tutorial: Send device data to Azure Storage using IoT Hub message routing


    References:

    0 comments No comments

  2. Sander van de Velde | MVP 36,971 Reputation points MVP Volunteer Moderator
    2023-10-20T11:16:48.4133333+00:00

    Hello @Stefan Kraus,

    Welcome to this moderated Azure community forum.

    You are very busy regarding Azure IoT already. Great!

    Regarding the incoming IoT Hub messages sent by devices, these are stored for a limited time on the IoT Hub to be forwarded over either the 'event-hub-compatible-endpoint' or any of the routes or both. Other services like Azure Data Explorer, Azure Function, CosmosDB, blob storage, etc. can receive the messages.

    The IoT Hub does not expose the messages directly (for security this is a good decision). You can view the individual messages by consuming them with any of the services or using the VS Code IoT Hub Extension or the Azure IoT Explorer.

    The Azure IoT hub does not support device-to-device communication out of the box.

    You need to build some custom logic in the cloud that is receiving logic from one device, is making a decision, and sends a command (direct method or device twin desired property change) to the other device.

    If you rely heavily on device-to-device communication, check out the new EventGrid support for MQTT (in public preview at this moment).

    Here, using MQTT, devices can exchange messages directly where spoofing can be prevented.

    Check out this blog post for more details.

    Finally, this communication is done between devices via cloud communication.

    This makes it vulnerable to network outages.

    Why not use a local Edge solution, managed from the cloud? Check out the Azure IoT Edge documentation.

    You can use the internal routing for your PLCs to connect them, or you can integrate a local MQTT broker on the edge, managed in the cloud.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    (this message is written word for word by a real person)


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.