There are two common meanings of “collect [Arduino](https://www.ampheo.com/c/development-board-arduino) weather data”: 1. Measure weather locally with [sensors](https://www.ampheo.com/c/sensors) (temperature / humidity / pressure) 2. Fetch online weather from an API (needs Wi-Fi/Ethernet) Below are both, with the simplest reliable workflows. ![maxresdefault (89)](https://hackmd.io/_uploads/Bk-l9rfrZl.jpg) **A) Collect weather data from sensors (most common)** **1) Pick a sensor** * [DHT22](https://www.ampheo.com/product/part-dht22-26872164)/AM2302: temp + humidity (cheap, OK, slower) * [BME280](https://www.ampheo.com/product/bme280-26836707): temp + humidity + pressure (better “weather station” sensor) * [BMP280](https://www.ampheo.com/product/bmp280-26788793): temp + pressure (no humidity) **2) Wire it** **BME280 (I²C) → Arduino Uno/Nano** * VCC → 3.3V (some breakout boards allow 5V; check yours) * GND → GND * SDA → A4 (Uno/Nano) * SCL → A5 (Uno/Nano) **3) Read + print data in a log-friendly format (CSV)** Print one line per sample (easy to store/log): ``` #include <Wire.h> #include <Adafruit_BME280.h> Adafruit_BME280 bme; void setup() { Serial.begin(115200); if (!bme.begin(0x76)) { // sometimes 0x77 Serial.println("BME280 not found!"); while (1); } Serial.println("ms,tempC,humPct,presshPa"); } void loop() { unsigned long ms = millis(); float t = bme.readTemperature(); float h = bme.readHumidity(); float p = bme.readPressure() / 100.0; // Pa -> hPa Serial.print(ms); Serial.print(","); Serial.print(t, 2); Serial.print(","); Serial.print(h, 2); Serial.print(","); Serial.println(p, 2); delay(2000); } ``` **4) Store the data (choose one)** **Option 1: Log to your laptop (easiest)** Arduino prints CSV → PC saves it to a file (Python is best): ``` import csv, time, serial PORT = "COM5" # Windows: COM5, macOS: /dev/tty.usbserial-xxxx, Linux: /dev/ttyUSB0 BAUD = 115200 ser = serial.Serial(PORT, BAUD, timeout=1) with open("weather_log.csv", "w", newline="") as f: w = csv.writer(f) w.writerow(["pc_time","ms","tempC","humPct","presshPa"]) while True: line = ser.readline().decode(errors="ignore").strip() if not line or line.startswith("ms,"): continue parts = line.split(",") if len(parts) != 4: continue w.writerow([time.strftime("%Y-%m-%d %H:%M:%S"), *parts]) f.flush() print(parts) ``` **Option 2: Log to SD card (standalone)** * Add an SD module + (recommended) RTC module DS3231 for real timestamps * Write the same CSV lines into weather.csv **Option 3: Send wirelessly** Use ESP32/ESP8266 or a Wi-Fi module and publish data to: * MQTT (Home Assistant / Node-RED) * HTTP (your server) * Google Sheets (via a web endpoint) **B) Collect “weather data” from the internet (API)** An Uno/Nano alone can’t call web APIs. You need: * ESP32 / ESP8266, or * [Arduino](https://www.ampheoelec.de/c/development-board-arduino) + Ethernet/Wi-Fi shield Workflow: 1. Connect to Wi-Fi 2. Send HTTP request to a weather API 3. Parse JSON (or simpler: request minimal fields) 4. Store/log the same way (Serial / SD / MQTT) **Quick recommendation** If you want a clean setup with minimal pain: ESP32 + BME280 (local sensing + Wi-Fi logging) is the sweet spot.