Hello @Senuda Jayalath ,
You may be interested in looking at this sample app.
Download the sample Node.js project from https://github.com/Azure-Samples/azure-iot-samples-node/archive/master.zip and extract the ZIP archive.
Make sure that port 8883 is open in your firewall. The device sample in this tutorial uses MQTT protocol, which communicates over port 8883. This port may be blocked in some corporate and educational network environments.
Please have a look at this section Process reported properties
A back-end application accesses the current reported property values for a device through the device twin. The following snippet shows you how the back-end application reads the reported property values for the simulated device:
// Display the reported properties from the device
function printReportedProperties(twin) {
console.log("Last received patch: " + twin.properties.reported.lastPatchReceivedId);
console.log("Firmware version: " + twin.properties.reported.firmwareVersion);
console.log("Fan status: " + twin.properties.reported.fanOn);
console.log("Min temperature set: " + twin.properties.reported.minTemperature);
console.log("Max temperature set: " + twin.properties.reported.maxTemperature);
}
Please let us know if you need further help in this matter.
Can you please provide an answer to the above question
Hello @Senuda Jayalath Sorry , I missed the notifications on this thread. Let me check on your follow-up question.
Hello @Senuda Jayalath I may suggest you go through the below documentation which talks about various scenarios with examples in Javascript.
IoT Plug and Play service developer guide
You can configure IoT Hub to generate device twin change notifications to route to a supported endpoint. See IoT Hub message routing to different endpoints Non-telemetry events.
You may also refer to Get started with device twins (Node.js)
Sign in to comment