Babel IoT Examples for Raspberry Pi
Build IoT and home-automation prototypes in Java, with direct, native control of the sensors and actuators on your bench — and messaging over LoRa and ZigBee. This bundle of small, runnable programs shows how, using ParadigmShift's open-source libraries for Babel, the high-level runtime that makes distributed systems simpler to build.
Who it's for
These demos are for makers, researchers, and engineers who want to prototype in the IoT and home-automation (domotics) space without dropping to C or wrestling with low-level GPIO plumbing. You write ordinary Java; the libraries give you native control of the hardware — Grove sensors and actuators over I²C and GPIO — and let you send messages over LoRa and ZigBee through a single, radio-agnostic API.
Everything here is open source and built on Babel, our runtime for composing distributed protocols. That means the same building blocks you use to blink an LED scale up to real distributed behaviour — membership, gossip dissemination, replication — when your prototype grows.
At ParadigmShift we use exactly this stack to build robust, self-managed, and secure IoT solutions across domains, from industrial production monitoring to smart environments. We're publishing these demos and the libraries underneath them to share that foundation — a high-level framework and tools for anyone who wants to test ideas, build things, and prototype quickly — and to grow a community of enthusiasts and researchers building on top of Babel. If that's you, we'd love to hear what you make.
Built on Babel
Babel is a framework for developing performant and dependable distributed protocols on the JVM. Protocols are first-class components that interact only through asynchronous events — requests, replies, notifications, and timers — which makes otherwise-hard distributed behaviour composable, observable, and testable. The IoT-control and radio libraries used in these demos expose their device and networking features as ordinary Babel protocols, so your application code stays high-level and portable: swap LoRa for ZigBee by changing one target, and your handlers keep working.
The libraries the demos build on are published as Maven artefacts with full API docs — browse them in the Open Source section or at javadoc.paradigmshift.pt. Babel itself is described in the paper cited under References.
What's in the bundle
The whole bundle ships as a single runnable “fat JAR”. You pick a demo with one command-line argument; with no argument it prints the full list.
Grove device demos (I²C / GPIO)
| Demo | What it does | Hardware |
|---|---|---|
Lcd | Shows a sequence of messages on the LCD | Grove LCD |
LedMatrix / LedMatrix2 | Cycles images / icons on the LED matrix | Grove RGB LED matrix |
Accel | Reads the accelerometer and shows it on the LCD | Accelerometer + LCD |
anyGesture / cardinalGesture / arrowGesture | Reacts to hand gestures on the LED matrix | Gesture detector + matrix |
encoderMatrix | Drives the matrix from a rotary encoder | Rotary encoder + matrix |
ledsRGB / ledsHSB / simpleLedsRGB / simpleLedsHSB | Chainable RGB LEDs cycling colours | Grove chainable RGB LED |
lightControl | Gesture-controlled lights tying several devices together | RGB chain + gesture + matrix + LCD |
Radio demos (run a sender on one Pi, a receiver on another)
| Demo | Role | Hardware |
|---|---|---|
loraSend / loraReceive | Broadcast / listen for LoRa packets | Waveshare SX126X LoRa HAT |
zigbeeSend / zigbeeReceive | Broadcast / listen for ZigBee packets | Ember EZSP ZigBee dongle |
Hardware you'll need
Pick the pieces for the demos you want to run — none of it is exotic, and it's all off-the-shelf.
- A Raspberry Pi 4 or Raspberry Pi 5 running Raspberry Pi OS (Bookworm). The demos drive real hardware, so they only run on a Pi.
- A GrovePi+ HAT for the Grove demos, plus the Grove devices you want: LCD, RGB LED matrix, gesture detector, 3-axis accelerometer, rotary encoder, and the chainable RGB LED.
- For LoRa: an SX126x-based LoRa HAT for the Raspberry Pi (868 MHz EU band), such as the Waveshare SX126X LoRa HAT built on the EByte E22-900T22S module.
- For ZigBee: an Ember (EZSP) USB dongle — any Silicon Labs EFR32-based ZigBee coordinator, e.g. the Sonoff ZBDongle-E.
Raspberry Pi setup (once, before running)
The demos talk to real buses, so the Pi has to expose them and your user has to be allowed to use them. This is the step people most often miss.
1 · Install Java and the I²C tools
sudo apt update
sudo apt install -y openjdk-17-jre-headless i2c-tools
i2c-tools is required for every Grove I²C demo — the device scanner shells out to i2cdetect.
2 · Enable the interfaces
sudo raspi-config nonint do_i2c 0 # I²C (Grove LCD / matrix / gesture / accel)
sudo raspi-config nonint do_serial_hw 0 # serial hardware port (LoRa HAT UART)
sudo raspi-config nonint do_serial_cons 1 # disable the serial login console (frees /dev/ttyAMA0)
sudo reboot
/dev/ttyAMA0 open. On Pi 4/5 you may also add
dtoverlay=disable-bt to /boot/firmware/config.txt so the PL011 (not the
mini-UART) is wired to the header. The ZigBee dongle is USB — no interface toggle needed.
3 · Let your user reach the buses (avoid running as root)
sudo usermod -aG i2c,gpio,dialout "$USER"
# log out / back in (or reboot) for the groups to apply
dialout covers both the LoRa HAT UART and the ZigBee USB dongle.
4 · Wire to the expected ports
| Hardware | Where | Default |
|---|---|---|
| Grove I²C devices | GrovePi I²C port | bus /dev/i2c-1 |
| Grove chainable RGB LED | GrovePi digital port | GPIO line 24 (led.line) |
| Waveshare SX126X LoRa HAT | 40-pin header | UART /dev/ttyAMA0, addr 0x0001 |
| Ember ZigBee dongle | any USB port | auto-discovered |
24 (BCM 24 clock + BCM 25 data), chosen so it
coexists with a seated LoRa HAT. Don't move it to line 26: the data pin
(line + 1 = BCM 27) is the LoRa HAT's M1 mode pin, which surfaces as a
Device or resource busy error.
Build & run
Download the JAR from the latest release, or build it yourself (Java 17 + Maven 3.6+):
mvn package
java -jar target/babel-raspberry-iot-examples.jar # prints the demo list
java -jar target/babel-raspberry-iot-examples.jar Lcd # run a specific demo
You can build on any machine and copy the JAR to the Pi — only running requires the hardware.
Running the radio demos
The radio demos need two nodes. Run a receiver on one Pi and a sender on another:
# Pi A — receiver
java -jar target/babel-raspberry-iot-examples.jar loraReceive
# Pi B — sender
java -jar target/babel-raspberry-iot-examples.jar loraSend
ZigBee works the same way (zigbeeReceive / zigbeeSend). Radio settings —
UART device, on-air address, ZigBee serial port — are read from paradigmshift.config,
all with sensible defaults.
Source & downloads
- Latest release (runnable JAR): github.com/ParadigmShift-PT/babel-raspberry-iot-examples/releases
- Source code: github.com/ParadigmShift-PT/babel-raspberry-iot-examples
- This project's API docs: paradigmshift-pt.github.io/babel-raspberry-iot-examples (published from the repo on GitHub Pages)
- The libraries it builds on: Open Source · javadoc.paradigmshift.pt
Credits & references
The IoT device-control demos are based on work originally developed at NOVA School of Science and Technology (NOVA FCT), in the Computer Systems Group of NOVA LINCS, as part of the TaRDIS European project. ParadigmShift's version is provided and evolved independently of that original work. The LoRa and ZigBee radio demos were developed by ParadigmShift.
Babel is described in: P. Fouto, P. Á. Costa, N. Preguiça and J. Leitão, “Babel: A Framework for Developing Performant and Dependable Distributed Protocols,” 2022 41st International Symposium on Reliable Distributed Systems (SRDS), Vienna, Austria, 2022, pp. 146–155, doi: 10.1109/SRDS55811.2022.00022.
Build with us
All of this is open source on GitHub — these demos, the LoRa and ZigBee protocols, and the Babel libraries underneath. Clone it, run it, build something new, and tell us what you make.