I have a sensor that is very sensitive to changes in temperature. To remove this drift in my baseline measurement due to temperature changes, I have taken a bunch of readings and am able to generate a voltage x temperature plot. So, given each degree of temperature that I measure, I get a different baseline voltage. My goal is to be able to remove the offset the change in temperature causes.

I have fed this data into MATLAB and have come up with the following fourth order polynomial equation that fits a curve nicely along my collected data points.

```
Linear model Poly3:
f(x) = p1*x^3 + p2*x^2 + p3*x + p4
where x is normalized by mean 1.717 and std 0.00172
Coefficients (with 95% confidence bounds):
p1 = -1.409 (-1.49, -1.328)
p2 = 2.49 (2.311, 2.668)
p3 = 37.14 (37, 37.28)
p4 = 6115 (6115, 6115)
```

Using this for guidance, I have generated the following Arduino code to try to use this equation to compensate my baseline for temperature drift:

```
float p1 = -1.409;
float p2 = 2.49;
float p3 = 37.14;
float p4 = 6115.0;
and
polynomial = (p1*pow(sensorVolts,3)) + (p2*pow(sensorVolts,2)) + (p3*sensorVolts) + p4;
```

HOWEVER, while I may have arrived here after months and months of tinkering, learning, and experimenting (I am not an electrical engineer or mathematician) I feel I don't fully-understand the proper way to solve something like this.

I have a sensor that is reading in a fixed light level. This sensor changes voltage (slightly) with changes in temperature. What do I do with the polynomial expression that is mapping voltage to this baseline that I recorded. I am thinking that there should be someway to determine the difference between the current sensor reading and how far off from the polynomial baseline (given the current temperature), right?

Is there a standard way of doing this? I have used massive lookup tables before, but was trying a more elegant approach. Apparently, I have worked myself into too elegant of a hole.

Thanks for your insight.