question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GPS python send message to Azure iot from Linux device

See original GitHub issue

Hi guys, from Linux with python I can send messages to Iot Azure with the code below, but could you also extend on how to pass with it GPS, please?

import os
    import asyncio
    from azure.iot.device.aio import IoTHubDeviceClient
etc

from simple_send_message from python azure sdk

simple_send_message.py
Sending message...
Message successfully sent!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:62 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
cartertinneycommented, Jun 2, 2021

@AndreV84

device_client = IoTHubDeviceClient.create_from_connection_string("<your connection string>")
with open("/dev/pts/26", "wb+", buffering=0) as term:
        while True:
        	data = str(term.read(26).decode(), end='')
                message = Message(data)
                device_client.send_message(message)

        sys.stdout.flush()

This should work. There is nothing special about sending data you receive from a GPS to the Hub. The Azure SDK is completely generic - it does not care where your data comes from. Just put it in a message, and send.

0reactions
cartertinneycommented, Jul 22, 2021

I can’t say I have a particular insight into that scenario, but as I said, if you wish to send data to Azure IoT Hub, the Device Client will do it over MQTT. The client does not support any other protocols for sending data to Azure IoT Hub.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cloud-to-device messages with Azure IoT Hub (Python)
How to send cloud-to-device messages to a device from an Azure IoT hub using the Azure IoT SDKs for Python. You modify a...
Read more >
Python send complex data (i.e GPS location) to Azure IoT ...
I am trying to send data from Raspberry Pi to Azure IoT Central. I am not sure how to structure the message to...
Read more >
Send device telemetry to Azure IoT Hub quickstart
This quickstart shows device developers how to connect a device securely to Azure IoT Hub. You use an Azure IoT device SDK for...
Read more >
Messaging and IoT for Python apps on Azure - Microsoft Learn
Internet of Things (IoT) · Send telemetry from a device to an IoT hub and read it with a back-end application · Send...
Read more >
Azure IoT DeviceClient SDK Python demonstration, the basics
Direct Methods provides a live update of a connected device. You can send a (JSON) message to the device while it is connected...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found