Brett Oliver
Published © CC BY-NC

Arduino Barometer

Arduino Stepper Motor Barometer with additional displays for last 3 & 6 hour pressure changes.

AdvancedFull instructions provided8 hours16,686
Arduino Barometer

Things used in this project

Story

Read more

Schematics

Schematic

Code

BarometerA4988_23.ino

Arduino
Main file for Barometer and 6 hour display
/* Example sketch to control a 28BYJ-48 stepper motor with ULN2003 driver board, AccelStepper and Arduino UNO: number of steps/revolutions. More info: https://www.makerguides.com 
v4 moved step 6 hour pressure step from  void getpressure 1523 to main loop check every hour 365
v5 remove unwamted step elements
v6 convert to diff display on 6 hr motor
v8 modified hour change formula 1486
v9 sleep
v10 chnged high/low for EN control 
v11 chenge calc for hour change 1380
v12 added calcCurrentDisp (); to calc current time from line 1384
v13 removed 30 sec sync
v14 air pressure extremes LEDs
v15 add hour diff hour calc etc to row 1 when not on settings
v16 adding 16th steps
v17 error
v18 change min pulse to hour pulse on the hour + 1min
v19 check enable and sleeps
v20 added DAC to NANO so pins changed on 328 to match (analogue and digital swapped A6 D3 - deleted
    v20 also changed Low range hi range to both light above 19 or -19
v21 same as 20 with serial print removed
v23 notes added LCD display info added to startup 
*/
#include <SFE_BMP180.h> //SFE_BMP180 pressure sensor
#include <Wire.h>
#include <SPI.h>
#include <LiquidCrystal_I2C.h>

// ######## You will need to create an SFE_BMP180 object, here called "pressure":

SFE_BMP180 pressure;

#define ALTITUDE 118.0 // Altitude of Kenley Surrey in meters
// also used to adjust/sync/calibrate to nearby weather station/3 hour display

//#########

//**********************
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

#define DS3231_I2C_ADDRESS 0x68
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}




// Include the AccelStepper library:
#include <AccelStepper.h>

// Define stepper motor connections and motor interface type. Motor interface type must be set to 1 when using a driver:
#define dirPin 8
#define stepPin 9
#define dirPin2 10
#define stepPin2 11

#define motorInterfaceType 1
// Create a new instance of the AccelStepper class:
AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);//barometer motor
AccelStepper stepper2 = AccelStepper(motorInterfaceType, stepPin2, dirPin2);// 6 hour motor


float seaPressure = 0;
float pressureNow = 0;
float pressurePrevious = 0;
float pressureDiff = 0;
int checkStop = 0;
int pressureRndDiff = 0;
int pressureRndNow =0;
int pressureRndPrevious =0;
int adjustOn = 4; // allows adjustment of barometer
// int test = 0; // test mode 0 off 1 is on

char status;
  double T,P,a;

//int h =0;
//int m = 0;
//int j = 0;
int stepcount = 0;
int time = 0;
int resetmins = 1;
int secondNow = 0;
int secondPrevious=0;
int minuteNow = 0;
int minutePrevious=0;
int hourNow = 0;
int hourPrevious=0;
int hourNow1=0;
int hourPrevious1=0;
int initial = 0;
int initial1 = 0;
int initial3 = 0;
int highPressureLED = 3;
int lowPressureLED = 5;
int hour6LowLED = 15;
int hour6HighLED = 16;
int manSync = 12; // resets seconds to 30 seconds
int changeSetting = 2;
int syncStop = 0;
int sync30Stop = 0;
int stepoffHour = 0;
int stepoffHourbkw = 0;
int stepoffMin = 0;
int stepoffMinbwd = 0;
int stepoffRTCminfwd = 0;
int stepoffRTCminbwd = 0;
int stepoffRTChourfwd = 0;
int stepoffRTChourbwd = 0;
int settingreadPin = A3; //Pin for sensing analogue value from pot
int settingVal = 0; // Analogue value 0-1023
int LCDstop = 0; // stops settings on LCD display refreshing until they change
int hourPulse = 13; //min pulse for seconds display was 14
int adjustLock = 0; // turns off adjust lock
int hourcalc = 0; // number from 0 to 7 representing the 8 hours of stored pressure readings 
int hourDiff = 0; // used to check if 6hour previous motor should be stepped.
int hourChange = 0; // the amount of 6 hour to step
int currentDisplay = 0; //current 6hour change reading
int hour0 = 1013; // you can set last 8 hours pressure here or leave at 0 and the
int hour1 = 1014; // readings will catch up over the next 8 hours
int hour2 = 1015;
int hour3 = 1016;
int hour4 = 1016;
int hour5 = 1016;
int hour6 = 1012;
int hour7 = 1013;
int sleep1 = 6;
int sleep2 = 7;

// check air pressure here https://www.meteoplug.com/cgi-bin/meteochart.cgi?draw=a3aeaaa1acbdf9f1fcfed4fedbc2c094c0d6d6d1d2c5edcebbfee9ffeff1fbf9

//int Disp3hrIn = A3;
//int Disp3hrVal =0;

