Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ad_val;
- float resolution = 1024.0; //1024 = 2^10, please check ad bit setting
- float ad_voltage;
- float ad_resistance;
- float vcc = 3.3;
- float resistance0 = 10000; // R0, termista, 10k ohm (normal, 25deg)
- float resistance1 = 10000; // R1, split voltage resitance, 10k ohm
- float e = 2.7182818284; // Napier's constant
- float b = 3435.0; // B parameter termista value when 25 deg. = 3435
- float standard_temp = 25.0 + 273.15; // 25.0 deg + 273.15 absolute temp. [kelbin]
- float temprature;
- ad_val = (int)p_event->data.done.p_buffer[i];
- ad_voltage = (float)(ad_val) / resolution * vcc;
- ad_resistance = ad_voltage / (vcc - ad_voltage) * resistance1;
- temprature = b/(logf(ad_resistance/resistance0) + (b/standard_temp)) - 273.15;
- //NRF_LOG_INFO("%d,%f", p_event->data.done.p_buffer[i], temprature);
- //NRF_LOG_INFO(NRF_LOG_FLOAT_MARKER, NRF_LOG_FLOAT(temprature));
- NRF_LOG_RAW_INFO("%d," NRF_LOG_FLOAT_MARKER "\n", p_event->data.done.p_buffer[i], NRF_LOG_FLOAT(temprature));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement