Intelligent Greenhouse Monitoring System
The AgriSheild works with advance LLM + Gallileo
Devices & Components
1
Arduino® Nano ESP32
1
Lipo Battery 1200mAh
1
Switch On/Off
1
Solar Panel 6V
1
GNSS GPS BeiDou Positioning Module with RTC - I2C&UART
1
Ethernet Cable
2
In-Line Adapter, RJ45
1
AHT10
1
SparkFun Sunny Buddy - MPPT Solar Charger
Hardware & Tools
1
Computer: Desktop PC (for coding and compiling)
1
Soldering Iron
1
3D printer
Software & Tools
Arduino IDE
1
Fusion 360
1
Blender
1
VSCODE
1
Android Studio
Project description
Code
Code
python
This is a demo code
1import requests 2import math 3import time 4import json 5from collections import deque 6 7# Placeholder for sensor readings (simulate hardware) 8class SensorSimulator: 9 def __init__(self): 10 self.temperature = 25.0 11 self.humidity = 60.0 12 self.history_size = 10 13 self.temp_history = deque(maxlen=self.history_size) 14 self.vpd_history = deque(maxlen=self.history_size) 15 self.temp_trend = 0.0 16 self.vpd_trend = 0.0 17 18 def read_sensors(self): 19 # Simulate reading from sensors 20 self.temperature += (time.time() % 10 - 5) / 10 # Random fluctuation 21 self.humidity += (time.time() % 8 - 4) / 10 22 self.temperature = max(10, min(35, self.temperature)) 23 self.humidity = max(30, min(90, self.humidity)) 24 25 svp = 0.6108 * math.exp(17.27 * self.temperature / (self.temperature + 237.3)) 26 avp = svp * (self.humidity / 100.0) 27 vpd = svp - avp 28 29 self.temp_history.append(self.temperature) 30 self.vpd_history.append(vpd) 31 32 avg_temp = sum(self.temp_history) / len(self.temp_history) 33 avg_vpd = sum(self.vpd_history) / len(self.vpd_history) 34 self.temp_trend = self.temperature - avg_temp 35 self.vpd_trend = vpd - avg_vpd 36 37 return self.temperature, self.humidity, vpd 38 39# Placeholder for weather fetch (use open API or simulate) 40def fetch_weather(latitude=0.0, longitude=0.0): 41 # Placeholder API key and URL (replace with actual for real use) 42 api_key = "YOUR_API_KEY_HERE" 43 url = f"https://api.weatherapi.com/v1/forecast.json?key={api_key}&q={latitude},{longitude}&days=2" 44 45 # Simulate response 46 return { 47 "current": {"temp_c": 25.0, "humidity": 60, "wind_kph": 10, "condition": {"text": "Clear"}}, 48 "location": {"name": "City", "country": "Country"}, 49 "forecast": {"forecastday": [{"day": {"maxtemp_c": 30, "mintemp_c": 20, "daily_chance_of_rain": 10, "maxwind_kph": 15, "condition": {"text": "Sunny"}}}]} 50 } 51 52# Logic for generating condition code (no specific advice text) 53def generate_condition_code(temperature, humidity, vpd, temp_trend, vpd_trend, forecast): 54 risk = (abs(temperature - 23.0) * 3.0) + (abs(vpd - 1.0) * 35.0) + (abs(humidity - 60.0) * 1.2) 55 forecast_max_temp = forecast["forecast"]["forecastday"][0]["day"]["maxtemp_c"] 56 forecast_min_temp = forecast["forecast"]["forecastday"][0]["day"]["mintemp_c"] 57 chance_of_rain = forecast["forecast"]["forecastday"][0]["day"]["daily_chance_of_rain"] 58 forecast_wind = forecast["forecast"]["forecastday"][0]["day"]["maxwind_kph"] 59 60 condition_code = 0 61 62 if risk > 85: 63 condition_code = 1 64 elif risk > 65: 65 condition_code = 15 66 elif risk > 40: 67 condition_code = 16 68 elif temperature > 33: 69 condition_code = 2 70 elif temperature > 29: 71 condition_code = 17 72 elif temperature > 25 and forecast_wind > 25: 73 condition_code = 36 74 elif temperature < 14: 75 condition_code = 3 76 elif temperature < 18 and humidity > 70: 77 condition_code = 18 78 elif temperature < 10 and forecast_min_temp < 5: 79 condition_code = 37 80 elif humidity > 88: 81 condition_code = 4 82 elif humidity > 75: 83 condition_code = 19 84 elif humidity > 80 and temperature < 20: 85 condition_code = 38 86 elif humidity < 45: 87 condition_code = 20 88 elif humidity < 50 and temperature > 25: 89 condition_code = 21 90 elif humidity < 40 and vpd > 1.5: 91 condition_code = 39 92 elif vpd > 1.6: 93 condition_code = 5 94 elif vpd > 1.3: 95 condition_code = 22 96 elif vpd > 1.4 and temperature < 20: 97 condition_code = 40 98 elif vpd < 0.55: 99 condition_code = 6 100 elif vpd < 0.8 and humidity > 80: 101 condition_code = 23 102 elif vpd < 0.6 and chance_of_rain > 50: 103 condition_code = 41 104 elif forecast_max_temp > 32: 105 condition_code = 7 106 elif forecast_max_temp > 28 and chance_of_rain < 30: 107 condition_code = 24 108 elif forecast_max_temp > 30 and forecast_wind > 25: 109 condition_code = 42 110 elif forecast_min_temp < 12: 111 condition_code = 8 112 elif forecast_min_temp < 15 and humidity > 75: 113 condition_code = 25 114 elif forecast_min_temp < 10 and chance_of_rain > 40: 115 condition_code = 43 116 elif forecast_wind > 30: 117 condition_code = 9 118 elif forecast_wind > 20 and temperature < 20: 119 condition_code = 26 120 elif forecast_wind > 25 and humidity < 50: 121 condition_code = 44 122 elif temperature > 30 and humidity < 80 and chance_of_rain < 20: 123 condition_code = 10 124 elif temperature > 25 and vpd > 1.2 and chance_of_rain < 50: 125 condition_code = 27 126 elif temperature > 28 and forecast_max_temp > 28 and risk > 30: 127 condition_code = 45 128 elif chance_of_rain > 60: 129 condition_code = 11 130 elif chance_of_rain > 40 and humidity > 70: 131 condition_code = 28 132 elif chance_of_rain > 50 and vpd < 1.0: 133 condition_code = 46 134 elif temp_trend > 1.8: 135 condition_code = 12 136 elif temp_trend > 1.0 and forecast_max_temp > 25: 137 condition_code = 29 138 elif temp_trend > 0.5 and humidity < 60: 139 condition_code = 47 140 elif temp_trend < -1.8: 141 condition_code = 30 142 elif temp_trend < -1.0 and forecast_min_temp < 15: 143 condition_code = 48 144 elif vpd_trend > 0.4: 145 condition_code = 13 146 elif vpd_trend > 0.2 and humidity < 60: 147 condition_code = 31 148 elif vpd_trend > 0.3 and forecast_wind > 20: 149 condition_code = 49 150 elif vpd_trend < -0.4: 151 condition_code = 14 152 elif vpd_trend < -0.2 and temperature < 20: 153 condition_code = 32 154 elif vpd_trend < -0.3 and chance_of_rain > 30: 155 condition_code = 50 156 elif temperature > 22 and temperature < 30 and vpd > 0.8 and vpd < 1.3: 157 condition_code = 33 158 elif temperature > 32: 159 condition_code = 34 160 elif temperature < 15: 161 condition_code = 35 162 elif temperature > 20 and temperature < 25 and humidity > 60 and humidity < 70: 163 condition_code = 51 164 elif risk < 20 and abs(temp_trend) < 0.5 and abs(vpd_trend) < 0.2: 165 condition_code = 52 166 else: 167 condition_code = 0 168 169 return condition_code 170 171# Simulated main loop 172def main(): 173 sensor = SensorSimulator() 174 latitude, longitude = 0.0, 0.0 # Placeholder GNSS 175 176 while True: 177 temperature, humidity, vpd = sensor.read_sensors() 178 weather_data = fetch_weather(latitude, longitude) 179 condition_code = generate_condition_code(temperature, humidity, vpd, sensor.temp_trend, sensor.vpd_trend, weather_data) 180 181 # Output data (simulate server response) 182 data = { 183 "temperature": temperature, 184 "humidity": humidity, 185 "vpd": vpd, 186 "condition_code": condition_code, 187 # No advice text shown 188 } 189 print(json.dumps(data)) 190 191 time.sleep(5) # Simulate delay 192 193if __name__ == "__main__": 194 main()
Comments
Only logged in users can leave comments