All demos
Tech Demo

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.

Raspberry Pi 4 / 5 Java 17 LoRa ZigBee Grove / Pi4J Open Source

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)

DemoWhat it doesHardware
LcdShows a sequence of messages on the LCDGrove LCD
LedMatrix / LedMatrix2Cycles images / icons on the LED matrixGrove RGB LED matrix
AccelReads the accelerometer and shows it on the LCDAccelerometer + LCD
anyGesture / cardinalGesture / arrowGestureReacts to hand gestures on the LED matrixGesture detector + matrix
encoderMatrixDrives the matrix from a rotary encoderRotary encoder + matrix
ledsRGB / ledsHSB / simpleLedsRGB / simpleLedsHSBChainable RGB LEDs cycling coloursGrove chainable RGB LED
lightControlGesture-controlled lights tying several devices togetherRGB chain + gesture + matrix + LCD

Radio demos (run a sender on one Pi, a receiver on another)

DemoRoleHardware
loraSend / loraReceiveBroadcast / listen for LoRa packetsWaveshare SX126X LoRa HAT
zigbeeSend / zigbeeReceiveBroadcast / listen for ZigBee packetsEmber 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.

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
The LoRa HAT needs the PL011 UART on the GPIO header free. The serial console must be off or it holds /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

HardwareWhereDefault
Grove I²C devicesGrovePi I²C portbus /dev/i2c-1
Grove chainable RGB LEDGrovePi digital portGPIO line 24 (led.line)
Waveshare SX126X LoRa HAT40-pin headerUART /dev/ttyAMA0, addr 0x0001
Ember ZigBee dongleany USB portauto-discovered
The chainable-LED default is line 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

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.