void setup() {
  pinMode(adjustOn, INPUT);
  pinMode(hourPulse, OUTPUT);
  pinMode(highPressureLED, OUTPUT);
  pinMode(lowPressureLED, OUTPUT);
  pinMode(hour6LowLED, OUTPUT);
  pinMode(hour6HighLED, OUTPUT);
  pinMode(manSync, INPUT);
  pinMode(sleep1, OUTPUT);
  pinMode(sleep2, OUTPUT);
  

  pinMode(settingreadPin, INPUT);
  // Set the maximum steps per second:
  stepper.setMaxSpeed(1000);
   stepper2.setMaxSpeed(1000);
   

    lcd.begin(20,4);   // initialize the lcd for 20 chars 4 lines, turn on backlight
     lcd.backlight(); // backlight on not needed as man controlled
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Barometer A988");  //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  lcd.setCursor(0,1); //Start at character 0 on line 1
  lcd.print("    Version 23"); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  
  {
  Wire.begin();
  Serial.begin(9600);  
  // set the initial time here:
  // DS3231 seconds, minutes, hours, day, date, month, year
 //  setDS3231time(10,42,9,5,18,12,19);
//delay(2000);
lcd.clear();
}

Serial.println("REBOOT");// serial removed

  // Initialize the sensor (it is important to get calibration values stored on the device).


  if (pressure.begin())
    Serial.println("BMP180 init success");// serial removed
  else
  {
    // Oops, something went wrong, this is usually a connection problem,
    // see the comments at the top of this sketch for the proper connections.

    Serial.println("BMP180 init fail\n\n");// serial removed
    while(1); // Pause forever.
  }

  //LED Test
digitalWrite(hour6HighLED, HIGH);
delay (500);
digitalWrite(hour6HighLED, LOW);

digitalWrite(hour6LowLED, HIGH);
delay (500);
digitalWrite(hour6LowLED, LOW);

digitalWrite(highPressureLED, HIGH);
delay (500);
digitalWrite(highPressureLED, LOW);


digitalWrite(lowPressureLED, HIGH);
delay (500);
digitalWrite(lowPressureLED, LOW);
delay (500);

lcd.clear();

getPressure ();// gets all pressure readings

// Disp readings on startup so hands can be set
    lcd.setCursor(0,1);
    lcd.print("  ");
    lcd.setCursor(0,1);
    lcd.print("H");
    lcd.print(hourcalc);

   lcd.setCursor(2,1);
    lcd.print("      ");
    lcd.setCursor(2,1);
   lcd.print("Old");
   lcd.print(currentDisplay);

   lcd.setCursor(13,1);
   lcd.print("       ");
   lcd.setCursor(13,1);
   lcd.print("Disp");
   lcd.print(hourDiff);

   

//disable motors on startup
digitalWrite(sleep1, HIGH);
digitalWrite(sleep2, HIGH);
stepper.disableOutputs();
stepper2.disableOutputs();


// test = 1; // test set to 0 off 1 on

}







void loop() {
   
if( digitalRead(adjustOn) == HIGH || adjustLock == 1)// only alow settings when change settings switch is ON
{
 //digitalWrite(sleep1, LOW);//enable on
 //digitalWrite(sleep2, LOW);//enable on only enable outputs for 2 mins
 Settings(); //set what function the setiing switches have
 adjustLock = 1; //hold on adjustment

 
if( digitalRead(adjustOn) == LOW)
{
//digitalWrite(sleep1, HIGH);//disable on
//digitalWrite(sleep2, HIGH);//enable on only enable outputs for 2 mins

adjustLock = 0; //hold on adjustment  
}
 
  }// only allow settings change when setting switch is on
  

 // displayTime(); // display the real-time clock data on the Serial Monitor,
    byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);



//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

 


//enable air pressure readings 
 if (minute == 9 || minute == 19 || minute == 29 || minute == 39 || minute == 49 || minute == 59 && second == 59)
 {
 
 checkStop = 0;// resets checkstop to allow air pressure readings every 10 mins
 
 }


//check air pressure every 10 mins
 if (checkStop == 0)
 { 
 if ( minute == 0 || minute == 10 || minute == 20 || minute == 30 || minute == 40 || minute == 50 )
 {
 //digitalWrite(sleep1, LOW);//enable on -only enable outputs for 1 min // only sleep1 needs activation 
  
 getPressure ();// gets all pressure readings
 checkStop = 1;// stops multiple readings of air pressure
 }


// else 
 //digitalWrite(sleep1, HIGH);//enable off
 // Serial.print("Sleep 1 HIGH (off) ");
   //    Serial.println(hourChange);
 
 }
 
 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@



if(digitalRead(manSync)==HIGH)// resets seconds to 30
{
 setDS3231time(30, minute, hour, dayOfWeek, dayOfMonth, month, year); //Set seconds to 30 on RTC 
 
}

  // counts seconds
 secondNow = second; 
 if(secondNow!=secondPrevious || initial)
  {
    
    
    lcd.setCursor(0,0);
    lcd.print("UTC ");
    
    if(hour<10)
    {
      lcd.print(0);
    }
    lcd.print(hour);
    
    lcd.print(":");
   
    
    if(minute<10)
    {
      lcd.print(0);
    }
    lcd.print(minute);
   
    lcd.print(":");
    
    if(second<10)
    {
      lcd.print(0);
    }
    lcd.print(second);
    lcd.print("  ");

  
 //   Serial.print("-1*0 ");
//  Serial.println(-1*0);

   

   
    initial = 0;
    secondPrevious = secondNow; 
  } 

  
  
  
  // count minutes
  minuteNow = minute;
 if(minuteNow!=minutePrevious || initial)  //settingVal < 690 stops clock motors operating when setting RTC
  {
    initial = 0;
    minutePrevious = minuteNow;
  // digitalWrite(minPulse,HIGH);//1 min pulse for seconds display sync
    syncStop = 0;// clock will not sync again untill a new minute has started.
  //  digitalWrite(minPulse,LOW);//1 min pulse for seconds display sync

 
  }
  
// counts hours + 1min for hourPulse at 15 seconds past the hour this allows barometer and 6 hour dial to step first

 
 if ( minute == 0 && second == 15) // send hour pulse 15 seconds past the hour to 3 hour circuit allows other motors to stop
 {
 digitalWrite(hourPulse,HIGH);
 digitalWrite(highPressureLED,HIGH);
 
 // Serial.println("hourPulse Hi ");
  

 
 }

 else if (minute != 1 || second != 0)
 {
 
digitalWrite(hourPulse,LOW);
digitalWrite(highPressureLED,LOW);

 }


// counts hours
  hourNow = hour;
 if ((minute == 59 && second > 50) || (minute == 0 && second <10) )// allows change on the hour only
 {
//  digitalWrite(sleep2, LOW);// enable 6hr motor
 if(hourNow!=hourPrevious || initial) //settingVal < 690 stops clock motors operating when setting RTC
  {
    initial = 0;
    hourPrevious = hourNow;
//print hour stores every hour
    // serial removed
    /*
     Serial.print("hour0 ");
  Serial.println(hour0);

  Serial.print("hour1 ");
  Serial.println(hour1);

  Serial.print("hour2 ");
  Serial.println(hour2);

  Serial.print("hour3 ");
  Serial.println(hour3);

  Serial.print("hour4 ");
  Serial.println(hour4);

  Serial.print("hour5 ");
  Serial.println(hour5);

  Serial.print("hour6 ");
  Serial.println(hour6);

  Serial.print("hour7 ");
  Serial.println(hour7);
  */
    //##############################################################################
//step 6 hour motor
if (hourChange > 0 && hourChange < 40) // 6 hour motor will not step if diff > 10
     {
     stephourFwd();
     
         //Serial.print("Step 6 hour Forward ");// serial removed
        // Serial.println(hourChange);// serial removed
         hourChange = 0;
     }
     else if (hourChange < 0 && hourChange > -40)
     // else if (hourDiff ==-1 || test == 1)
     {
       
       
      stephourBwd();
     // Serial.print("Step 6 Hour Backward ");// serial removed
     //  Serial.println(hourChange);// serial removed
     hourChange = 0;
     
      
     }

     
    
         
    
 // hourChange = 0;
  
//##############################################################################
    
  
 
  }

  
 // digitalWrite(sleep2, HIGH);// disable 6hr motor
// add LCD stop
  if(second== 0)
  {
 // lcd.setCursor(0,1);
 //lcd.print("                    ");
 
    lcd.setCursor(0,1);
    lcd.print("  ");
    lcd.setCursor(0,1);
    lcd.print("H");
    lcd.print(hourcalc);

   lcd.setCursor(2,1);
    lcd.print("      ");
    lcd.setCursor(2,1);
   lcd.print("Old");
   lcd.print(currentDisplay);

   lcd.setCursor(13,1);
   lcd.print("       ");
   lcd.setCursor(13,1);
   lcd.print("Disp");
   lcd.print(hourDiff);
 

   
   

   
  }
 }


    
  }




 // Set Clock/Motors###################################################################################################
//gets advance retard settings from pot
void Settings()
{
  
  
 settingVal = analogRead(settingreadPin);    // read the value from the pot

  if ( settingVal >= 0 && settingVal < 85 )
  {
    setMinsfwd();
     
    
    
  }

 

 if ( settingVal >= 85 && settingVal < 170 )
  {
    setMinsbwd();
     
  }

  if ( settingVal >= 170 && settingVal < 255 )
  {
    setMinsslowfwd();
    
  }

   if ( settingVal >= 255 && settingVal < 340 )
  {
   setMinsslowbkd();
    
  }

    if ( settingVal >= 340 && settingVal < 425 )
  {
    setHoursfwd();
  }

   if ( settingVal >= 425 && settingVal < 510 )
  {
    setHoursbwd();
  }

  if ( settingVal >= 510 && settingVal < 595 )
  {
    setHoursslowfwd();
  }

  if ( settingVal >= 595 && settingVal < 690 )
  {
    setHourslowbkd();
  }

  if ( settingVal >= 690 && settingVal < 765 )
  {
  setRTCfwdmin();
  }

  if ( settingVal >= 765 && settingVal < 850 )
  {
    setRTCbwdmin();
  }

   if ( settingVal >= 850 && settingVal < 900 )
  {
   setRTCfwd();
  }

  if ( settingVal >= 900 && settingVal < 970 )
  {
   
  setRTCbwd();
    
  }

if ( settingVal >= 970 && settingVal < 1025 )
  {
   
  
    
  }

  
   if ( settingVal >= 0 && settingVal < 85 && LCDstop==0)// LCDstop prevents the LCD from freshing until another item is selected
  {
   
     lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("Barometer Advance");
    LCDstop=1;
    
    
  }


 if ( settingVal >= 85 && settingVal < 170 && LCDstop==1)
  {
    
     lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("Barometer Retard");
    LCDstop=0;
  }

  if ( settingVal >= 170 && settingVal < 255  && LCDstop==0 )
  {
    
     lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("Baro Inch Advance");
    LCDstop=1;
  }

   if ( settingVal >= 255 && settingVal < 340 && LCDstop==1 )
  {
   
    lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("Baro Inch Retard");
    LCDstop=0;
  }

    if ( settingVal >= 340 && settingVal < 425 && LCDstop==0 )
  {

     lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("6Hr Baro Advance");
    LCDstop=1;
  }

   if ( settingVal >= 425 && settingVal < 510 && LCDstop==1 )
  {
   lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("6Hr Baro Retard");

    LCDstop=0;
  }

  if ( settingVal >= 510 && settingVal < 595 && LCDstop==0 )
  {
    lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("6Hr Baro Inch Advn");

    LCDstop=1;
  }

  if ( settingVal >= 595 && settingVal < 690 && LCDstop==1 )
  {
   lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("6Hr Baro Inch Retard");

    LCDstop=0;
  }

  if ( settingVal >= 690 && settingVal < 765 && LCDstop==0)
  {
   lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("RTC Min Advance");
  
    LCDstop=1;
  }

  if ( settingVal >= 765 && settingVal < 850 && LCDstop==1 )
  {

  lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("RTC Min Retard");
    LCDstop=0;
  }

   if ( settingVal >= 850 && settingVal < 900 && LCDstop==0 )
  {

    lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("RTC Hour Advance");
    
    LCDstop=1;
  }

  if ( settingVal >= 900 && settingVal < 970 && LCDstop==1 )
  {
  lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("RTC Hour Retard");

    LCDstop=0;
  }

 if ( settingVal >= 970 && settingVal < 1025 && LCDstop==0 )
  {
  lcd.setCursor(0,1);
     lcd.print("                    ");
     lcd.setCursor(0,1);
    lcd.print("OFF");

    LCDstop=1;
  }


 }
// END of Loop


// set RTC min forward 1 min per press ##################################################################################
void setRTCfwdmin()
{
   if( digitalRead(changeSetting) == HIGH && stepoffRTCminfwd == 0 )
   {
    
    byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
   minute = minute+1;  
  if (minute == 60)
  {
    minute = 0 ;
  }
  
  
     setDS3231time(second, minute, hour, dayOfWeek, dayOfMonth, month, year); //Set seconds to 30 on RTC
    stepoffRTCminfwd = 1;
   }
   if( digitalRead(changeSetting) == LOW )
   {
    stepoffRTCminfwd = 0;
   }
}


//##################################################################################

// set RTC min backward 1 min per press ##################################################################################
void setRTCbwdmin()
{
   if( digitalRead(changeSetting) == HIGH && stepoffRTCminbwd == 0 )
   {
    
    byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
     
  minute = minute-1;
   if (minute <1)
  {
    minute = 59 ;
  }
 
  
     setDS3231time(second, minute, hour, dayOfWeek, dayOfMonth, month, year); //Set seconds to 30 on RTC
    stepoffRTCminbwd = 1;
   }
   if( digitalRead(changeSetting) == LOW )
   {
    stepoffRTCminbwd = 0;
   }
}


//##################################################################################






//###################################################################################################


// set RTC hour forward 1 hour per press ##################################################################################
void setRTCfwd()
{
   if( digitalRead(changeSetting) == HIGH && stepoffRTChourfwd == 0 )
   {
    
    byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
     
  hour = hour+1;
     setDS3231time(second, minute, hour, dayOfWeek, dayOfMonth, month, year); //Set seconds to 30 on RTC
    stepoffRTChourfwd = 1;
   }
   if( digitalRead(changeSetting) == LOW )
   {
    stepoffRTChourfwd = 0;
   }
}


//##################################################################################

// set RTC hour backward 1 hour per press ##################################################################################
void setRTCbwd()
{
   if( digitalRead(changeSetting) == HIGH && stepoffRTChourbwd == 0 )
   {
    
    byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
     
  hour = hour-1;
     setDS3231time(second, minute, hour, dayOfWeek, dayOfMonth, month, year); //Set seconds to 30 on RTC
    stepoffRTChourbwd = 1;
   }
   if( digitalRead(changeSetting) == LOW )
   {
    stepoffRTChourbwd = 0;
   }
}


//##################################################################################


// set Minutes Motor forward 1 min per press ##################################################################################
void setMinsfwd()
{
  //digitalWrite(sleep1, LOW);
   //stepper.enableOutputs();
// step minutes 1 min per press
   if( digitalRead(changeSetting) == HIGH && stepoffMin == 0 )
   {
     //Serial.println("Step Forward Man");// serial removed
    stepoffMin = 1;
    stepminsFwd();
   }
   if( digitalRead(changeSetting) == LOW )
   {
    stepoffMin = 0;
   }
//digitalWrite(sleep1, HIGH);
   //stepper.disableOutputs();

}
//##################################################################################








// set Minutes Motor backward  1 min per press ##################################################################################
void setMinsbwd()
{
  //digitalWrite(sleep1, LOW);
  // stepper.enableOutputs();
  
  if( digitalRead(changeSetting) == HIGH && stepoffMinbwd == 0 )
   {
   // Serial.println("Step Backward Man");// serial removed
    stepoffMinbwd = 1;
   stepminsBwd();
   }
   if( digitalRead(changeSetting) == LOW )
   {
    stepoffMinbwd = 0;
   }

//digitalWrite(sleep1, HIGH);
  // stepper.disableOutputs();
}

//##################################################################################



// step minutes slow forward const press ##################################################################################


void setMinsslowfwd()
{
   stepper.enableOutputs();
   digitalWrite(sleep1, LOW);
   if( digitalRead(changeSetting) == HIGH )
   {
   // Serial.println("Step Baro Inch Forward Man");// serial removed
   stepper.setCurrentPosition(0);
 
  // Run the motor forward at 500 steps/second until the motor reaches 4096 steps (1 revolution):
  while (stepper.currentPosition() != 1) {  //was 52     52x60 =3120
    stepper.setSpeed(50);
    stepper.runSpeed();
    
  }
 
   /*
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, LOW);
    digitalWrite(motorPin3, LOW);
    digitalWrite(motorPin4, LOW);
*/
   }
   digitalWrite(sleep1, HIGH);
   stepper.disableOutputs();

}


//##################################################################################

// step minutes slow backward const press ##################################################################################


void setMinsslowbkd()
{
  stepper.enableOutputs();
  digitalWrite(sleep1, LOW);
   if( digitalRead(changeSetting) == HIGH )
   {
    // Serial.println("Step Baro Inch Backward Man");// serial removed
   stepper.setCurrentPosition(0);
 
  // Run the motor forward at 500 steps/second until the motor reaches 4096 steps (1 revolution):
  while (stepper.currentPosition() != -1) {  //was 52     52x60 =3120
    stepper.setSpeed(-50);
    stepper.runSpeed();
    
  }
      /*
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, LOW);
    digitalWrite(motorPin3, LOW);
    digitalWrite(motorPin4, LOW);
*/
   }
   digitalWrite(sleep1, HIGH);
   stepper.disableOutputs();

}


//##################################################################################

// set Hour Motor forward 1 hour per press ##################################################################################
void setHoursfwd()
{
 // stepper2.enableOutputs();
 // digitalWrite(sleep2, LOW);
  
 // step hours 1 hour per press
   if( digitalRead(changeSetting) == HIGH && stepoffHour == 0 )
   {
    // Serial.println("Step 6hr Forward Man");// serial removed
    stepoffHour = 1;
    stephourmanFwd();
   }
 //  stepper2.disableOutputs();
 //  digitalWrite(sleep2, HIGH);

if( digitalRead(changeSetting) == LOW )
   {
    stepoffHour = 0;
   
   }
...

This file has been truncated, please download it to see its full contents.

BarometerA4988_3hour__21.ino

Arduino
File for 3 hour display and forecasting
/* Example sketch to control a 28BYJ-48 stepper motor with ULN2003 driver board, AccelStepper and Arduino UNO: number of steps/revolutions. More info: https://www.makerguides.com 
v4 added presure extreme LEDs
v5 add forcast LEDs and calc
v6 sorted enable and sleep order
v7 remove adjust on and test replace it with Clearing and threatening LEDs PIN 12 and 13 
v8 add dac driver-deleted
v9 added LCD
v10 added weather forecast usingLEDs 
v12 LEds test added
v13 add 1 dp point to 3 hour display
v14 void 1026 add slow set buttons
v18 voided 
v19last reading not included in number of steps
v20 change led test order
v20a serial.print removed indicated by // serial removed
v21 as 20a identical to v20 that includes serial print

*/
#include <SFE_BMP180.h> //SFE_BMP180 pressure sensor
#include <SPI.h>
#include <LiquidCrystal_I2C.h>


// ######## You will need to create an SFE_BMP180 object, here called "pressure":

SFE_BMP180 pressure;

#define ALTITUDE 125.0 // Altitude of Kenley Surrey in meters

//#########

//**********************
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

//#define DS3231_I2C_ADDRESS 0x68
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}


// Include the AccelStepper library:
#include <AccelStepper.h>

// Define stepper motor connections and motor interface type. Motor interface type must be set to 1 when using a driver:
#define dirPin 11
#define stepPin 10


#define motorInterfaceType 1
// Create a new instance of the AccelStepper class:
AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);



float seaPressure = 0;
float pressureNow = 0;
float pressurePrevious = 0;
float pressureDiff = 0;
int checkStop = 0;
//int pressureRndDiff = 0;
int pressureRndNow =0;
int pressureRndPrevious =0;
int adjustOn = 12; // allows adjustment of barometer
// int test = 0; // test mode 0 off 1 is on

char status;
  double T,P,a;

//int h =0;
//int m = 0;
//int j = 0;
int stepcount = 0;
//int time = 0;
//int resetmins = 1;
//int secondNow = 0;
//int secondPrevious=0;
//int minuteNow = 0;
//int minutePrevious=0;
//int hourNow = 0;
//int hourPrevious=0;
int initial = 0;
int initial1 = 0;
int initial3 = 0;
//int sync30 = 3;//30sec sync on pin18
//int syncLED = 15;
//int manSync = 12;
//int adjustOn = 12;
//int syncStop = 0;
//int sync30Stop = 0;
int stepoffHour = 0;
int stepoffHourbkw = 0;
int stepoffMin = 0;
int stepoffMinbwd = 0;
//int stepoffRTCminfwd = 0;
//int stepoffRTCminbwd = 0;
//int stepoffRTChourfwd = 0;
//int stepoffRTChourbwd = 0;
//int settingreadPin = A3; //Pin for sensing analogue value from pot
//int settingVal = 0; // Analogue value 0-1023
int LCDstop = 0; // stops settings on LCD display refreshing until they change
int hourPulse = 3; //hour pulse from main Barometer Arduino
int adjustLock = 0; // turns off adjust lock
int hourcalc = 0;
float hourDiff = 0.50; // used to check if 3hour previous motor should be stepped.
float hourChange = 0.00; // the amount of 3 hour to step float value
int hourStep = 0; //the amount of 3 hour to step
int  hourStepdigit1 = 0; // gets the 1st digit from hourstep
int  hourStepdigit2 = 0; // gets the 2nd digit from hourstep
int stepTotal = 0; // tptal amount of steps for 3 hour motor
int  hourChangeNeg = 0;// if hour change is -ve this stores the value to chenge stepTotal later
float currentDisplay = 0.50; //current 3hour change reading
float hour0 = 1036.00; // you can set last 3 hours pressure here or leave at 0 and the
float hour1 = 1036.00; // readings will catch up over the next 4 hours
float hour2 = 1036.00;
float hour3 = 1036.00;
float hour4 = 1036.00;

//check readings https://www.meteoplug.com/cgi-bin/meteochart.cgi?draw=a3aeaaa1acbdf9f1fcfed4fedbc2c094c0d6d6d1d2c5edcebbfee9ffeff1fbf9
int sleep = 9;
int hourPulseOff = 0;
//int testinput = 17;
int testpulse = 0;
int hourPlus1min = 0;
int stepFwd1 = 14;
int manstepFwd1 = 0;
int maninchFwdBwd = A7;
int stepBwd1 = 15;
int manstepBwd1 = 0;
int hour3LowLED = 5;// Green low range LED
int hour3HighLED = 4;//Red high range LED
int ledStormy = 8;
int ledRain = 7;
int ledChange = 6;
int ledFair = 2;
int ledDry = 13;
int ledClear = 12;
int ledThreat = 17;
int ledNoChange = 16;

//Test
int n = 0;
int n1 =0;
int n2 =0;





void setup() {

  
  pinMode(ledStormy, OUTPUT);
  pinMode(ledRain, OUTPUT);
  pinMode(ledChange, OUTPUT);
  pinMode(ledFair, OUTPUT);
  pinMode(ledDry, OUTPUT);
  pinMode(ledClear, OUTPUT);
  pinMode(ledThreat, OUTPUT);
  pinMode(ledNoChange, OUTPUT);
  
   pinMode(stepFwd1, INPUT);
   pinMode(stepBwd1, INPUT);
 // pinMode(adjustOn, INPUT);
  pinMode(hourPulse, INPUT);
  pinMode(hour3LowLED, OUTPUT);
  pinMode(hour3HighLED, OUTPUT);
  pinMode(sleep, OUTPUT);
 
  

 // pinMode(settingreadPin, INPUT);
  // Set the maximum steps per second:
  stepper.setMaxSpeed(1000);


  
  lcd.begin(20,4);   // initialize the lcd for 20 chars 4 lines, turn on backlight
     lcd.backlight(); // backlight on not needed as controlled by 7 MAX2719
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Barometer A988 3 Hr");  //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  lcd.setCursor(0,1); //Start at character 0 on line 0
  lcd.print("    Version 20"); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
  


  
  {
 // Wire.begin();
  Serial.begin(9600);
 
delay(2000);
lcd.setCursor(0,2); //Start at character 0 on line 0
  lcd.print("##### LED TEST #####"); //@@@@@@@@

}
//#############################################################
Serial.println("REBOOT v08");
//############################################################

  // Initialize the sensor (it is important to get calibration values stored on the device).

  if (pressure.begin())
    Serial.println("BMP180 init success");
  else
  {
    // Oops, something went wrong, this is usually a connection problem,
    // see the comments at the top of this sketch for the proper connections.

    Serial.println("BMP180 init fail\n\n");
    while(1); // Pause forever.
  }
// test = 1; // test set to 0 off 1 on
//LED Test
delay (2000);
digitalWrite(ledThreat, HIGH);
delay (500);
digitalWrite(ledThreat, LOW);

digitalWrite(ledNoChange, HIGH);
delay (500);
digitalWrite(ledNoChange, LOW);

digitalWrite(ledClear, HIGH);
delay (500);
digitalWrite(ledClear, LOW);

digitalWrite(ledStormy, HIGH);
delay (500);
digitalWrite(ledStormy, LOW);

digitalWrite(ledRain, HIGH);
delay (500);
digitalWrite(ledRain, LOW);

digitalWrite(ledChange, HIGH);
delay (500);
digitalWrite(ledChange, LOW);

digitalWrite(ledFair, HIGH);
delay (500);
digitalWrite(ledFair, LOW);

digitalWrite(ledDry, HIGH);
delay (500);
digitalWrite(ledDry, LOW);

digitalWrite(hour3HighLED, HIGH);
delay (500);
digitalWrite(hour3HighLED, LOW);

digitalWrite(hour3LowLED, HIGH);
delay (500);
digitalWrite(hour3LowLED, LOW);

 lcd.clear();
 
 getPressure ();// gets all pressure readings
 showLCD(); // load display to LCD
 getForecast(); //get forcast and set LEDs for weather
 
//disable motors on startup
digitalWrite(sleep, HIGH);
stepper.disableOutputs();

 


}







