A weather sensor at the end of the world, on the console at home – open-source Heltec V4 firmware on both ends of TTN

Hi all,

I’d like to share a use case that TTN makes possible with very little effort, together with the open-source (MIT) firmware behind it: Universal Weather Node for the Heltec WiFi LoRa 32 V4 (ESP32-S3 + SX1262, about €25).

A weather sensor at the end of the world, on the console at home

  • At the end of the world (pasture, mountain hut, model airfield – no Wi-Fi, no internet): a weather sensor (Ecowitt / Froggit, Bresser, TFA IT+, Davis … or wired) and a Heltec V4 next to it. The node receives the sensor on 868 MHz (FSK) and sends the values as LoRaWAN uplinks, on solar and battery if needed.
  • TTN: any gateway in range takes the uplinks. They are decoded by our payload formatter, published on TTN’s MQTT server and kept for 24 h by the Storage Integration.
  • At home: a second Heltec V4 with the same firmware subscribes to the device on TTN’s MQTT server and shows the far-away station like a sensor of its own – with name, history, records, Home Assistant device. It can even re-transmit the values on 868 MHz as a virtual Ecowitt sensor (e.g. a WH65), so the Ecowitt console in the living room shows the wind from the mountain hut as if the sensor were in the garden.

No server of your own, no port forwarding, no extra server or script in between – just two boards, a free TTN account and a gateway in range.

How the home node talks to TTN

  • MQTT live: one TLS connection to eu1.cloud.thethings.network:8883 (user <app>@ttn, an API key with only Read application traffic), topic v3/<app>@ttn/devices/<dev>/up. A new uplink arrives within seconds – measured 9 s after it was received at the gateway.
  • Storage Integration as a fill-in: after every (re)connect, and while MQTT is down, the node asks the storage for the uplinks it missed (after= the last received_at), so a short outage leaves no gap in the newest value.
  • The uplink’s own time counts: the node uses received_at, so the age shown is the real age, and a value older than its freshness window goes stale instead of being shown as current. An equal or older uplink (from the other path) is ignored.
  • TLS is verified against the built-in ISRG Root X1 certificate; the API key is write-only on the node and never logged.
  • Signal of the far node: the number of gateways, the best RSSI and the SNR of each uplink. Pointed at a node’s own device, the same is a handy range test.
  • It runs in its own task with the buffers in PSRAM (about 10 KB per live TLS connection plus an 8 KB message buffer), so the radio reception on the home node never waits for it.

What we made the SX1262 do

The V4’s LoRa chip is used for much more than LoRa – one radio, several jobs, no extra hardware:

  • Receiving weather sensors with its FSK modem on 868.3 MHz: Bresser (5/6/7-in-1 and more), Fine Offset sold as Ecowitt / Froggit (WS90, WS80, WH31, WH40, WN20, WH57 lightning, PM2.5, CO₂ …), TFA / LaCrosse IT+ at 17.241 and 9.579 kbit/s, and Davis Vantage Pro2 / Vue (experimental): for Davis the node follows the transmitter’s frequency hopping over 5 channels and predicts the next hop from the measured period.
  • Several sensor families at once: the radio can listen to only one data rate at a time, so the node learns each sensor’s send interval and switches to its data rate about 1 s before its next packet is due. Fine Offset and IT+ 17.241 kbit/s share a phase and are received together.
  • Transmitting, too – virtual sensors: the node sends its own values as up to 8 Ecowitt / Fine Offset or TFA IT+ sensor frames (WH31, WH40, WN32P, WH65, TX29 / TX35), within the 1 % duty cycle, so a console or gateway shows e.g. a wired Davis as a WH65. In Davis mode it uses the gap right after a Davis packet, before the next hop.
  • And LoRaWAN on top – at the same time: between uplinks the SX1262 receives the weather sensors in FSK. For an uplink it switches to LoRa, sends, keeps RX1 / RX2 open for downlinks, and goes straight back to FSK. At a 60 s interval roughly 5 % of sensor packets are missed – the sensors repeat every few seconds anyway, and rain totals are counters, so no rain is lost.

The LoRaWAN side

  • OTAA, EU868, works with TTN and ChirpStack (LoRaWAN 1.0.x, or 1.1 with NwkKey = AppKey)
  • Compact binary payload (34 bytes for a full station) that fits every EU868 data rate down to SF12; if ADR drops the data rate, the node leaves out the least important fields first. CayenneLPP is available as well
  • JavaScript payload decoder in the repo (chirpstack/decoder.js, decodeUplink), tested as the TTN uplink payload formatter
  • DeviceTimeReq for network time, so the clock works without internet (only requested while no better time source is available)
  • On the V4 the radio’s TX power is reduced by the front-end gain, so the radiated power stays at the EU868 limit
  • Downlinks on FPort 1 for remote configuration (parameter IDs)
  • Silent-session detection with automatic rejoin, and a light-sleep low-power mode for battery / solar sites

Fair use: the full 34-byte payload takes about 92 ms at SF7 and 308 ms at SF9. To stay within 30 s of airtime per day that means an interval of at least about 4½ min at SF7 and about 15 min at SF9 – so the interval has to follow the data rate the node really gets. The docs link the airtime calculator.

The rest of the project, in short

The node is a complete weather station hub that runs entirely on the ESP32 – no PC, Raspberry Pi or cloud:

  • up to 32 wireless sensors received directly, type detected automatically; a BME280 for pressure; on our own PCB also wired Davis sensors, DS18B20, UV, Victron VE.Direct
  • computed on the node: dew point, feels-like, cloud base, pressure tendency and weather trend, rain per hour / day / week / month / year, WMO wind (3-s gusts, 10-min means), sunshine duration, frost / fog warnings
  • built-in web dashboard with live values, wind rose, records and a long history (up to 2 years) on the node itself – works without internet, installable as a phone app
  • outputs: MQTT with Home Assistant auto-discovery, weather networks (AWEKAS, Weather Underground, Windy, Weathercloud, WOW, CWOP, openSenseMap …), InfluxDB / Prometheus, Loxone, REST API with Server-Sent Events, push alarms (ntfy, Pushover, Telegram, webhook)
  • network sensors: values from another node, a home-automation system or TTN (as above) used like a local sensor
  • own Wi-Fi access point for sites without Wi-Fi: phones join with a QR code on the display and see the dashboard
  • browser installation, setup wizard, OTA updates

What is tested so far for the TTN source: a V4 receiving its own uplinks back from TTN (eu1), both over MQTT and from the storage, through a RAK gateway. The complete chain with a second, really remote node and an Ecowitt console at the end has not been run yet – reports are very welcome.

:backhand_index_pointing_right: GitHub - franzenhof/universal-weather-node: Wi-Fi + LoRaWAN weather station that does everything on the node itself: WMO wind, rain, dew point, trends; statuspage, sends to MQTT, TTN/ChirpStack, Home Assistant, AWEKAS, WU, Windy & more. Open hardware (KiCad, JLCPCB-ready) and MIT firmware. LoRaWAN is optional. No other base-station required. · GitHub

  • the TTN source: docs/network-sensors.md → The Things Network
  • LoRaWAN, decoder, payload formats: docs/lorawan.md
  • receiving sensors with the SX1262: docs/wireless-sensors.md
  • virtual sensors (transmitting to a console): docs/virtual-sensors.md

Feedback from people running it on TTN is very welcome – especially on airtime and fair use with real-world intervals.