1. Have a thermistor, data whose dataset is available not anything else from company except B value. Attached is data.

2. Trying to make a equation for it and implement for 8 bit MCU, usin IAR IDE.

3. First I made this code, steinhart thermistor equation. calculated values of A,B,C from this site: https://www.thinksrs.com/downloa... . Put three values at -20C, 25C & 100C and get A,B,C

uint8_t get_ntc_temperature_4(float32_t resistance , float32_t *tempearture_c) { uint8_t err = 0U; float32_t x; float32_t x2; float32_t x3; if( (resistance <= 956040.0f) && (resistance >= 6683.0f) ) { x = logf(resistance); x2 = x * x; x3 = x2 * x; x = 0.000641295533f + (0.0002233488434f * x) + (0.0000000926090998f * x3); x = 1.0f / x; *tempearture_c = x - 273.15f; } else { err = 1U; } return err; }

4. Then made equation using curve fit tool and below is code:

uint8_t get_ntc_temperature_2(float32_t resistance , float32_t *tempearture_c) { uint8_t err = 0U; float32_t c0; float32_t c1; float32_t c2; if( (resistance <= 956040.0f) && (resistance >= 482170.0f) ) { c0 = 14.5029518320319131f; c1 = -0.000057344817030149406f; c2 = 0.000000000021788855747503695f; } else if(resistance >= 250140.0f) { c0 = 29.3136847463533279f; c1 = -0.000119496884518122221f; c2 = 0.0000000000876747221220605721f; } else if(resistance >= 130230.0f) { c0 = 45.3985586636038647f; c1 = -0.000249401966454676711f; c2 = 0.000000000352768556658954028f; } else if(resistance >= 71230.0f) { c0 = 62.1448935476119572f; c1 = -0.000506560472110208432f; c2 = 0.00000000135019658772898851f; } else if(resistance >= 39200.0f) { c0 = 79.7753263268828902f; c1 = -0.00100556530593662709f; c2 = 0.00000000491385322365418885f; } else if(resistance >= 21830.0f) { c0 = 98.8979251125107339f; c1 = -0.00198872984475097995f; c2 = 0.0000000176669521860767602f; } else if(resistance >= 12750.0f) { c0 = 118.809289117525665f; c1 = -0.00381338043851388829f; c2 = 0.0000000598289053823529209f; } else if(resistance >= 7327.0f) { c0 = 140.313484336487619f; c1 = -0.00722784306211046376f; c2 = 0.000000196440993753396293f; } else if(resistance >= 6683.0f) { c0 = 133.215333415477943f; c1 = -0.00480709971651089099f; c2 = 0.0f; } else { err = 1U; } if(0U == err) { *tempearture_c = c0 + (c1 * resistance) + (c2 * resistance * resistance); } return err; }

5. Size build on full size optimization on IAR for 8 bit MCU:

a) No function call:

5 138 bytes of readonly code memory

139 bytes of readonly data memory

357 bytes of readwrite data memory

b) With polynomial equation fit:

5 593 bytes of readonly code memory

139 bytes of readonly data memory

357 bytes of readwrite data memory

c) With natural log:

5 820 bytes of readonly code memory

139 bytes of readonly data memory

359 bytes of readwrite data memory

6. Noticed that with polynomial fit extra space is 455 bytes & with natural log its 682 bytes.

7. Error with polynomial fit is +0.069 to -0.098C.

Error with natural log is slightly more though.

8. Any other better method to implement or curve fit this data? Max end function accuracy I am looking is +-0.099C.

PS: In function call, I got coefficients generated in float64_t in curve fit toolbox, put f in the end though.