I want to create a lookup table in a SD card which contains bytes corresponding to humidity values based on dry bulb wet bulb temps. Such as hum[drybulb[wetbulb]]. That's to say, an array within an array. In other words I provide a temp value for drybulb and a second value for wetbulb and get a return value of humidity. The expected range of values are typically between 0 and 40 degrees Celsius, so single bytes are sufficient (assume no decimals). Does this make sense?. Any ideas?
The lookup table will be something like this:
How many values will you have and which arduino are you using?
May be it fits nicely in flash memory and you don’t need the SD card at all
Not really. The humidity can easily be calculated by the arduino from the two temperature readings. No need for a look-up table.
You mean there is a formula such as hum = fn (x, y) ?
I've only found tables.
It looks like 400 values which,
you're right !
will fit within flash memory of a Pro-mini !
Thanks for your reply.
Yes. The formula is a little more complicated than I imagined, but do-able for Arduino. I did not find a C code version, but I did find this:
so just declare your LUT as a 2D array with PROGMEM
const uint8_t twoDimension[][5] PROGMEM = {
{10, 20, 30, 40, 50},
{11, 21, 31, 41, 51},
{12, 22, 32, 42, 52},
{13, 23, 33, 43, 53},
{14, 24, 34, 44, 54},
{15, 25, 35, 45, 55},
{16, 26, 36, 46, 56},
};
const byte nbCols = sizeof twoDimension[0] / sizeof * twoDimension[0];
const byte nbRows = sizeof twoDimension / sizeof * twoDimension;
void setup() {
Serial.begin(115200);
Serial.print(F("table size = ")); Serial.print(nbCols); Serial.write('x'); Serial.println(nbRows);
for (size_t c = 0; c < nbCols; c++) {
for (size_t r = 0; r < nbRows; r++) {
Serial.print(pgm_read_byte(&twoDimension[r][c]));
Serial.write('\t');
}
Serial.println();
}
}
void loop() {}
Here's a C++ version. Unfortunately it's not Arduino C++, so will need some adaptation.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.