Convert an Excel Calculation to Arduino

Hello, I am curve fitting a thermal couple using Excel.

This Excel calculation for “=14.782578+0.099628456*P31^1.4634484” calculates the correct answer of 29.95008781 of 31 degrees F.

Where” P31” = 31 or the variable in the code below called "Outside".

The form of the equation is Y = A + B X^C from TableCurve (curve fitting software).

I programmed this into Arduino and the results of 21.77 are wrong.

Please check out a copy of my code below:

double A = 14.782578; double B = .09962846; double C = 1.4364484; Outside = A + B * Outside * sqrt(C);

Thanks, Lou

What operation do you think the "^" symbol performs?

Which C/C++ function performs that operation?

double A = 14.782578;
double B = 0.09962846;
double C = 1.4364484;
double Outside = 31.0;

void setup() {
  // put your setup code here, to run once:

    Outside =  A + (B * pow(Outside, C));

void loop() {
  // put your main code here, to run repeatedly:


gives 28.6070176 at the serial output which is the same result I get when I use my calculator.

You sure about your "correct" answer?

Hi, What thermocouple or thermistor are you using?

Thanks.. Tom.. :)

Try this...

Outside = A + B * pow (Outside,C);

I got it from here:

pow() [Math] Description Calculates the value of a number raised to a power. Pow() can be used to raise a number to a fractional power. This is useful for generating exponential mapping of values or curves.

Syntax pow(base, exponent)

Parameters base: the number (float)

exponent: the power to which the base is raised (float)

Returns The result of the exponentiation. (double)