void loop() {
   

 

  

 
   hourPlus1min = (digitalRead(hourPulse));//checks for pulse at 1min past the hour from the barometer
  
    if (hourPlus1min == HIGH && hourPulseOff ==0 || initial1 ) 
  {
    initial1 =0;
    hourcalc++;
   
    if (hourcalc > 4)
    {
    hourcalc = 0;
   
    }
    //Serial.print("hourcalc ");// serial removed
    // Serial.println(hourcalc);// serial removed
  
       
    
   getPressure ();// gets all pressure readings
   getForecast(); //get forcast and set LEDs for weather
   showLCD(); // load display to LCD






  
   hourPulseOff = 1; //turns off 
  }
  else if (hourPlus1min == LOW)
  {
   hourPulseOff = 0;
  }
  adjustLock = 0; //hold on adjustment



// Step forward/back man~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  // step hours 1 hour per press
 manstepFwd1 = digitalRead(stepFwd1);
  

  
if( manstepFwd1 == HIGH && stepoffHour == 0 )
 {
  
    stepoffHour = 1;
    stephourmanFwd();
 
 }
   manstepFwd1 = digitalRead(stepFwd1);

if( manstepFwd1 == LOW )
   {
    stepoffHour = 0;
   }


 
 
 // step hours 1 hour per press
 manstepBwd1 = digitalRead(stepBwd1);

 if( manstepBwd1 == HIGH && stepoffHour == 0 )
 {
  
    stepoffHour = 1;
    stephourmanBwd();
 
 }
   manstepBwd1 = digitalRead(stepBwd1);

 
 if( manstepBwd1 == LOW)
 {
 stepoffHour = 0;
 }
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 //Inch 3hr forward/backwards
maninchFwdBwd= analogRead(A7);


if (maninchFwdBwd >800 )
{
//  Serial.print(" maninchFwdBwd= ");// serial removed
 // Serial.println(maninchFwdBwd);// serial removed
         
  maninchFwd();
   
}

 else if (maninchFwdBwd <200)
 {
   
//  Serial.print(" maninchFwdBwd= ");// serial removed
//  Serial.println(maninchFwdBwd);// serial removed
  maninchBwd();
  
 }

    //##############################################################################

//step 3 hour motor
if (hourChange > 0 && hourChange < 20) // 3 hour motor will not step if diff > 40
     {
     stephourFwd();
     
       //  Serial.print("Step 3 hour Forward ");// serial removed
        // Serial.println(hourChange);// serial removed
         hourChange = 0;
     }
     else if(hourChange < 0 && hourChange > -20)
     
     {
       
       
      stephourBwd();
     // Serial.print("Step 3 Hour Backward ");// serial removed
     //  Serial.println(hourChange);// serial removed
     hourChange = 0;
     
      
     }
    
         
  
//##############################################################################
    
  
 
  


 }


    
  





//##################################################################################


// set Hour Motor backward 1 hour per press ##################################################################################
void setHoursbwd()
{
  // digitalWrite(sleep, LOW);
//  stepper.enableOutputs();

 // step hours 1 hour per press
   if( digitalRead(adjustOn) == HIGH && stepoffHourbkw == 0 )
   {
   // Serial.println("Step 3hr Backward Man");
    stepoffHourbkw = 1;
    stephourmanBwd();
   }
//   stepper.disableOutputs();
//   digitalWrite(sleep, HIGH);

if( digitalRead(adjustOn) == LOW )
   {
    stepoffHourbkw = 0;
   
   }
//  End step hours 1 hour per press


}
//##################################################################################




// step hours slow forward const press ##################################################################################


void  maninchFwd()
{
  stepper.enableOutputs();
  digitalWrite(sleep, LOW);
   if( digitalRead(adjustOn) == HIGH )
   {
  //  Serial.println("Step 3hr Inch Forward Man");// serial removed
   stepper.setCurrentPosition(0);
 
  // Run the motor forward at 500 steps/second until the motor reaches 8 steps (1 revolution):
  while (stepper.currentPosition() != 1) {  //was 52     52x60 =3120
    stepper.setSpeed(10);
    stepper.runSpeed();
    
  }
   
   }
   digitalWrite(sleep, HIGH);
stepper.disableOutputs();
}


//##################################################################################

// step hours slow backward const press ##################################################################################


void  maninchBwd()
{
  stepper.enableOutputs(); 
  digitalWrite(sleep, LOW);
   if( digitalRead(adjustOn) == HIGH )
   {
  // Serial.println("Step 3hr Inch backward Man");// serial removed
   stepper.setCurrentPosition(0);
 
  // Run the motor forward at 500 steps/second until the motor reaches 8 steps (1 revolution):
  while (stepper.currentPosition() != -1) {  //was 52     52x60 =3120
    stepper.setSpeed(-10);
    stepper.runSpeed();
    
  } 
   }
   digitalWrite(sleep, HIGH);
stepper.disableOutputs();
}


//##################################################################################


 //Hour Motor #####################################################################################################
void stephourFwd() // steps hour hand forward 1 hour
{
   stepper.enableOutputs();
 // Serial.println("Step 3 hrs forward auto");// serial removed
   digitalWrite(sleep, LOW);
  stepper.setCurrentPosition(0);
 
  // Run the motor forward at 500 steps/second until the motor reaches 4096 steps (1 revolution):
  while (stepper.currentPosition() != hourChange*160) {  //hourDiff gives the nuber of steps to take
     stepper.setSpeed(400);
     stepper.runSpeed();
  } 
  digitalWrite(sleep, HIGH);
    stepper.disableOutputs(); 
   }
//###############################################################################################################



