Wind sensor temp correction

Is it possible to have arduino automatically update and "plug in" a correction factor based on another output.

For example if I buy this sensor:

And I use this code:

Notice this line for temp adjustment:

const float zeroWindAdjustment = .2; // negative numbers yield smaller wind speeds and vice versa.

Can I have arduino plug some predermined values in based on temps?

Thank you for any advice and help,

Ken

Yes.

It is handy to do this via a table.

In C or C++, a table is implemented via an array. Learn about arrays.

However, there is little need to use predetermined values unless speed is of the essence. The Arduino can calculate the correction factor (adjustment) based on the temperature and use this to correct the wind speed.

Ok ill start researching arrays. I have never looked at them before. Speed is not of the essence. A loop would run maybe every couple of minutes.

Thanks!

So I've been thinking... what about a conditional statement for each range of temps. And assign the correct calibration factor to them.

like this.

if ((TMP_Therm_ADunits>0) && (TMP_Therm_ADunits<10)) {
zeroWindAdjustment = .2;
}

// "0" and "10" would be a cold temp range that requires a factor of .2 to be used.

So how do I actually make this plug (.2) into this:

zeroWind_volts = (zeroWind_ADunits * 0.0048828125) - zeroWindAdjustment;

Uh, you just did it.

Except...
You probably want to change this

const float zeroWindAdjustment =  .2; // negative numbers yield smaller wind speeds and vice versa.

to this

float zeroWindAdjustment =  .2; // negative numbers yield smaller wind speeds and vice versa.

(Notice that we have deleted the const part of the statement.)

Also, you can probably simplify your if statements (for example):

 float zeroWindAdjustment =  0.0; // negative numbers yield smaller wind speeds and vice versa.
.
.
.
    if (TMP_Therm_ADunits<10) { 
      zeroWindAdjustment =  .2;
    }  else if (TMP_Therm_ADunits<20) {
      zeroWindAdjustment = .4;
    } else if (TMP_Therm_ADUnits<30) {
      zeroWindAdjustment = .6;
    } else {
      zeroWindAdjustment = .8;
    }
    zeroWind_volts = (zeroWind_ADunits * 0.0048828125) - zeroWindAdjustment;

Oh so this code needs to go in the setup section and not the loop. In my head I was wondering how I could get it back to the top. Well durn, This sounds like a fun experiment. I was on the fence about ordering this sensor until I could make sure this would work.

Thanks!

Ken

Seasea19:
Oh so this code needs to go in the setup section and not the loop. In my head I was wondering how I could get it back to the top. Well durn, This sounds like a fun experiment. I was on the fence about ordering this sensor until I could make sure this would work.

Thanks!

Ken

the code should be placed in the loop not in the setup

setup only runs once then moves to the main loop. As you want the calibration number to change based on temp then it will need to be tested more than once

float zeroWindAdjustment = 0.0; can go in the loop but must be placed before anything trys to use it with in the loop. Or it can be placed before setup and used as a global.

You need to remove the const as that stands for constant which means its read only and you want to be able to change it.

personally I would make it global as you may wish to move the calibration code to a function later

Did you read the comment in the code?

// adjust the zeroWindAdjustment until your sensor reads about zero with the glass over it.

The adjustment factor is not based on temperature. Where did you get that idea?