I am struggling with this...
The Wind Direction only gets read every second transmission cycle so I need to be able to set the wthrWindDir = 'X' on the non-read cycle;
When I use this in a function it prints the appropriate letter 'A' through 'P'.
Serial.print(getWindDirection_Descr(dataBytes[4]));
But, when I do this is prints a back-to-front "?" for the value.
wthrWindDir = getWindDirection_Descr(dataBytes[4]);
Serial.print(wthrWindDir);
if wthrWindDir != 'X' ...
I realize this is non-working code, but I am sure it is a procedural thing that I am not grasping -- again!
Full code is here.
https://forum.arduino.cc/index.php?topic=528352.msg3601988#msg3601988
char wthrWindDir = 'X';
const float winddirections[] = {
315.0, 247.5, 292.5, 270.0,
337.5, 225.0, 0.0, 202.5,
67.5, 135.0, 90.0, 112.5,
45.0, 157.5, 22.5, 180.0
};
char * acurite_5n1_winddirection_str[] = {
"A", // 0 315
"B", // 1 247.5
"C", // 2 292.5
"D", // 3 270
"E", // 4 337.5
"F", // 5 225
"G", // 6 0
"H", // 7 202.5
"I", // 8 67.5
"J", // 9 135
"K", // 10 90
"L", // 11 112.5
"M", // 12 45
"N", // 13 157.5
"O", // 14 22.5
"P" // 15 180
};
char * getWindDirection_Descr(byte b) {
int direction = b & 0x0F;
return acurite_5n1_winddirection_str[direction];
}