//Hour Motor #####################################################################################################
void stephourBwd() // steps hour hand backward 1 hour
{
    stepper.enableOutputs();
  //Serial.println("Step 3hrs backward auto");// serial removed
  digitalWrite(sleep, LOW);
 stepper.setCurrentPosition(0);
while ( stepper.currentPosition() != hourChange*160) {
     stepper.setSpeed(-400);
     stepper.runSpeed();
    
}
digitalWrite(sleep, HIGH);
  stepper.disableOutputs();
 }
//###############################################################################################################


//Hour Motor Man Step forward#####################################################################################################
void stephourmanFwd() // steps hour hand forward 1 hour
{
    stepper.enableOutputs();
  digitalWrite(sleep, LOW);
  //Serial.println("Step 3hr forward man");// serial removed
   stepper.setCurrentPosition(0);
 
  // Run the motor forward at 500 steps/second until the motor reaches 4096 steps (1 revolution):
  while ( stepper.currentPosition() != 160) {  
  
     stepper.setSpeed(400);
     stepper.runSpeed();
  } 
    digitalWrite(sleep, HIGH);
     stepper.disableOutputs();
   }
//###############################################################################################################



//Hour Motor Man Step back ward #####################################################################################################
void stephourmanBwd() // steps hour hand backward 1 hour
{
    stepper.enableOutputs();
   digitalWrite(sleep, LOW);
 // Serial.println("Step 3hr backward man");// serial removed
 stepper.setCurrentPosition(0);
while ( stepper.currentPosition() != -160) {

     stepper.setSpeed(-400);
     stepper.runSpeed();
    
}
digitalWrite(sleep, HIGH);
 stepper.disableOutputs();
 }
//###############################################################################################################



void getPressure ()//get all pressure readings checked every 10 mins eg 0 10 20 etc
{
  
if (checkStop == 0)
{
  // If you want sea-level-compensated pressure, as used in weather reports,
  // you will need to know the altitude at which your measurements are taken.
  // We're using a constant called ALTITUDE in this sketch:
  
 // Serial.println();
 // Serial.print("provided altitude: ");
 // Serial.print(ALTITUDE,0);
//  Serial.print(" meters, ");
 // Serial.print(ALTITUDE*3.28084,0);
//  Serial.println(" feet");
  
  // If you want to measure altitude, and not pressure, you will instead need
  // to provide a known baseline pressure. This is shown at the end of the sketch.

  // You must first get a temperature measurement to perform a pressure reading.
  
  // Start a temperature measurement:
  // If request is successful, the number of ms to wait is returned.
  // If request is unsuccessful, 0 is returned.

  status = pressure.startTemperature();
  if (status != 0)
  {
    // Wait for the measurement to complete:
    delay(status);

    // Retrieve the completed temperature measurement:
    // Note that the measurement is stored in the variable T.
    // Function returns 1 if successful, 0 if failure.

    status = pressure.getTemperature(T);
    if (status != 0)
    {
      // Print out the measurement:
    //  Serial.print("temperature: ");
    //  Serial.print(T,2);
   //   Serial.print(" deg C, ");
    //  Serial.print((9.0/5.0)*T+32.0,2);
   //   Serial.println(" deg F");
      
      // Start a pressure measurement:
      // The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
      // If request is successful, the number of ms to wait is returned.
      // If request is unsuccessful, 0 is returned.

      status = pressure.startPressure(3);
      if (status != 0)
      {
        // Wait for the measurement to complete:
        delay(status);

        // Retrieve the completed pressure measurement:
        // Note that the measurement is stored in the variable P.
        // Note also that the function requires the previous temperature measurement (T).
        // (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
        // Function returns 1 if successful, 0 if failure.

        status = pressure.getPressure(P,T);
        if (status != 0)
        {
          // Print out the measurement:
       //   Serial.print("absolute pressure: ");
       //   Serial.print(P,2);
      //    Serial.print(" mb, ");
      //    Serial.print(P*0.0295333727,2);
      //    Serial.println(" inHg");

          // The pressure sensor returns abolute pressure, which varies with altitude.
          // To remove the effects of altitude, use the sealevel function and your current altitude.
          // This number is commonly used in weather reports.
          // Parameters: P = absolute pressure in mb, ALTITUDE = current altitude in m.
          // Result: p0 = sea-level compensated pressure in mb

          seaPressure = pressure.sealevel(P,ALTITUDE); // we're at 160 meters (Kenley, Surrey UK)
         // serial removed
         /*
          Serial.print("relative (sea-level) pressure: ");
          Serial.print(seaPressure,2);
          Serial.print(" mb, ");
          Serial.print(seaPressure*0.0295333727,2);
          Serial.println(" inHg");

         */ 

          

          // On the other hand, if you want to determine your altitude from the pressure reading,
          // use the altitude function along with a baseline pressure (sea-level or other).
          // Parameters: P = absolute pressure in mb, p0 = baseline pressure in mb.
          // Result: a = altitude in m.

          a = pressure.altitude(P,seaPressure);
     //    Serial.print("computed altitude: ");
   //       Serial.print(a,0);
    //      Serial.print(" meters, ");
    //      Serial.print(a*3.28084,0);
    //      Serial.println(" feet");
        }
        else Serial.println("error retrieving pressure measurement\n");
      }
      else Serial.println("error starting pressure measurement\n");
    }
    else Serial.println("error retrieving temperature measurement\n");
  }
  else Serial.println("error starting temperature measurement\n");
}


//Serial.print("hourscalc ");
 // Serial.println(hourcalc);


if (hourcalc == 0)
{
  hour0 = seaPressure;//was rnd sea pressure
  currentDisplay = hourDiff; // the last display reading becomes the old reading called currentDisplay
  hourDiff = hour0 - hour3; // this is the air pressure difference from now to the reading 3 hours ago and wil be displayed onthe 3 hour dial
  
 
  calcCurrentDisp (); // calculates 3 hour Air pressure display
 
}

else if (hourcalc == 1)
{
  hour1 = seaPressure;
  currentDisplay = hourDiff;
    hourDiff = hour1 - hour4;
  

     calcCurrentDisp ();
    
}


else if (hourcalc == 2 )
{
  hour2 = seaPressure;
  currentDisplay = hourDiff;
hourDiff = hour2 - hour0;


 calcCurrentDisp ();
     
}

else if (hourcalc == 3 )
{
  hour3 = seaPressure;
  currentDisplay = hourDiff;
  hourDiff = hour3 - hour1;
 

   calcCurrentDisp ();
    
}

else if (hourcalc == 4 )
{
  hour4 = seaPressure;
  currentDisplay = hourDiff;
   hourDiff = hour4 - hour2;

 

    calcCurrentDisp ();
    
}

//show 3 hour pressure scale hi/low LEDs

if(hourDiff > 9 || hourDiff < -9) // if 3 hour pressure is outside of extended range both hi and low range leds light
{
digitalWrite( hour3HighLED, HIGH);
  digitalWrite( hour3LowLED, HIGH);
}
else if(hourDiff >= 4.80)
 {
  digitalWrite( hour3HighLED, HIGH);
  digitalWrite( hour3LowLED, LOW);
 }

 else if (hourDiff <= -4.80)
 {
  digitalWrite( hour3LowLED, HIGH);
  digitalWrite( hour3HighLED, LOW);
 }

 else if ( hourDiff <4.80 && hourDiff >-4.80 )
 {
 digitalWrite( hour3LowLED, LOW);
 digitalWrite( hour3HighLED, LOW);
 }

 

// Serial.print("currentDisplay (old) ");// serial removed
 // Serial.println(currentDisplay);// serial removed

//  Serial.print("3 hour display to show ");// serial removed
// Serial.println(hourDiff);// serial removed
//Serial.print("RND seaPressure ");
//Serial.println(round(seaPressure));

//get pressure change and show change over 1 hour on LCD bottom row
  pressureNow = seaPressure ;

  if ( pressureNow != pressurePrevious || initial )
  {
     initial = 0;
     pressureDiff = pressureNow - pressurePrevious;

     //Print pressure and diff on LCD
     lcd.setCursor(0,3);
    
    if (pressurePrevious == 0.00)
    {
      pressurePrevious =  pressureNow ;// shows previous pressure at startup
    }
     
     
     if(pressurePrevious<1000)
    {
      lcd.print(0);
    }
    lcd.print(pressurePrevious);// shows previous pressure until 1hPa change

    lcd.print("hPa  ");

   // pressurePrevious =  pressureNow ;
    
     lcd.setCursor(12,3);
     lcd.print("        ");//blank section
     lcd.setCursor(12,3);
     lcd.print(pressureDiff);

     // show rounded pressure reading on display updayes every hour
   
     lcd.setCursor(0,2);
      lcd.print("           ");
    // show rounded pressure on lcd
    lcd.setCursor(0,2);
    if(pressureNow<1000)
    {
      lcd.print(0);
    }
   lcd.print(round(pressureNow));
  


  }
  pressureRndPrevious =  pressureRndNow ;
  pressurePrevious =  pressureNow ;//resets pressure change


//#################################################################################

 
  }


  //####################################################################
