Fail Connecting EmonTX+ESP8266 to Azure IoT HUB using MQTT protocol

Hi!, I’m Julian, The aim of my project is to implement an IoT device based on ATMega328+EmonTX Shield+ESP8266. This IoT device needs to send MQTT messages to Azure Cloud. I have ready the cloud part except for MQTT communications.

The first issue that I found is MQTT login process. ESP8266 setup interface doesn’t accept Azure’s MQTT protocol (Furtheremore information MicrosoftDocs/azure-docs/blob/master/articles/iot-hub/iot-hub-mqtt-support.md#using-the-mqtt-protocol-directly-as-a-device)

Once all steps in Azure cloud side are clear and defined (IoT Hub, Device Created, SAS token generated) can’t setup LogIn parameters in emonESP site.

Username required by Azure :

xxxxxDevices.azure-devices.net/emoncms/api-version=2016-11-14

SAS Token generated and required for Azure MQTT as password (include blank space between Signature and sr=):

SharedAccessSignature sr=XXXX.azure-devices.net%2Fdevices%2Femoncms&sig=OcTUy5HKPTFJq7sczWJURgSdCqKK22om1f7bD6%2FA%2FQw%3D&se=1635538818

Also requires:

ClientID : Can’t be defined in emonESP page

My theories are:

  • emoESP is not prepared to handle SaS token format as a password for MQTT login. Even when SAS token is HTTP compatible.

  • Username format required by Azure is not accepted by emonESP page.

Hope someone could help me to solve this issue.

Many thanks in advance for your support

Julian

Hi Julian, welcome.

There is another thread re MQTT Custom Port running. EmonESP Custom MQTT Port - what version are you running? @glyn.hudson is the man for the ESP Firmware.

I’d suggest this is best raised as an Issue on GitHub.

If you can’t easily get this to work swap the ESP for a PiZero.

Easier to manage & modify.