Weather forecasting aims to predict the state of the atmosphere at a certain time in a certain place or area. This does not only mean weather phenomena that affect the ground but the entire earth’s atmosphere is considered. A weather forecast is a forecast over a longer period, i.e. over several days or even months, up to an entire season. The possibility of such forecasts is currently still very limited but could become a reality in the near future due to improved observation possibilities.
The data on the current state of the atmosphere comes from a network of ground measuring stations that measure wind speed, temperature, air pressure and humidity, as well as precipitation amounts. In addition, data from weather satellites, commercial aircraft and weather ships are also used. The problem is the irregular distribution of these observations and measurements, as well as the fact that there are relatively few measuring stations in less developed countries and over the oceans.
For reasons of computing time and the large amounts of data generated, the air and water masses involved cannot yet be taken into account with satisfactory accuracy. There are too many individual factors at play, the interplay of which cannot be fully analysed to date and will not be possible in the near future. Therefore, local influences such as mountains and their irregularly shaped slopes, effects of different irradiation due to “incorrectly” calculated cloudiness, vegetation (forest to the field) or rock makeup so much that the accuracy for the next 4 to 7 days decreases considerably. The theoretical limit of the weather forecast is now assumed to be 14 days.
---
In today’s system of weather forecasting, the collected data are sent to a computer through a Data
Acquisition Systems (DAS). Multiple parameters are usually multiplexed, made flat with some algorithm (somewhat like like Kalman Filter stabilizes sensor readings) finally proceeding through a single channel to the computer to show the data.
What the Sensors We Can Use for Arduino-Based Weather Forecasting
For well-known large cities, you can use the Arduino library to fetch weather information from OpenWeather:
1 | https://github.com/Bodmer/OpenWeather |
This method does not require any sensor. However, to calculate the approximate basic weather forecasting around your house (especially in a place away from a larger city), a system can be developed which is simple to design and includes three different sensors with ESP32:
- Temperature & humidity sensor (DHT11)
- Pressure sensor (BMP085) and
- Accelerometer (ADXL-335) (if you make the system with a gas balloon)
You will also need an RTC module (DS1307) and a TFT-Display. If you use a gas balloon (you must check your local laws) to collect the data then you can use the accelerometer module. The data can be recorded and analyzed on a Raspberry Pi or a powerful server or in an Android smartphone. You’ll need the following libraries for Arduino:
- Adafruit BMP085 Library
- Adafruit DHT 11 Library
- Adafruit ST3375 Library
- Adafruit Graphics Library
- RTClib (for Tiny RTC Module)

The diagram is from :
1 | https://www.sciencedirect.com/science/article/pii/S1877050916311437?ref=pdf_download&fr=RR-2&rr=7e64074a3cd4f419 |
Here is a sample sketch:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | // This sketch is written by http://blog.simtronyx.de/en/simple-indoor-climate-monitoring-with-an-arduino-bmp085-dht11-and-a-rtc/ // We have not checked this sketch whether working // This sketch shows the logic which you can follow #include <SPI.h> #include "Adafruit_GFX.h" // Adafruit Grafik-Bibliothek #include "Adafruit_ST7735.h" // Adafruit ST7735-Bibliothek #include <Wire.h> #include "Adafruit_BMP085.h" // Adafruit BMP085-Bibliothek #include "RTClib.h" #include <DHT.h> #define DHTPIN 4 // Zur Messung verwendeter Pin, in unserem Fall also Pin 4 #define DHTTYPE DHT11 // DHT 11 // TFT-Display #define CS 10 // Arduino-Pin an Display CS #define DC 9 // Arduino-Pin an Display A0 #define RST 8 // Arduino Reset-Pin Adafruit_ST7735 tft = Adafruit_ST7735(CS, DC, RST); // Display-Bibliothek Setup RTC_DS1307 RTC; // Tiny RTC Modul Adafruit_BMP085 bmp; // BMP085 DHT dht(DHTPIN, DHTTYPE); // Initialisieren des DHTs DateTime now; DateTime time_old; DateTime date_old; boolean night_mode=true; void setup(void) { // Initialisiere RTC Wire.begin(); RTC.begin(); if (! RTC.isrunning()) { // Aktuelles Datum und Zeit setzen, falls die Uhr noch nicht läuft RTC.adjust(DateTime(__DATE__, __TIME__)); } bmp.begin(); // BMP085 starten dht.begin(); // DHT starten // Display tft.initR(INITR_BLACKTAB); // ST7735-Chip initialisieren display_show(); } float temp=1000; float hum=1000; int32_t pressure=1000; float min_temp=1000; float max_temp=-1000; float min_humidity=1000; float max_humidity=-1000; int32_t min_pressure=1000000; int32_t max_pressure=-1000; int tempct=0; void loop() { DateTime now=RTC.now(); if(now.minute()!=time_old.minute()){ show_time(time_old,true); time_old=now; show_time(time_old,false); } if(now.day()!=date_old.day()){ show_date(date_old,true); date_old=now; show_date(date_old,false); } float t; if(tempct%2==0)t=dht.readTemperature(); else t=bmp.readTemperature(); if(isnan(t)){} else if((int)t!=(int)temp){ show_temp(temp,true); temp=t; if(min_temp>temp)min_temp=temp; if(max_temp<temp)max_temp=temp; show_temp(temp,false); } tempct++; float h = dht.readHumidity(); if(isnan(h)){} else if(h!=hum){ show_hum(hum,true); hum=h; if(min_humidity>hum)min_humidity=hum; if(max_humidity<hum)max_humidity=hum; show_hum(hum,false); } int32_t p=bmp.readPressure(); if(p!=pressure){ show_pressure(pressure,true); pressure=p; if(min_pressure>pressure)min_pressure=pressure; if(max_pressure<pressure)max_pressure=pressure; show_pressure(pressure,false); } delay(10000); } void show_temp(float temp,boolean clear){ int clearcolor=night_mode?ST7735_BLACK:ST7735_WHITE; int textcolor=night_mode?ST7735_WHITE:ST7735_BLACK; byte xs=12; byte ys=66; String htemp=String((int)temp); //byte xss=(temp<10?:temp set_text(xs,ys,htemp,clear?clearcolor:textcolor,3); set_text(xs+(3*htemp.length()*8),ys,"",(clear?clearcolor:textcolor),2); tft.write(247); // das °-Zeichen tft.print("C"); set_text(xs+81,ys+1,String((int)max_temp),clear?clearcolor:ST7735_RED,1); tft.write(247);tft.print("C"); set_text(xs+81,ys+11,String((int)min_temp),clear?clearcolor:ST7735_BLUE,1); tft.write(247);tft.print("C"); } void show_hum(float hum,boolean clear){ int clearcolor=night_mode?ST7735_BLACK:ST7735_WHITE; int textcolor=night_mode?ST7735_WHITE:ST7735_BLACK; byte xs=12; byte ys=96; set_text(xs,ys,String((int)hum)+"%",clear?clearcolor:textcolor,3); set_text(xs+81,ys+1,String((int)max_humidity)+"%",clear?clearcolor:ST7735_GREEN,1); set_text(xs+81,ys+11,String((int)min_humidity)+"%",clear?clearcolor:ST7735_YELLOW,1); } void show_pressure(float pressure,boolean clear){ int clearcolor=night_mode?ST7735_BLACK:ST7735_WHITE; int textcolor=night_mode?ST7735_WHITE:ST7735_BLACK; byte xs=12; byte ys=130; set_text(xs,ys,String((int32_t)pressure)+"Pa",clear?clearcolor:textcolor,1); if(max_pressure>=100000)xs-=8; set_text(xs+68,ys-5,String((int32_t)max_pressure)+"Pa",clear?clearcolor:ST7735_CYAN,1); set_text(xs+68,ys+5,String((int32_t)min_pressure)+"Pa",clear?clearcolor:ST7735_MAGENTA,1);// } String get_day_of_week(uint8_t dow){ String dows=" "; switch(dow){ case 0: dows="So"; break; case 1: dows="Mo"; break; case 2: dows="Di"; break; case 3: dows="Mi"; break; case 4: dows="Do"; break; case 5: dows="Fr"; break; case 6: dows="Sa"; break; } return dows; } void show_time(DateTime now, boolean clear){ int clearcolor=night_mode?ST7735_BLACK:ST7735_WHITE; int textcolor=night_mode?ST7735_WHITE:ST7735_BLACK; tft.setTextColor(clear?clearcolor:textcolor); tft.setTextSize(3); tft.setCursor(21,21); if(now.hour()<10)tft.print(0); tft.print(now.hour(),DEC); tft.print(":"); if(now.minute()<10)tft.print(0); tft.print(now.minute(),DEC); // tft.print(":"); // if(now.second()<10)tft.print(0); // tft.print(now.second(),DEC); } void show_date(DateTime now,boolean clear){ int clearcolor=night_mode?ST7735_BLACK:ST7735_WHITE; int textcolor=night_mode?ST7735_WHITE:ST7735_BLACK; tft.setTextColor(clear?clearcolor:textcolor); tft.setTextSize(1); tft.setCursor(24,47); tft.print(get_day_of_week(now.dayOfWeek())); tft.print(", "); if(now.day()<10)tft.print(0); tft.print(now.day(),DEC); tft.print("."); if(now.month()<10)tft.print(0); tft.print(now.month(),DEC); tft.print("."); tft.print(now.year(),DEC); } void set_text(int x,int y,String text,int color,int size){ tft.setTextSize(size); tft.setCursor(x,y); tft.setTextColor(color); tft.print(text); } void display_show(){ tft.fillScreen(night_mode?ST7735_BLACK:ST7735_WHITE); set_text(2,4,"Raumklimaueberwachung",ST7735_BLUE,1); set_text(14,147,"blog.simtronyx.de",ST7735_GREEN,1); time_old=date_old=RTC.now(); show_time(time_old,false); show_date(date_old,false); } |
You can also include soil moisture sensor and rain sensor.