// show forecast on LEDs

/*
 Predicting the Weather With the Barometer
More specifically, a barometer with readings in hPa can be interpreted in this manner:

If the reading is over 1022 hPa 

Rising or steady pressure means continued fair weather.
Slowly falling pressure means fair weather.
Rapidly falling pressure means cloudy and warmer conditions.


If it falls between 1009–1022 hPa 

Rising or steady pressure means present conditions will continue.
Slowly falling pressure means little change in the weather.
Rapidly falling pressure means that rain is likely, or snow if it is cold enough.


If the reading is under (1009 hPa

Rising or steady pressure indicates clearing and cooler weather.
Slowly falling pressure indicates rain
Rapidly falling pressure indicates a storm is coming.



Rising or Falling slowly

Pressure change of 0.1 to 1 mb in the preceding three hours

Rising or Falling

Pressure change of 1 to 3 mb in the preceding three hours

Rising or Falling quickly

Pressure change of 3 to 6 mb in the preceding three hours

Rising or Falling very rapidly

Pressure change of more than 6.0 mb in the preceding three hours
 */

void getForecast()
{

 //reading is under (1009 hPa
 //Rising or steady pressure indicates clearing and cooler weather
 
  if(seaPressure <1009.00 && hourDiff >=0 )
  {
    ClearforecastLED();// clear all forecast LEDs before changing
   
    digitalWrite( ledChange, HIGH);
    digitalWrite( ledClear, HIGH);

     lcd.setCursor(8,2);
    lcd.print("            ");
    lcd.setCursor(8,2);
     lcd.print("Chg Clearing");

    
    
  }


   //reading is under (1009 hPa
   //Slowly falling pressure indicates rain

  else if(seaPressure <1009.00 && hourDiff <0 && hourDiff >=-1.5 )
   {
    
    ClearforecastLED();
    
    digitalWrite( ledRain, HIGH);
    digitalWrite( ledThreat, HIGH);
    
     lcd.setCursor(8,2);
    lcd.print("            ");
    lcd.setCursor(8,2);
     lcd.print("Rain Threat");
    
   }


    //reading is under (1009 hPa
   //Rapidly falling pressure indicates a storm is coming. 
  
  else if(seaPressure <1009.00 && hourDiff <-1.5 )
   {
  ClearforecastLED();
  digitalWrite( ledStormy, HIGH);
  digitalWrite( ledThreat, HIGH);

   lcd.setCursor(8,2);
    lcd.print("            ");
    lcd.setCursor(8,2);
     lcd.print("Storm Threat");
    
   }
  
 
  
  //1009–1022 hPa
  //Rising or steady pressure means present conditions will continue.
  //Slowly falling pressure means little change in the weather.
  
  else if(seaPressure >= 1009.00 && seaPressure <= 1022.00 && hourDiff >=-1.5 && hourDiff <=1.5 )
   {
  ClearforecastLED();
  digitalWrite( ledNoChange, HIGH);
  digitalWrite( ledFair, HIGH);

   lcd.setCursor(8,2);
    lcd.print("            ");
    lcd.setCursor(8,2);
     lcd.print("Fair No Chge");
    
   }

//1009–1022 hPa
  //Rising rapidly
  //Clearing
  
  else if(seaPressure >= 1009.00 && seaPressure <= 1022.00 && hourDiff >1.5  )
...

This file has been truncated, please download it to see its full contents.

Credits

Brett Oliver

Brett Oliver

1 project • 5 followers

Comments