Quick Answer

LoRaWAN lets you deploy weather sensors kilometres away from the nearest gateway β€” on a battery that lasts months or years. A sensor node built around an ESP32 with a LoRa radio module (SX1276 or RFM95W), a BME280, and a rain gauge can transmit readings every 10 minutes while drawing microwatts in sleep mode. This guide in the Tutorials section covers the full stack from sensor node hardware to The Things Network integration and data visualisation.

What This Guide Covers

We will walk through LoRaWAN technology fundamentals (why it suits remote weather sensing), sensor node design and construction, gateway options, The Things Network (TTN) registration and configuration, payload encoding with CayenneLPP, data forwarding to InfluxDB or MQTT, power optimisation for battery operation, and range testing. The techniques here complement the Publishing Fundamentals guide for getting your data from field to dashboard.

Prerequisites

  • Basic electronics skills (soldering, breadboarding)
  • Arduino IDE or PlatformIO installed
  • A LoRaWAN gateway within range, or willingness to set up your own
  • Familiarity with The Things Network console (free account)

Understanding LoRaWAN for Weather

LoRaWAN is a wide-area network protocol designed for low-power, low-bandwidth IoT devices. Key characteristics:

  • Range: 2–15 km line-of-sight, 1–5 km in urban areas
  • Data rate: 0.3–50 kbps (plenty for weather readings)
  • Power: Sleep current under 10 Β΅A on most LoRa modules
  • Duty cycle: Regulatory limits (1% in EU) restrict how often you can transmit

Weather data is a perfect fit for LoRaWAN: small payload sizes, infrequent updates (every 5–15 minutes is fine), and the sensors are often deployed in locations without mains power or Wi-Fi. A single gateway can serve dozens of sensor nodes across a wide area.

Parts List

Component Purpose Approximate Cost
ESP32 + SX1276 module (e.g., TTGO LoRa32 v2.1) Microcontroller with integrated LoRa radio Β£15–25
BME280 breakout Temperature, humidity, pressure Β£8
Tipping-bucket rain gauge Precipitation (reed switch output) Β£15–25
Wind speed + direction sensors (optional) Anemometer and wind vane Β£25–40
868 MHz antenna (SMA) LoRa antenna (tuned) Β£5–10
3.7 V LiPo battery (3000–6000 mAh) Power storage Β£8–15
Small solar panel (1–5 W) Trickle charge Β£8–15
Weatherproof enclosure Protection Β£10

Total: approximately Β£95–150 for a basic temperature/humidity/pressure/rain station.

Step 1: Build the Sensor Node

The TTGO LoRa32 v2.1 is a convenient all-in-one board with an ESP32, SX1276 LoRa transceiver, OLED display, and battery charging circuit. Wire the BME280 via I2C (SDA β†’ GPIO 21, SCL β†’ GPIO 22) and connect the rain gauge reed switch to a GPIO pin with an internal pull-up.

For wind sensors, an anemometer's pulse output connects similarly to the rain gauge (count pulses per interval to calculate speed). The wind vane's analog output needs an ADC reading β€” the ESP32's built-in ADC works but has nonlinearity issues at the extremes; an external ADS1115 on I2C is more reliable.

Step 2: Program the Sensor Node

Using PlatformIO with the LMIC library for LoRaWAN:

#include <lmic.h>
#include <hal/hal.h>
#include <Adafruit_BME280.h>
#include <CayenneLPP.h>

Adafruit_BME280 bme;
CayenneLPP lpp(51);  // max payload size

// TTN device credentials (OTAA)
static const u1_t PROGMEM APPEUI[8] = { /* from TTN console */ };
static const u1_t PROGMEM DEVEUI[8] = { /* from TTN console */ };
static const u1_t PROGMEM APPKEY[16] = { /* from TTN console */ };

void do_send(osjob_t* j) {
    lpp.reset();
    lpp.addTemperature(1, bme.readTemperature());
    lpp.addRelativeHumidity(2, bme.readHumidity());
    lpp.addBarometricPressure(3, bme.readPressure() / 100.0F);
    lpp.addDigitalInput(4, rainCount);  // accumulated tips
    
    LMIC_setTxData2(1, lpp.getBuffer(), lpp.getSize(), 0);
}

CayenneLPP (Cayenne Low Power Payload) is a standardised encoding format that TTN understands natively. It handles unit conversion and data typing automatically, saving you from writing custom decoders.

Set the transmit interval to respect duty cycle limits. In the EU 868 MHz band, the 1% duty cycle means you can transmit for about 36 seconds per hour. A typical weather payload takes under 100 ms to transmit, so a 10-minute interval is well within limits.

Step 3: Deep Sleep for Battery Life

Between transmissions, put the ESP32 into deep sleep:

#define SLEEP_MINUTES 10

void enterDeepSleep() {
    esp_sleep_enable_timer_wakeup(SLEEP_MINUTES * 60 * 1000000ULL);
    esp_deep_sleep_start();
}

In deep sleep, the ESP32 draws about 10 Β΅A. With a 3000 mAh LiPo, that gives months of standby. The active transmit cycle (wake, read sensors, join or send, sleep) takes about 5–10 seconds and draws 100–150 mA. The daily energy budget for 144 transmissions (every 10 minutes) is roughly 50 mAh β€” giving a theoretical battery life of 60 days from a 3000 mAh cell without solar charging.

Add a small 1–2 W solar panel and you have effectively unlimited runtime in any location that gets a few hours of sunlight per day.

Step 4: Gateway Setup

If there is an existing TTN community gateway within range, you can skip this step. Check the TTN gateway map on The Things Network β€” but note that coverage maps are optimistic. Real-world range depends heavily on terrain and obstructions.

Setting up your own gateway:

  • Budget option: RAK Discover Kit (RAK7246) β€” indoor gateway, about Β£100
  • Outdoor option: RAK7249 or Dragino DLOS8 β€” weatherproof, PoE powered, Β£200–400

Configure the gateway with your TTN account credentials and verify it appears online in the TTN console. A properly placed outdoor gateway on a rooftop can cover 5–10 km radius in flat terrain.

Step 5: TTN Console Configuration

  1. Create a new Application in the TTN console
  2. Register your device using OTAA (Over-The-Air Activation)
  3. Copy the AppEUI, DevEUI, and AppKey into your firmware
  4. Set the payload formatter to "CayenneLPP"

Once the device joins and starts transmitting, you will see decoded data in the TTN console's Live Data view. Temperature, humidity, and pressure should appear with correct values and units.

Step 6: Data Forwarding

TTN provides webhook integrations to forward data to external services. Common destinations:

  • MQTT: TTN's built-in MQTT broker at eu1.cloud.thethings.network provides real-time data feeds. Subscribe with any MQTT client.
  • HTTP webhook: POST decoded payloads to your server endpoint for storage.
  • InfluxDB Cloud: Direct integration available for time-series storage and Grafana dashboards (see our Grafana guide).

For MQTT integration with Home Assistant, the MQTT and Home Assistant guide covers the configuration patterns.

Common Mistakes

  1. Antenna impedance mismatch. Using a random wire instead of a proper 50Ξ© antenna tuned to 868/915 MHz can reduce range by 80% or more. Always use the correct antenna.
  2. Duty cycle violations. Transmitting too frequently gets your device banned from TTN gateways. Respect the 1% duty cycle limit.
  3. Incorrect payload format. If the TTN console shows raw hex but no decoded values, the payload formatter does not match your encoding. Verify you are using CayenneLPP consistently.
  4. Forgetting to handle rain counter rollover. The rain tip counter resets on each deep sleep wake cycle unless you persist it to RTC memory. Use RTC_DATA_ATTR uint16_t rainCount; to preserve it across sleep cycles.
  5. Not testing range before permanent deployment. Walk the site with the node powered on and check gateway reception before mounting everything on a pole. Moving a deployed station is painful.

Related Reading

FAQ

How far can LoRaWAN really reach? In flat terrain with clear line-of-sight, 10–15 km is achievable. In urban areas with buildings, expect 1–3 km. The record is over 700 km using high-altitude balloons, but for practical ground-level use, 5 km is a reasonable planning assumption.

Can I use LoRa without LoRaWAN (peer-to-peer)? Yes. Point-to-point LoRa is simpler and avoids the need for a gateway and TTN account. However, you lose the benefits of OTAA security, multi-gateway redundancy, and the TTN data forwarding infrastructure.

How many sensor nodes can one gateway handle? Hundreds. LoRaWAN gateways can receive on multiple channels simultaneously. The bottleneck is usually duty cycle on the nodes, not gateway capacity.

What about Helium or other LoRaWAN networks? Helium provides LoRaWAN coverage in some areas but coverage is inconsistent. TTN is the most reliable for hobby weather stations due to its community-driven, free model. You can configure the same device to work with either network by changing the join server.