Skip to main content
All blog posts

Meet Yagi: A Programming Language for Radio

Describe a signal once, and Yagi builds the receiver, the test signals and the detector. Here is why we are building it.

Yagi is a programming language for radio frequency systems, built by 291 Group. It is named for the Yagi-Uda antenna, invented by Hidetsugu Yagi and Shintaro Uda in 1926, and its idea fits in one line: describe the signal once.

Radio software is written three times

Today, a new radio capability is usually written three times: once in Python to prove the idea, once in C++ to make it fast, and once more in a hardware language to put it on specialised hardware. Sample rates and units live in comments and in the engineer’s head, so a mismatch produces silent garbage instead of an error. Every new signal means a hand-built demodulator, a separate test generator and separate detection logic.

Describe the signal once

In Yagi, you describe a signal once: how it is modulated, how fast its symbols arrive, how its frames are built and checked. From that one description, Yagi generates the receiver, the test signals and the detector, and runs the same program on a laptop or a field sensor, live from a radio or from a recording.

Here is a short program that tunes a radio to 433.92 MHz and decodes a weather sensor:

radio sdr = hackrf("one") {
  rx.freq = 433.92 MHz
  rx.rate = 2 Msps
}

signal WeatherSensor {
  modulation:  ook
  symbol_rate: 2.4 kbaud
  coding:      nrz
  frame:       preamble(0xAAAA) ++ sync(0x2DD4)
            ++ payload(bytes[8]) ++ crc16(poly: 0x1021)
}

sdr.rx
  |> lowpass(cutoff: 100 kHz)
  |> decimate(10)
  |> WeatherSensor.demod()
  |> each(frame => log(frame.payload))

A language that knows what a frequency is

Radio is built into the language. Frequencies, sample rates and physical units are types, and so are the limits of real radios. Ask a receiver for a frequency it cannot tune, or connect two blocks running at different sample rates, and Yagi stops you when the program compiles, not in the field.

Short descriptions, real results

  • A 28-line description of LoRa decodes 196 of 205 public recordings, more than the 187 decoded by a 2,100-line reference decoder written in C++.
  • Its device library describes 95 devices, each checked against a public test collection of real recordings.
  • It already decodes 433 MHz sensors, aircraft transponders (ADS-B), Bluetooth Low Energy advertising and push-to-talk voice radio.

It runs with common software-defined radios such as HackRF and RTL-SDR.

Follow Yagi

Yagi has its home on GitHub at github.com/yagi-lang. Follow it there to see it first.