Calculate confort index

Hello,
I use NXP Rapid IoT device.
On this, I want to calculate and display the comfort index, based on the following formula: index = (temperature * 1.8 + 32) - (0.55 - 0.0055 * humidity) * ((temperature * 1.8 + 32) - 58);
Can you give me a hint, what should I proceed?
Can I use a global variable in Get Temp and GetHum functions? If yes, how?

Thank you,
Mihai

Hello Mihai,

I am going to assume that you wish to make this calculation on the embedded side of the project. In this case you can utilize the code editor in the embedded tab of your project to insert your own C code to the project. You can also use the function element to create custom embedded behavior. For example in the trigger ability in the code view of the function element you add you can write the following as long as you have the element libraries loaded for the sensors which by default the NXP RIOTK will have.

ATMO_Status_t Function_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
    float tempC;
    float humidityPct;

    ATMO_ENS210_GetTemperatureFloat(&tempC);
    ATMO_ENS210_GetHumidityFloat(&humidityPct);

    float comfort = (tempC * 1.8f + 32.0f) - (0.55f - 0.0055f * humidityPct) * ((tempC * 1.8 + 32) - 58);
    ATMO_CreateValueFloat(out, comfort);
    return ATMO_Status_Success;
}

You can then use this new function element you make with it’s trigger ability and the trigger event will then carry the output out from comfort value we calculated which you can then send to another element to be used.

You can use global variables in the code view of your project. At the top of the C code that is exposed in the online editor you will see a section that looks like the following

//HEADER START

//HEADER END

You can insert any variables you want accessible by all the C functions in the project.

Thank you kieron.gillespie for answer.
It works.