Hello ,
this tutorial connects a Raspberry Pi to the Azure IoT Hub.
Each azure IoT device has its own credentials.
It complains about the authorization. Are you sure you passed the connection string:
sudo node index.js '<YOUR AZURE IOT HUB DEVICE CONNECTION STRING>'
Please check this.
As an alternative, you can check this RPI simulation to get familiar with the code and connection string.
Regarding the Device-to-Cloud message, this is actually the right experience!
The device will send Cloud-to-Device messages.
Azure IoT Hub supports several ways to communicate to the device:
- Direct methods
- DeviceTwin desired properties
- Cloud messages
Direct methods only work when the device is connected at the same time as the direct method is called.
Both desired properties and the cloud messages are 'stored' on the IoT hub until the device connects to the IoT Hub and consumes the device twin changes or the cloud messages.
So, the cloud messages you already sent are probably still queued on the IoT Hub.
For all three ways of C2D communication, extra local logic must be added on the device.