-->
Page 1 of 1

Getting ESP Chip ID to MQTT Broker

PostPosted: Fri Mar 10, 2017 10:39 am
by AutoDoc
I need to send my ESP serial number to my MQTT broker as the payload. ESP.getChipID returns a 32-bit integer, and MQTT wants a string. After much trial and error I have a solution, but there must be a better way. Here's what I'm doing:
Code: Select all...
char NRValue[8];
String(ESP.getChipId()).toCharArray(NRValue,8);
client.publish("DocTest/ChipID", NRValue);
...


Is there a better way?

Re: Getting ESP Chip ID to MQTT Broker

PostPosted: Fri Mar 10, 2017 2:35 pm
by martinayotte
Code: Select allclient.publish("DocTest/ChipID", String(ESP.getChipId()).c_str());