#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd1(0x20, 16, 2);
LiquidCrystal_I2C lcd2(0x21, 16, 2);
LiquidCrystal_I2C lcd3(0x22, 16, 2);
LiquidCrystal_I2C lcd4(0x23, 16, 2);
unsigned long previousMillis;
unsigned long currentMillis;
unsigned long displayOffset;
unsigned long displayMillis;
const int duration_1 = 5000;
const int duration_2 = 500;
const int duration_3 = 5000;
int seq;
int last;
int w;
int x;
int z;
int d[5];
int e;
#define txEnableCom1 22
#define txEnableCom2 23
#define stationSelect_A 24
#define stationSelect_B 25
#define dip_3 26
#define dip_4 27
#define dip_5 28
#define dip_6 29
#define dip_7 30
#define dip_8 31
#define backlightButton 32
int stationAddress[5] = {
300, 301, 302, 303, 304
};
int address = 110;
int addressHold;
char data[64] = {0};
int y100;
int y200;
float y[19];
int commandEStop = 9110;
int packet1 = 201;
int packet2 = 202;
int packet3 = 203;
int packet4 = 204;
int packet5 = 205;
int packet6 = 206;
int comRelease = 207;
float a = 17.625;
float b = 243.04;
float temp;
float RH;
float Ts;
float altimeter;
float windSpeed_kts;
int headingAvg;
float temp_station1; float temp_station2; float temp_station3; float temp_station4;
float RH_station1; float RH_station2; float RH_station3; float RH_station4;
float altimeter_station1; float altimeter_station2; float altimeter_station3; float altimeter_station4;
int headingAvg_station1; int headingAvg_station2; int headingAvg_station3; int headingAvg_station4;
float windSpeed_kts_station1; float windSpeed_kts_station2; float windSpeed_kts_station3; float windSpeed_kts_station4;
float Ts_station1; float Ts_station2; float Ts_station3; float Ts_station4;
void setup() {
Serial.begin(19200);
Serial1.begin(19200);
Serial.setTimeout(1500);
while (!Serial || !Serial1) {
delay(10);
}
currentMillis = millis();
previousMillis = currentMillis;
displayMillis = millis();
displayOffset = displayMillis;
pinMode(txEnableCom1, OUTPUT);
pinMode(txEnableCom2, OUTPUT);
pinMode(stationSelect_A, INPUT_PULLUP);
pinMode(stationSelect_B, INPUT_PULLUP);
pinMode(backlightButton, INPUT_PULLUP);
seq = 1;
last = 2;
delay(1000);
if(digitalRead(stationSelect_A) == HIGH && digitalRead(stationSelect_B) == HIGH) {
x = 1;
lcd1.init();
lcd1.backlight();
lcd1.setCursor(0,0);
lcd1.print("Station 1 ");
lcd1.setCursor(0,1);
lcd1.print("****************");
}
if(digitalRead(stationSelect_A) == LOW && digitalRead(stationSelect_B) == HIGH) {
x = 2;
lcd1.init();
lcd1.backlight();
lcd1.setCursor(0,0);
lcd1.print("Station 1 ");
lcd1.setCursor(0,1);
lcd1.print("****************");
lcd2.init();
lcd2.backlight();
lcd2.setCursor(0,0);
lcd2.print("Station 2 ");
lcd2.setCursor(0,1);
lcd2.print("****************");
}
if(digitalRead(stationSelect_A) == HIGH && digitalRead(stationSelect_B) == LOW) {
x = 3;
lcd1.init();
lcd1.backlight();
lcd1.setCursor(0,0);
lcd1.print("Station 1 ");
lcd1.setCursor(0,1);
lcd1.print("****************");
lcd2.init();
lcd2.backlight();
lcd2.setCursor(0,0);
lcd2.print("Station 2 ");
lcd2.setCursor(0,1);
lcd2.print("****************");
lcd3.init();
lcd3.backlight();
lcd3.setCursor(0,0);
lcd3.print("Station 3 ");
lcd3.setCursor(0,1);
lcd3.print("****************");
}
if(digitalRead(stationSelect_A) == LOW && digitalRead(stationSelect_B) == LOW) {
x = 4;
lcd1.init();
lcd1.backlight();
lcd1.setCursor(0,0);
lcd1.print("Station 1 ");
lcd1.setCursor(0,1);
lcd1.print("****************");
lcd2.init();
lcd2.backlight();
lcd2.setCursor(0,0);
lcd2.print("Station 2 ");
lcd2.setCursor(0,1);
lcd2.print("****************");
lcd3.init();
lcd3.backlight();
lcd3.setCursor(0,0);
lcd3.print("Station 3 ");
lcd3.setCursor(0,1);
lcd3.print("****************");
lcd4.init();
lcd4.backlight();
lcd4.setCursor(0,0);
lcd4.print("Station 4 ");
lcd4.setCursor(0,1);
lcd4.print("****************");
}
lcd1.noBacklight();
lcd1.setCursor(0,0);
lcd1.print(" ");
lcd1.setCursor(0,1);
lcd1.print(" ");
lcd2.noBacklight();
lcd2.setCursor(0,0);
lcd2.print(" ");
lcd2.setCursor(0,1);
lcd2.print(" ");
lcd3.noBacklight();
lcd3.setCursor(0,0);
lcd3.print(" ");
lcd3.setCursor(0,1);
lcd3.print(" ");
lcd4.noBacklight();
lcd4.setCursor(0,0);
lcd4.print(" ");
lcd4.setCursor(0,1);
lcd4.print(" ");
}
void loop() {
// Slave communication
while(seq == 1) {
timer_2();
updateDisplay();
byte n = Serial.available();
if (n != 0) {
byte m = Serial.readBytesUntil('\n', data, 64);
data[m] = '\0'; //null-byte
y100 = atoi(strtok(data, ","));
y200 = atoi(strtok(NULL, ","));
if(y100 == address) {
if(y200 == 0) {
}
if(y200 == packet1) {
delay(200);
digitalWrite(txEnableCom1, HIGH);
Serial.print(address);
Serial.print(",");
Serial.print(packet1);
Serial.print(",");
Serial.print(temp);
Serial.print(",");
Serial.print(RH);
Serial.print(",");
Serial.println(Ts);
digitalWrite(txEnableCom1, LOW);
delay(50);
y200 = 0;
}
if(y200 == packet2) {
delay(200);
digitalWrite(txEnableCom1, HIGH);
Serial.print(address);
Serial.print(",");
Serial.print(packet2);
Serial.print(",");
Serial.print(altimeter);
Serial.print(",");
Serial.print(windSpeed_kts);
Serial.print(",");
Serial.println(headingAvg);
digitalWrite(txEnableCom1, LOW);
delay(50);
y200 = 0;
}
if(y200 == packet3) {
delay(200);
digitalWrite(txEnableCom1, HIGH);
Serial.print(address);
Serial.print(",");
Serial.print(packet3);
Serial.print(",");
Serial.print(0);
Serial.print(",");
Serial.print(0);
Serial.print(",");
Serial.println(0);
digitalWrite(txEnableCom1, LOW);
delay(50);
y200 = 0;
}
if(y200 == packet4) {
delay(200);
digitalWrite(txEnableCom1, HIGH);
Serial.print(address);
Serial.print(",");
Serial.print(packet4);
Serial.print(",");
Serial.print(0);
Serial.print(",");
Serial.print(0);
Serial.print(",");
Serial.println(0);
digitalWrite(txEnableCom1, LOW);
delay(50);
y200 = 0;
}
if(y200 == packet5) {
delay(200);
digitalWrite(txEnableCom1, HIGH);
Serial.print(address);
Serial.print(",");
Serial.println(comRelease);
digitalWrite(txEnableCom1, LOW);
delay(50);
y200 = 0;
}
}
else if(y100 != address) {
seq = last;
break;
}
}
else {
seq = 2;
}
}
// calculations
while(seq == 2) {
timer_2();
updateDisplay();
// one station
if(x == 1) {
float temp_C_station1 = (temp_station1 - 32) * (5/9);
float aTRH_station1;
aTRH_station1 = log(RH_station1/100) + ((a * temp_C_station1) / (b + temp_C_station1));
Ts_station1 = ((b * aTRH_station1) / (a - aTRH_station1)) * 9/5 + 32;
temp = temp_station1;
RH = aTRH_station1;
Ts = Ts_station1;
altimeter = altimeter_station1;
windSpeed_kts = windSpeed_kts_station1;
headingAvg = headingAvg_station1;
}
// two stations
if(x == 2) {
float temp_C_station1 = (temp_station1 - 32) * (5/9);
float aTRH_station1;
aTRH_station1 = log(RH_station1/100) + ((a * temp_C_station1) / (b + temp_C_station1));
Ts_station1 = ((b * aTRH_station1) / (a - aTRH_station1)) * 9/5 + 32;
float temp_C_station2 = (temp_station2 - 32) * (5/9);
float aTRH_station2;
aTRH_station2 = log(RH_station2/100) + ((a * temp_C_station2) / (b + temp_C_station2));
Ts_station2 = ((b * aTRH_station2) / (a - aTRH_station2)) * 9/5 + 32;
temp = (temp_station1 + temp_station2) / 2;
RH = (aTRH_station1 + aTRH_station2) / 2;
Ts = (Ts_station1 + Ts_station2) / 2;
altimeter = (altimeter_station1 + altimeter_station2) / 2;
windSpeed_kts = (windSpeed_kts_station1 + windSpeed_kts_station2) / 2;
headingAvg = (headingAvg_station1 + headingAvg_station2) / 2;
}
// three stations
if(x == 3) {
float temp_C_station1 = (temp_station1 - 32) * (5/9);
float aTRH_station1;
aTRH_station1 = log(RH_station1/100) + ((a * temp_C_station1) / (b + temp_C_station1));
Ts_station1 = ((b * aTRH_station1) / (a - aTRH_station1)) * 9/5 + 32;
float temp_C_station2 = (temp_station2 - 32) * (5/9);
float aTRH_station2;
aTRH_station2 = log(RH_station2/100) + ((a * temp_C_station2) / (b + temp_C_station2));
Ts_station2 = ((b * aTRH_station2) / (a - aTRH_station2)) * 9/5 + 32;
float temp_C_station3 = (temp_station3 - 32) * (5/9);
float aTRH_station3;
aTRH_station3 = log(RH_station3/100) + ((a * temp_C_station3) / (b + temp_C_station3));
Ts_station3 = ((b * aTRH_station3) / (a - aTRH_station3)) * 9/5 + 32;
temp = (temp_station1 + temp_station2 + temp_station3) / 3;
RH = (aTRH_station1 + aTRH_station2 + aTRH_station3) / 3;
Ts = (Ts_station1 + Ts_station2 + Ts_station3) / 3;
altimeter = (altimeter_station1 + altimeter_station2 + altimeter_station3) / 3;
windSpeed_kts = (windSpeed_kts_station1 + windSpeed_kts_station2 + windSpeed_kts_station3) / 3;
headingAvg = (headingAvg_station1 + headingAvg_station2 + headingAvg_station3) / 3;
}
// four stations
if(x == 4) {
float temp_C_station1 = (temp_station1 - 32) * (5/9);
float aTRH_station1;
aTRH_station1 = log(RH_station1/100) + ((a * temp_C_station1) / (b + temp_C_station1));
Ts_station1 = ((b * aTRH_station1) / (a - aTRH_station1)) * 9/5 + 32;
float temp_C_station2 = (temp_station2 - 32) * (5/9);
float aTRH_station2;
aTRH_station2 = log(RH_station2/100) + ((a * temp_C_station2) / (b + temp_C_station2));
Ts_station2 = ((b * aTRH_station2) / (a - aTRH_station2)) * 9/5 + 32;
float temp_C_station3 = (temp_station3 - 32) * (5/9);
float aTRH_station3;
aTRH_station3 = log(RH_station3/100) + ((a * temp_C_station3) / (b + temp_C_station3));
Ts_station3 = ((b * aTRH_station3) / (a - aTRH_station3)) * 9/5 + 32;
float temp_C_station4 = (temp_station4 - 32) * (5/9);
float aTRH_station4;
aTRH_station4 = log(RH_station4/100) + ((a * temp_C_station4) / (b + temp_C_station4));
Ts_station4 = ((b * aTRH_station4) / (a - aTRH_station4)) * 9/5 + 32;
temp = (temp_station1 + temp_station2 + temp_station3 + temp_station4) / 4;
RH = (aTRH_station1 + aTRH_station2 + aTRH_station3 + aTRH_station4) / 4;
Ts = (Ts_station1 + Ts_station2 + Ts_station3 + Ts_station4) / 4;
altimeter = (altimeter_station1 + altimeter_station2 + altimeter_station3 + altimeter_station4) / 4;
windSpeed_kts = (windSpeed_kts_station1 + windSpeed_kts_station2 + windSpeed_kts_station3 + windSpeed_kts_station4) / 4;
headingAvg = (headingAvg_station1 + headingAvg_station2 + headingAvg_station3 + headingAvg_station4) / 4;
}
seq = stationAddress[1];
z = 1;
}
while(seq == stationAddress[1]) {
addressHold = stationAddress[1];
timerComSeq();
timer_2();
updateDisplay();
if(w == 1) {
last = stationAddress[1];
if(z == 1) {
digitalWrite(txEnableCom2, HIGH);
Serial1.print(addressHold);
Serial1.print(",");
Serial1.println(packet1);
digitalWrite(txEnableCom2, LOW);
z = 2;
}
delay(50);
getWeatherData();
}
if(w == 2 && last == stationAddress[1]){
if(y100 == stationAddress[1] && y200 == comRelease) {
temp_station1 = y[1];
RH_station1 = y[2];
altimeter_station1 = y[7];
headingAvg_station1 = y[8];
windSpeed_kts_station1 = y[9];
}
if(z == 2) {
Serial1.println("Station 1");
Serial1.println(temp_station1);
Serial1.println(RH_station1);
Serial1.println(altimeter_station1);
Serial1.println(headingAvg_station1);
Serial1.println(windSpeed_kts_station1);
last == 2;
z = 1;
}
if(x == 1) {
seq = 1;
}
else if(x == 2 || x == 3 || x == 4) {
seq = stationAddress[2];
}
}
if(Serial.available() != 0) {
seq = 1;
break;
}
}
while(seq == stationAddress[2]) {
addressHold = stationAddress[2];
timerComSeq();
timer_2();
updateDisplay();
if(w == 1) {
last = stationAddress[2];
if(z == 1) {
digitalWrite(txEnableCom2, HIGH);
Serial1.print(addressHold);
Serial1.print(",");
Serial1.println(packet1);
digitalWrite(txEnableCom2, LOW);
z = 2;
}
delay(50);
getWeatherData();
}
if(w == 2 && last == stationAddress[2]){
if(y100 == stationAddress[2] && y200 == comRelease) {
temp_station2 = y[1];
RH_station2 = y[2];
altimeter_station2 = y[7];
headingAvg_station2 = y[8];
windSpeed_kts_station2 = y[9];
}
if(z == 2) {
Serial1.println("Station 2");
Serial1.println(temp_station2);
Serial1.println(RH_station2);
Serial1.println(altimeter_station2);
Serial1.println(headingAvg_station2);
Serial1.println(windSpeed_kts_station2);
last == 2;
z = 1;
}
if(x == 1 || x == 2) {
seq = 1;
}
else if(x == 3 || x == 4) {
seq = stationAddress[3];
}
}
if(Serial.available() != 0) {
seq = 1;
break;
}
}
while(seq == stationAddress[3]) {
addressHold = stationAddress[3];
timer_2();
updateDisplay();
if(w == 1) {
last = stationAddress[3];
if(z == 1) {
digitalWrite(txEnableCom2, HIGH);
Serial1.print(addressHold);
Serial1.print(",");
Serial1.println(packet1);
digitalWrite(txEnableCom2, LOW);
z = 2;
}
delay(50);
getWeatherData();
}
if(w == 2 && last == stationAddress[3]){
if(y100 == stationAddress[3] && y200 == comRelease) {
temp_station3 = y[1];
RH_station3 = y[2];
altimeter_station3 = y[7];
headingAvg_station3 = y[8];
windSpeed_kts_station3 = y[9];
}
if(z == 2) {
Serial1.println("Station 3");
Serial1.println(temp_station3);
Serial1.println(RH_station3);
Serial1.println(altimeter_station3);
Serial1.println(headingAvg_station3);
Serial1.println(windSpeed_kts_station3);
last == 2;
z = 1;
}
if(x == 1 || x == 2 || x == 3) {
seq = 1;
}
else if(x == 4) {
seq = stationAddress[4];
}
}
if(Serial.available() != 0) {
seq = 1;
break;
}
}
while(seq == stationAddress[4]) {
addressHold = stationAddress[4];
timerComSeq();
timer_2();
updateDisplay();
if(w == 1) {
last = stationAddress[4];
if(z == 1) {
digitalWrite(txEnableCom2, HIGH);
Serial1.print(addressHold);
Serial1.print(",");
Serial1.println(packet1);
digitalWrite(txEnableCom2, LOW);
z = 2;
}
delay(50);
getWeatherData();
}
if(w == 2 && last == stationAddress[4]){
if(y100 == stationAddress[4] && y200 == comRelease) {
temp_station4 = y[1];
RH_station4 = y[2];
altimeter_station4 = y[7];
headingAvg_station4 = y[8];
windSpeed_kts_station4 = y[9];
}
if(z == 2) {
Serial1.println("Station 4");
Serial1.println(temp_station4);
Serial1.println(RH_station4);
Serial1.println(altimeter_station4);
Serial1.println(headingAvg_station4);
Serial1.println(windSpeed_kts_station4);
last == 2;
z = 1;
}
seq = 2;
}
if(Serial.available() != 0) {
seq = 1;
break;
}
}
}
void timerComSeq() {
currentMillis = millis();
if(currentMillis < (previousMillis + duration_1)) {
w = 1;
}
if(currentMillis > (previousMillis + duration_1)) {
if(currentMillis < (previousMillis + duration_1 + duration_2)) {
w = 2;
}
if(currentMillis >= (previousMillis + duration_1 + duration_2)) {
previousMillis = currentMillis;
}
}
}
void timer_2() {
displayMillis = millis();
d[0] = duration_3 * 1;
d[1] = duration_3 * 2;
d[2] = duration_3 * 3;
d[3] = duration_3 * 4;
d[4] = duration_3 * 5;
if(displayMillis < (displayOffset + d[0])) {
e = 1;
}
else if((displayOffset + d[0]) < displayMillis && displayMillis < (displayOffset + d[1])) {
e = 2;
}
else if((displayOffset + d[1]) < displayMillis && displayMillis < (displayOffset + d[2])) {
e = 3;
}
else if((displayOffset + d[2]) < displayMillis) {
displayOffset = displayMillis;
}
}
void getWeatherData() {
byte n = Serial1.available();
if (n != 0) {
byte m = Serial1.readBytesUntil('\n', data, 64);
data[m] = '\0'; //null-byte
y100 = atoi(strtok(data, ","));
y200 = atoi(strtok(NULL, ","));
if(y100 == addressHold) {
if(y200 == 0) {
}
if(y200 == packet1) {
y[1] = atof(strtok(NULL, ","));
y[2] = atof(strtok(NULL, ","));
y[3] = atof(strtok(NULL, ","));
delay(200);
digitalWrite(txEnableCom2, HIGH);
Serial1.print(addressHold);
Serial1.print(",");
Serial1.println(packet2);
digitalWrite(txEnableCom2, LOW);
}
if(y200 == packet2) {
y[4] = atof(strtok(NULL, ","));
y[5] = atof(strtok(NULL, ","));
y[6] = atof(strtok(NULL, ","));
delay(200);
digitalWrite(txEnableCom2, HIGH);
Serial1.print(addressHold);
Serial1.print(",");
Serial1.println(packet3);
digitalWrite(txEnableCom2, LOW);
}
if(y200 == packet3) {
y[7] = atof(strtok(NULL, ","));
y[8] = atof(strtok(NULL, ","));
y[9] = atof(strtok(NULL, ","));
delay(200);
digitalWrite(txEnableCom2, HIGH);
Serial1.print(addressHold);
Serial1.print(",");
Serial1.println(packet4);
digitalWrite(txEnableCom2, LOW);
}
if(y200 == packet4) {
y[10] = atof(strtok(NULL, ","));
y[11] = atof(strtok(NULL, ","));
y[12] = atof(strtok(NULL, ","));
delay(200);
digitalWrite(txEnableCom2, HIGH);
Serial1.print(addressHold);
Serial1.print(",");
Serial1.println(packet5);
digitalWrite(txEnableCom2, LOW);
}
if(y200 == packet5) {
y[13] = atof(strtok(NULL, ","));
y[14] = atof(strtok(NULL, ","));
y[15] = atof(strtok(NULL, ","));
delay(200);
digitalWrite(txEnableCom2, HIGH);
Serial1.print(addressHold);
Serial1.print(",");
Serial1.println(packet6);
digitalWrite(txEnableCom2, LOW);
}
if(y200 == packet6) {
y[16] = atof(strtok(NULL, ","));
y[17] = atof(strtok(NULL, ","));
y[18] = atof(strtok(NULL, ","));
delay(200);
digitalWrite(txEnableCom2, HIGH);
Serial1.print(addressHold);
Serial1.print(",");
Serial1.println(comRelease);
digitalWrite(txEnableCom2, LOW);
}
if(y200 == comRelease) {
}
}
}
}
void updateDisplay() {
/*
temp_station1
RH_station1
altimeter_station1
headingAvg_station1
windSpeed_kts_station1
Ts_station1
*/
if(x == 1) {
if(digitalRead(backlightButton) == LOW) {
lcd1.backlight();
}
else {
lcd1.noBacklight();
}
}
if(x == 2) {
if(digitalRead(backlightButton) == LOW) {
lcd1.backlight();
lcd2.backlight();
}
else {
lcd1.noBacklight();
lcd2.noBacklight();
}
}
if(x == 3) {
if(digitalRead(backlightButton) == LOW) {
lcd1.backlight();
lcd2.backlight();
lcd3.backlight();
}
else {
lcd1.noBacklight();
lcd2.noBacklight();
lcd3.noBacklight();
}
}
if(x == 4) {
if(digitalRead(backlightButton) == LOW) {
lcd1.backlight();
lcd2.backlight();
lcd3.backlight();
lcd4.backlight();
}
else {
lcd1.noBacklight();
lcd2.noBacklight();
lcd3.noBacklight();
lcd4.noBacklight();
}
}
if(e == 1) {
lcd1.setCursor(0,0);
lcd1.print("Temp: ");
if(temp_station1 < 10) {
lcd1.print(temp_station1, 2);
lcd1.print("F ");
}
else if(10 <= temp_station1 || temp_station1 < 100) {
lcd1.print(temp_station1, 2);
lcd1.print("F ");
}
else if(100 <= temp_station1) {
lcd1.print(temp_station1, 2);
lcd1.print("F ");
}
lcd1.setCursor(0,1);
lcd1.print("RH: ");
if(RH_station1 < 10) {
lcd1.print(RH_station1, 2);
lcd1.print("% ");
}
else if(RH_station1 >= 10) {
lcd1.print(RH_station1, 2);
lcd1.print("% ");
}
lcd2.setCursor(0,0);
lcd2.print("Temp: ");
if(temp_station2 < 10) {
lcd2.print(temp_station2, 2);
lcd2.print("F ");
}
else if(10 <= temp_station2 || temp_station2 < 100) {
lcd2.print(temp_station2, 2);
lcd2.print("F ");
}
else if(100 <= temp_station2) {
lcd2.print(temp_station2, 2);
lcd2.print("F ");
}
lcd2.setCursor(0,1);
lcd2.print("RH: ");
if(RH_station2 < 10) {
lcd2.print(RH_station2, 2);
lcd2.print("% ");
}
else if(RH_station2 >= 10) {
lcd2.print(RH_station2, 2);
lcd2.print("% ");
}
lcd3.setCursor(0,0);
lcd3.print("Temp: ");
if(temp_station3 < 10) {
lcd3.print(temp_station3, 2);
lcd3.print("F ");
}
else if(10 <= temp_station3 || temp_station3 < 100) {
lcd3.print(temp_station3, 2);
lcd3.print("F ");
}
else if(100 <= temp_station3) {
lcd3.print(temp_station3, 2);
lcd3.print("F ");
}
lcd3.setCursor(0,1);
lcd3.print("RH: ");
if(RH_station3 < 10) {
lcd3.print(RH_station3, 2);
lcd3.print("% ");
}
else if(RH_station3 >= 10) {
lcd3.print(RH_station3, 2);
lcd3.print("% ");
}
lcd4.setCursor(0,0);
lcd4.print("Temp: ");
if(temp_station4 < 10) {
lcd4.print(temp_station4, 2);
lcd4.print("F ");
}
else if(10 <= temp_station4 || temp_station4 < 100) {
lcd4.print(temp_station4, 2);
lcd4.print("F ");
}
else if(100 <= temp_station4) {
lcd4.print(temp_station4, 2);
lcd4.print("F ");
}
lcd4.setCursor(0,1);
lcd4.print("RH: ");
if(RH_station4 < 10) {
lcd4.print(RH_station4, 2);
lcd4.print("% ");
}
else if(RH_station4 >= 10) {
lcd4.print(RH_station4, 2);
lcd4.print("% ");
}
}
if(e == 2) {
lcd1.setCursor(0,0);
lcd1.print("Wind: ");
if(windSpeed_kts_station1 < 10) {
lcd1.print(windSpeed_kts_station1, 2);
lcd1.print(" kts ");
}
else if(10 <= windSpeed_kts_station1 || windSpeed_kts_station1 < 100) {
lcd1.print(windSpeed_kts_station1, 2);
lcd1.print(" kts ");
}
else if(100 <= windSpeed_kts_station1) {
lcd1.print(windSpeed_kts_station1, 2);
lcd1.print(" kts");
}
lcd1.setCursor(0,1);
lcd1.print("Heading: ");
if(headingAvg_station1 < 10) {
lcd1.print(headingAvg_station1);
lcd1.print(" ");
}
else if(10 <= headingAvg_station1 || headingAvg_station1 < 100) {
lcd1.print(headingAvg_station1);
lcd1.print(" ");
}
else if(100 <= headingAvg_station1) {
lcd1.print(headingAvg_station1);
lcd1.print(" ");
}
lcd2.setCursor(0,0);
lcd2.print("Wind: ");
if(windSpeed_kts_station2 < 10) {
lcd2.print(windSpeed_kts_station2, 2);
lcd2.print(" kts ");
}
else if(10 <= windSpeed_kts_station2 || windSpeed_kts_station2 < 100) {
lcd2.print(windSpeed_kts_station2, 2);
lcd2.print(" kts ");
}
else if(100 <= windSpeed_kts_station2) {
lcd2.print(windSpeed_kts_station2, 2);
lcd2.print(" kts");
}
lcd2.setCursor(0,1);
lcd2.print("Heading: ");
if(headingAvg_station2 < 10) {
lcd2.print(headingAvg_station2);
lcd2.print(" ");
}
else if(10 <= headingAvg_station2 || headingAvg_station2 < 100) {
lcd2.print(headingAvg_station2);
lcd2.print(" ");
}
else if(100 <= headingAvg_station2) {
lcd2.print(headingAvg_station2);
lcd2.print(" ");
}
lcd3.setCursor(0,0);
lcd3.print("Wind: ");
if(windSpeed_kts_station3 < 10) {
lcd3.print(windSpeed_kts_station3, 2);
lcd3.print(" kts ");
}
else if(10 <= windSpeed_kts_station3 || windSpeed_kts_station3 < 100) {
lcd3.print(windSpeed_kts_station3, 2);
lcd3.print(" kts ");
}
else if(100 <= windSpeed_kts_station3) {
lcd3.print(windSpeed_kts_station3, 2);
lcd3.print(" kts");
}
lcd3.setCursor(0,1);
lcd3.print("Heading: ");
if(headingAvg_station3 < 10) {
lcd3.print(headingAvg_station3);
lcd3.print(" ");
}
else if(10 <= headingAvg_station3 || headingAvg_station3 < 100) {
lcd3.print(headingAvg_station3);
lcd3.print(" ");
}
else if(100 <= headingAvg_station3) {
lcd3.print(headingAvg_station3);
lcd3.print(" ");
}
lcd4.setCursor(0,0);
lcd4.print("Wind: ");
if(windSpeed_kts_station4 < 10) {
lcd4.print(windSpeed_kts_station4, 2);
lcd4.print(" kts ");
}
else if(10 <= windSpeed_kts_station4 || windSpeed_kts_station4 < 100) {
lcd4.print(windSpeed_kts_station4, 2);
lcd4.print(" kts ");
}
else if(100 <= windSpeed_kts_station4) {
lcd4.print(windSpeed_kts_station4, 2);
lcd4.print(" kts");
}
lcd4.setCursor(0,1);
lcd4.print("Heading: ");
if(headingAvg_station4 < 10) {
lcd4.print(headingAvg_station4);
lcd4.print(" ");
}
else if(10 <= headingAvg_station4 || headingAvg_station4 < 100) {
lcd4.print(headingAvg_station4);
lcd4.print(" ");
}
else if(100 <= headingAvg_station4) {
lcd4.print(headingAvg_station4);
lcd4.print(" ");
}
}
if(e == 3) {
lcd1.setCursor(0,0);
lcd1.print("alt: ");
lcd1.print(altimeter_station1, 2);
if(altimeter_station1 < 10) {
lcd1.print(" inH2O ");
}
else if(10 <= altimeter_station1 || altimeter_station1 < 100) {
lcd1.print(" inH2O");
}
lcd1.setCursor(0,1);
lcd1.print("Ts: ");
lcd1.print(Ts_station1);
if(Ts_station1 < 10) {
lcd1.print("F ");
}
else if(10 <= Ts_station1 || Ts_station1 < 100) {
lcd1.print("F ");
}
else if(100 <= Ts_station1) {
lcd1.print("F ");
}
lcd2.setCursor(0,0);
lcd2.print("alt: ");
lcd2.print(altimeter_station2, 2);
if(altimeter_station2 < 10) {
lcd2.print(" inH2O ");
}
else if(10 <= altimeter_station2 || altimeter_station2 < 100) {
lcd2.print(" inH2O");
}
lcd2.setCursor(0,1);
lcd2.print("Ts: ");
lcd2.print(Ts_station2);
if(Ts_station2 < 10) {
lcd2.print("F ");
}
else if(10 <= Ts_station2 || Ts_station2 < 100) {
lcd2.print("F ");
}
else if(100 <= Ts_station2) {
lcd2.print("F ");
}
lcd3.setCursor(0,0);
lcd3.print("alt: ");
lcd3.print(altimeter_station3, 2);
if(altimeter_station3 < 10) {
lcd3.print(" inH2O ");
}
else if(10 <= altimeter_station3 || altimeter_station3 < 100) {
lcd3.print(" inH2O");
}
lcd3.setCursor(0,1);
lcd3.print("Ts: ");
lcd3.print(Ts_station3);
if(Ts_station1 < 10) {
lcd3.print("F ");
}
else if(10 <= Ts_station3 || Ts_station3 < 100) {
lcd3.print("F ");
}
else if(100 <= Ts_station3) {
lcd3.print("F ");
}
lcd4.setCursor(0,0);
lcd4.print("alt: ");
lcd4.print(altimeter_station4, 2);
if(altimeter_station4 < 10) {
lcd4.print(" inH2O ");
}
else if(10 <= altimeter_station4 || altimeter_station4 < 100) {
lcd4.print(" inH2O");
}
lcd4.setCursor(0,1);
lcd4.print("Ts: ");
lcd4.print(Ts_station4);
if(Ts_station4 < 10) {
lcd4.print("F ");
}
else if(10 <= Ts_station4 || Ts_station4 < 100) {
lcd4.print("F ");
}
else if(100 <= Ts_station4) {
lcd4.print("F ");
}
}
}