You may consider using another thermopile sensor from the Melexis (MLX90614 or MLX90616).
Unlike OTP-638, it has internal brains to measure voltage and sensor temperature with simple I2C digital output for both.
There are several projects posted on Cypress forums with code for it, e.g.
According to the OTA-638D2 datasheet, the object temperature Tobj can be obtained using a lookup table from measured V_thermopile and T_themistor. Lets say T_thermistor=20C and V_thermopile = 1.50 V.
1. select a column (1-25), corresponding to T_thermistor [C]. Column = 20.
2. In the column 20, find voltage, closest to V_thermopile =1.50V. Found 1.530V, which gives T_object = 37C.
Remember, that using this lookup table assumes that no other filters or additional optics is attached to the sensor. This method will require to put entire table into uC flash memory, which will take 50*25*2*4 = 10000 bytes if float precision is used. The size can be reduced twice (5000 bytes) if V_thermopile is converted to int precision by multiplying values from the table by 1000. Advantage of this method is speed. The disadvantage is that creating a large lookup table is time-consuming, and the accuracy is rather low (1degC).
The accuracy can be improved to approx. 0.1degC by using direct calculation according to the master equation:
V_thermopile = K (T_object[K]^4 - T_thermistor[K]^4),
(here all temperature values in Kelvins, not Celsius!)
T_object[K] = T_object[C] + 273.15
T_thermistor[K] = T_thermistor[C] + 273.15
T_object[K] = sqrt( sqrt( V_thermopile/K + T_thermistor[K]^4 ) ).
T_object[C] = T_object[K] - 273.15
In this equation, constant K is unknown, and you would have to calculate it yourself using either a table from the datasheet or to measure it directly using some known body temperature:
(1/K) = (T_object[K]^4 - T_thermistor[K]^4) / V_thermopile.
Example of (1/K) calculation using lookup table from the datasheet:
T_obj = 50C = 323.15 K
T_thr = 0C = 273.15 K
V_thp = 4.397 mV
T_obj^4 - T_thr^4 = 10904773289.97 - 5566789756.3 = 5337983533.675
Z = (1/K) = 5337983533.675 / 4.397 = 1.2140E+9 [K^4/mV]
Note that to get 0.1degC accuracy, T_thermistor must be also measured with 0.1C or better accuracy! You can use Fast Thermsitor Calculator to speed-up calculation and to get better accuracy:
The advantage of this technique is that no lookup table needed, and better accuracy is possible. Also assembled device can be re-calibrated, and improved value of the constant K can be obtained. But performing all that calculations will take some time.
Hi I had tried finding value of K , but it keeps on varying. Those falling to zero are actually divide by zero error, where Tobj & Tamb equals each other. here is excel file where values of K are calculated : https://www.avrfreaks.net/sites/default/files/forum_attachments/values_thermopile.xlsx
Somehow we are stuck with analog sensor only, so have to use only this. Thats why I searched this cypress app note and trying to understand how it works?
So this forumula dont work.
The Excel table and the chart above represent calibration data in very wide range from -50C to +700C. No surprise, that there is some deviation of the K value. It is, actually, quite remarkable, that despite highly non-linear relation, the value of K deviates only by a factor of 3 in the entire range. Moreover, it can be linearized with good accuracy, if necessary. On the positive side, the values for T_object from 0C to 50C occupy on the chart X a narrow space from ~2500 to ~5000. And the value of K in that range
is pretty much constant, ~0.8E-12 [V/K^4], which coincides with value (1/K)=1.21E+12 [K^4/V] calculated in my previous post.
I would give it a try and fine-tune the constant if necessary. Note that tabulated values are only for unpakaged device, any additional optics or reflective pipe will affect this value.
The analog sensor must be cheaper, compared to $10 Melexis part. But it needs Delta Sigma ADC, for example PSoC5, which is more expensive than e.g PSoC4.
Note that equations (1) and (10) in the above App Note are incorrect.
In range of Tobj=30 to 47C & Tntc = 0 to 50C, value of K varies from 0.000000000000835174699521675000(max) to 0.000000000000772644023249283000(min)
I took average of all values of K, and in final calculations, when Tobj is calculated from known Vtp,K & Ta , it gives error of 1C to -0.2C,
This is too large of error even for small range.
I had detailed discussion with manufacturer. They have given this equation. Need to find two unknowns in below equation:
Vtp = K( Tobj^(4-n) - Ta^(4-n) )
Company says K & n are empirically determined value & this they wont tell.
Vtp is in volts
Tobj & Ta are in kelvins
Here is 38301 dataset: https://drive.google.com/file/d/1Kzok_MVeLRNiUz59HZl6xHrpkh5dg3mg/view?usp=sharing
From these 38301 dataset values, we need to find best fit values of K & n, so that in final calculations when Tobj is to be calculated from known values of Vtp,Ta,K & n, Tobj has minimum error.
Too bad, this equation invokes fractional power calculations, which is very slow
Vtp = K( Tobj^(4-n) - Ta^(4-n) )
Have enough memory and power, so not an issue, will call math library pow().
Thing is how to find values of K & n
I believe that Excel has minimization function, which can optimize K and n over the dataset. Something like equation solver. I am not an expert on that.