Skip to content

Instantly share code, notes, and snippets.

@larryli
Created March 26, 2024 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larryli/ec66d2c9f818cd56440fba3e0b04fbcf to your computer and use it in GitHub Desktop.
Save larryli/ec66d2c9f818cd56440fba3e0b04fbcf to your computer and use it in GitHub Desktop.
NTC 100K
#include <math.h>
/**
* 3v3 --- [10K] -+- [NTC] --- GND
* |
* +-- ADC
*/
#define NTC_V 3300
#define NTC_R_PULLUP 10000
#define NTC_R(v) (NTC_R_PULLUP * (v) / (NTC_V - (v)))
/**
* B: 3950
* T25: 273.15 + 25
* T50: 273.15 + 50
* R25: 100000
* R50: 35884
* T25 * T50 R25
* B = --------- * ln(---)
* T50 - T25 R50
*/
#define NTC_B 3950
#define NTC_R25 100000
#define NTC_T25 (273.15 + 25)
#define NTC_T0 273.15
#define NTC_T(r) (1 / (1 / NTC_T25 + log((r) / NTC_R25) / NTC_B) - NTC_T0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment