Hi,
I am using SDK 2.0.0.
I have two problems in this function.
#include <math.h>
.
.
.
static void on_temp_request(uint16_t Vt)
{
uint16_t beta = 4100;
uint16_t T1 = 25;
float Vcc = 2.97;
float RT1 = 10000; // resistance @ T1
float RT2; // resistance @ T2
float temp;
float Vt_V;
Vt_V = Vt/1000;
RT2 = (RT1 * Vt_V) / (Vcc - Vt_V);
temp = 1 / ( (logf(RT2/RT1) / beta ) + 1/25);
LOG_INF ("Temperature reported : %0.2f, %0.2f, %d", temp, RT2, Vt);
}
Lets take Vt value as 1420, in one instance.
1. RT2 is calculated as 5076.14. This is incorrect. It should have been 9161.29.
2. I couldn't find the ln () function (natural log function). It was really difficult to find any reference to Nordic SDK math functions. I found 'logf' as natural log in one SES document. So I tried it. After modifying my prj.conf, I managed to compile it. But still the calculation is not correct. It calculates the temps as -6046.90. It could be that logf is not the natural log function. In that case, what is natural log () in NRF SDK? How to use it in my app?
I added the following in my prj.conf file
Thanks,