Me and Arun Dixit Sir had a discussion that humidity sensor error had anchored the whole project therefore he gave me a problem statement that If temperature outside is 40°C and Humidity is 15% and inside polyhouse is 28°C then what is Humidity inside it?

In general we know that relative humidity is how much water vapour is present in air, if we refine further than relative humidity is the amount of water vapor in the air compared to the maximum amount of water vapor the air can hold at a given temperature.

RH (%) = (Actual water vapor pressure / Maximum water vapor pressure at the same temperature or saturated vapour pressure) × 100

Step1: Specific Humidity in air OUTSIDE

Step2: Additional water evaporated in air from cooling pad

Q = (m * Cp * dT)

Humidity Ratio = Q/(4.186 * 540) g/kg = Specific Humidity

Final Specific Humidity = Humidity Ratio + AVP

Procedure to Calculate Humidity Ratio at 100% Relative Humidity

At 100% RH AVP = SVP

**Step 5:** **Inside Relative Humidity**

C++ code for the same procedure

```
#include <iostream>
#include <cmath>
using namespace std;
double calculateSaturationVaporPressure(double temperature) {
// Using Tetens formula
double saturationVaporPressure = 6.11 * pow(10, (7.5 * temperature) / (237.3 + temperature));
return saturationVaporPressure;
}
double calculateActualVaporPressure(double relativeHumidity, double saturationVaporPressure) {
// Calculating actual vapor pressure
double actualVaporPressure = (relativeHumidity / 100) * saturationVaporPressure;
return actualVaporPressure;
}
double calculateMixingRatio(double actualVaporPressure, double atmosphericPressure) {
// Calculating mixing ratio in kg/kg
double mixingRatio = 0.622 * actualVaporPressure / (atmosphericPressure - actualVaporPressure);
return mixingRatio;
}
int main() {
double outsideTemperature; // Temperature in degrees Celsius
cout << "Enter Outside Temperature: ";
cin >> outsideTemperature;
double insideTemperature;
cout << "Enter Inside Temperature: ";
cin >> insideTemperature;
double outsideRelativeHumidity; // Relative Humidity in %
cout << "Enter Outside Relative Humidity: ";
cin >> outsideRelativeHumidity;
double atmosphericPressure = 1008; // Atmospheric pressure in hPa
// Step 1: Calculate Saturation Vapor Pressure
double outsideSaturationVaporPressure = calculateSaturationVaporPressure(outsideTemperature);
// Step 2: Calculate Actual Vapor Pressure
double outsideActualVaporPressure = calculateActualVaporPressure(outsideRelativeHumidity, outsideSaturationVaporPressure);
// Step 3: Calculate Mixing Ratio (Humidity Ratio)
double outsideMixingRatio = calculateMixingRatio(outsideActualVaporPressure, atmosphericPressure);
// Step 4: Convert to Grams per Kilogram
double outsideSpecificHumidity = outsideMixingRatio * 1000; // Convert kg/kg to g/kg
// Output the result
cout << "The specific humidity at " << outsideTemperature << "°C and " << outsideRelativeHumidity
<< "% relative humidity is approximately " << outsideSpecificHumidity << " grams of water vapor per kilogram of dry air (g/kg d.a)." << endl;
float m = 1000;
float Cp = 1.005;
float dT = outsideTemperature - insideTemperature;
float Q = (m * Cp * dT) / (4.186 * 540);
float finalSpecificHumidity = Q + outsideSpecificHumidity;
// Calculate inside relative humidity
double insideSaturationVaporPressure = calculateSaturationVaporPressure(insideTemperature);
double insideActualVaporPressure = calculateActualVaporPressure(100, insideSaturationVaporPressure);
double insideMixingRatio = calculateMixingRatio(insideActualVaporPressure, atmosphericPressure);
double insideSpecificHumidity = insideMixingRatio * 1000; // Convert kg/kg to g/kg
float insideRelativeHumidity = (finalSpecificHumidity / insideSpecificHumidity) * 100;
cout << "Inside Relative Humidity: " << insideRelativeHumidity << endl;
return 0;
}
```

Note: Here pressure is assumed 1008 mbar = 1008hPa and 1atm = 1013.25 at sea level, and this Magnus Teten’s formula has limitations (-40 °C to 50 °C) with 3% error.