UTF-8 to Hex to Dec to Temp/Hum

I have a BLE beacon that sends Temp and Humidity data in a 6 byte text sensor, which I’d like to have translated in to meaningful data.
What I’d like to accomplish is this:

  • UTF8 to Hex
  • Hex to decimal
  • Convert decimal to °C / RH

Formulae:

float cTemp = ((((data[0] * 256.0) + data[1]) * 175) / 65535.0) - 45;
float humidity = ((((data[3] * 256.0) + data[4]) * 100) / 65535.0);

The text sensor (sensor.bthome_sensor_0001_text) contains i.e. k釠U

Converted by Convert UTF8 to Hexadecimal – Online UTF8 Tools
0x6b 0xe9 0x87 0xa0 0x55 0x00

Byte 1 and 2 are temperature 0x6be9 (27625 decimal, 28.76°C )
Byte 4 and 5 are humidity 0xa055 (41045 decimal, 72.28% RH)
Byte 3 and 6 are CRC and can be ignored

So my challenge is to make a lambda that converts the UTF8 to hex, take the first 2 bytes for temp, 4th and 5th for RH, convert those to decimal an use that as input for the °C / RH conversion.
I’m sure that this isnt very complicated for the experciences c++ developer, but I don’t have any c++ or lambda knowledge. I usually understand code, but writing is a different matter.
So any help is very much appreciated :slight_smile: