Lessons and the learning game

Build a backyard weather station

A solar weather station on an Uno, and a base station indoors that prints the day.

The finished station

Build a backyard weather station runs every lesson on the same board:

  • The kit: the SparkFun weather meter kit, all reed switches and no electronics. The anemometer is on pin 3 and the rain gauge on pin 2, each to ground on the pin's pull-up; the vane sits under a 10 k pull-up on A0.
  • The air: a BME280 on I2C at 0x76 for temperature, humidity and pressure.
  • The sun: an LTR390 at 0x53 for the UV index and visible light.
  • Power: a solar panel through a 1N5817 diode onto the bus, a 1000 mAh LiPo cell, an INA219 in the battery line, and 47 ohms standing in for the station's draw.
  • The radio: a Ra-02 LoRa module at 433 MHz on SPI: NSS 10, MOSI 11, MISO 12, SCK 13. A green lamp on pin 4 lights as a packet goes out.
  • The base station: a second Arduino Uno with its own Ra-02, always running the base station sketch.

How it works

Wind and rain. One reed closure a second is 2.4 km/h; the sketch times the gaps between clicks on an interrupt. The vane's 16 positions are 16 resistances, matched to the nearest expected reading. Each bucket tip is 0.2794 mm, and a tip within 100 ms of the last is a bounce.

The air. The BME280 library applies the chip's own factory calibration. The dew point comes from the Magnus formula, and the sea-level pressure from the standard atmosphere: p0 = p / (1 - h / 44330)^5.255.

UV. 2300 counts per UV index at gain 18 and 400 ms readings becomes 575 at 100 ms. The band and the time to burn fair skin follow from the index.

Solar power. Panel power times peak sun hours against the station's draw times 24 hours. Awake all the time the budget fails; awake 2 seconds in every 300 it balances with room to spare.

LoRa. 14 bytes, big-endian, with the wind's 12 bits and the vane's 4 sharing two bytes. 46 ms on the air at SF7 and 125 kHz, against 113 ms for the same readings as text. A packet count lets the base station spot losses.

The page. The base station keeps the day's low, high and gust, turns the total tips into millimeters, and prints a page for every packet.

The course

  1. Wind and rain: clicks to km/h, the Beaufort scale, the vane's ladder, and the tipping bucket.
  2. Temperature and pressure: the BME280, the dew point, and the sea-level correction.
  3. UV: counts per UV index, the bands, time to burn, and lux.
  4. Solar power: charging, the daily budget, night, autonomy and sleep.
  5. LoRa uplink: packing, bit packing, time on air, duty cycle and lost packets.
  6. Project: a garden weather page: lows and highs, gusts, rain today and your own height.

Every checked step is tested against the running circuit.