Search code examples
node.jsazureiotazure-iot-hubopen-telemetry

Which is an appropriate NodeJS code to send telemetry from device to IoT hub?


With the help of Azure IoT SDK node, I've been assigned to send telemetry data from device to IoT hub using NodeJS. How do I write or how do I find an appropriate sample for d2c messages. I'm quite confused which sample code to be used from this particular SDK for device to IoT hub telemetry. https://github.com/Azure/azure-iot-sdk-node "Suppose my device has a waste level sensor and sending waste fill level to IoT hub so how do I get an appropriate sample from this SDK to send data to Hub"

Thank you.


Solution

  • the easiest Node SDK sample I could find was this one". It's in the repository that you linked to.

    If you want more information, and a step-by-step tutorial, I can recommend this tutorial in the docs. It uses a different sample in the same repository.

    For all of these samples: they send a certain payload. You can change the payload to whatever you need it to be for your waste level sensor!