Weather Station – RealTime Interface

Hi guys!!! Hope you’re doing well (given the global situation 😷)….

So, let’s pick up where we left off: the last article about the weather station I made a general overview of the software focusing on the main screen or the HomePage.
In this article we will see in more detail another screen (the most interesting): the RealTime.

Questa immagine ha l'attributo alt vuoto; il nome del file è immagine.png
RealTime

Like the HomePage, the RealTime screen also has a menu (located at the bottom of the page) that allows you to access the different features.

Information analysis

Let’s see in detail what information the RealTime screen gives us:

Indicates the outside temperature (also shown in the top bar)

Show external pressure (expressed in millibars)

Indicates air humidity (expressed as a percentage)

Finally, the screen presents another image on the right (in this case clouds) that changes according to some calculations that are made on the value of the detected pressure (actually the algorithm should take into account all three values mentioned above, but at the moment the sensor is placed in the house and then it would not make sense to use the data of temperature and humidity).

Clicking on each image (excluding the one on the right, so the clouds in this case) opens a graph showing the temperature, pressure and humidity trends over a period of about 24 hours.

The algorithm

The algorithm that “sets up” the image, in this case, of the cloud works in a very simple way:


$result = $pression[0] - $pressionThreeHoursAgo[0];

if($pression[0] >= 1013 && $result >= 1) {
    echo "<img src=\"img/sun.png\" style=\"margin-left: 50px;\" height=\"150px\"/>";          //sun
}
elseif ($pression[0] >= 1013 && $result <= -1) {
    echo "<img src=\"img/sunnyCloud.png\" style=\"margin-left: 50px;\" height=\"150px\"/>";   //cloud/sunny
}
elseif ($pression[0] >= 1013 && Abs($result) < 1) {
    echo "<img src=\"img/sun.png\" style=\"margin-left: 50px;\" height=\"150px\"/>";          //sun
}
elseif ($pression[0] < 1013 && $result >= 1) {
    echo "<img src=\"img/cloudy.png\" style=\"margin-left: 50px;\" height=\"150px\"/>";       //cloudy
}
elseif ($pression[0] < 1013 && $result < -1) {
    echo "<img src=\"img/rain.png\" style=\"margin-left: 50px;\" height=\"150px\"/>";         //rain  
}
elseif ($pression[0] < 1013 && Abs($result) < 1) {
    echo "<img src=\"img/cloudy.png\" style=\"margin-left: 50px;\" height=\"150px\"/>";       //cloudy
}

In other words:

SE (current_pressure >= 1013 && current_pressure - pressure_3_hours_ago >= 1)
      SUN
SE (current_pressure >= 1013 && current_pressure - pressure_3_hours_ago <= -1) 
      CLOUD AND SUNNY 
SE (current_pressure >= 1013 && Abs(current_pressure - pressure_3_hours_ago) < 1) 
      SUN 
SE (current_pressure < 1013 && current_pressure - pressure_3_hours_ago >= 1)
      CLOUDY
SE (current_pressure < 1013 && current_pressure - pressure_3_hours_ago < -1)
      RAIN
SE (current_pressure < 1013 && Abs(current_pressure - pressure_3_hours_ago) < 1)
      CLOUDY

Below are the icons that may appear depending on the cases listed above:

Sun
Cloudy
Cloud and Sunny
Rain

As already said the algorithm is very simple, but obviously can be revised and become much more efficient and complex (but for now I have no great need to complicate my life 😂).

Conclusions

As you can see the screenshot is very basic (and for the moment it’s ok) however I already have in mind some improvements I could do maaa… I will leave these ideas for another article 😆

See you soon!!! 🤗