Retrieve sensor data from mqtt broker using telegraf

Hi guys,

I am trying to using telegraf to collect sensor data and insert to influxDB.
My problem is that influxDB isnt displaying the field in which my data, which is temperature and humidity, is stored.

The part of the JSON message that i want to be displayed is shown in the right picture and the topics that are displayed in influxDB are shown in the left picture:

The data of /timer[1]/counter_code and counter_data as well as pdin_code is displayed as field
in influxDB. The pdin_data isn’t listed. I figure this is cause of the data being a string.

As u can see the string is a hexadecimal number, with the first 4 symbols being the temperature data. My questions are (1) if I can cast the string to a float number using telegraf, (2) if I can seperate the temperature/humidity part off the json message from the placeholder by cutting parts of the text e.g.: β€œ01B9FF0000F4FF00” β†’ Temperature: B9FF, Humidty F5FF using telegraf or if there is another way to display the data in influxDB.

Yes that is possible in Telegraf.
And I would also definitely fix it in Telegraf before it ends up in InfluxDB!

You need a processor plugin for that. With the standard plugins this should not be possible, I would solve it with a processors.starlark or processors.execd plugin.

1 Like