Search code examples
azureamazon-web-servicescloudsendiot

How do I send data from Data Loggers to Azure IoT Hub or AWS IoT?


I want to send my data to either MS Azure or AWS IoT platform through my Data Logger. How do I do it?


Solution

  • Azure IoT Hub exposes device endpoints:

    Device endpoints

    For each device provisioned in the device identity registry, IoT Hub exposes a set of endpoints that a device can use to send and receive messages:

    • Send device-to-cloud messages. Use this endpoint to send device-to-cloud messages.
    • Receive cloud-to-device messages. A device uses this endpoint to receive targeted cloud-to-device messages.

    [...]

    These endpoints are exposed using MQTT v3.1.1, HTTP 1.1, and AMQP 1.0 protocols. Note that AMQP is also available over WebSockets on port 443.

    The simplest way would be a REST call:
    https://msdn.microsoft.com/en-us/library/azure/mt590784.aspx

    POST https://{IoTHubName}.azure-devices.net/devices/{deviceId}/messages/events?api-version={api-version}

    The body can be any octet-stream. Note that the size of the whole message (body plus properties) has to be less than 256 Kb.

    e.g.

    $ curl -X POST https://heresthething.azure-devices.net/devices/aNewArduino/messages/events?api-version=2016-02-03 \
           -H "Authorization: SharedAccessSignature sr=HeresTheThing.azure-devices.net&sig=t8Pf2lXXXVDlMY%3d&se=1489585285&skn=device" \
           -H "Transfer-Encoding: Chunked" \
           -H "Connection: Close" \
           -k -v \
           --data "New Arduino, who dis?"
    

    Use Device Explorer to register your device(s) and generate SAS.

    You should start here:
    https://azure.microsoft.com/en-us/documentation/articles/iot-hub-devguide/

    Depening on the scale of your project (2 devices or 2000?), you may want something less complex, like App Service Mobile Apps with Easy Tables. It's essentially a CRUD API.

    A POST is all you need to ingest telemetry. You can then use OData v3 syntax to GET and filter your data set.

    Zumo-GET-sample