How to record temperature into a FIT file (so it is also graphed in the Connect app)?

Hello,

I am currently trying to log the device temperature (using SensorHistory) to a FIT file.

I already have the heart rate logged and that also shows up in Garmin Connect as an activity, so the FIT file creation is working.

My issue now is how to write the temperature data to the FIT file (which field ID and data type to use) in such a way that I can later view the data as a graph in Connect IQ.

Ideally I would like to have two-decimal precision.

How could I do that?

I currently can't insert a code block so I uploaded the App.mc on pastebin: https://pastebin.com/ScFyrzGz

Thanks in advance

Aaron