Link Search Menu Expand Document

Remote Control

It is possible to remotely control your devices from another computer, enabling you to develop and test your application directly from your development environment.

Command Line Examples

All of the command line examples provided assume that all dependent JARs are also contained within the current directory or on the CLASSPATH.


For Arduino compatible devices communication is via USB using the excellent firmata4j and jssc libraries that are accessed when using the diozero-provider-firmata wrapper.

Make sure you set the property FIRMATA_PORT to the serial port (COM on Windows) to which your Arduino is connected. This can be set either via the command line (e.g. -DFIRMATA_PORT=COM5) or as an environment variable (command line takes precedence).

Example command line:

java -cp diozero-sampleapps-1.2.1.jar:diozero-provider-firmata4j-1.2.1.jar com.diozero.sampleapps.LEDTest -DFIRMATA_PORT=COM5 12

Particle Wi-Fi Connected Microcontrollers

The Particle Photon is a tiny Wi-Fi connected microcontroller. You can upload the VoodooSpark firmware to the board to enable remote control over Wi-Fi.

Make sure you set the properties PARTICLE_DEVICE_ID and PARTICLE_TOKEN correctly (either via command line or as environment variables).

Example command line:

java -cp diozero-sampleapps-1.2.1.jar:diozero-provider-voodoospark-1.2.1.jar -DPARTICLE_DEVICE_ID=abc -DPARTICLE_TOKEN=xyz com.diozero.sampleapps.LEDTest 12


The pigpio library also comes with the pigpiod daemon process for remote access. By default (for security reasons) this process only allows communication from the Raspberry Pi device it is running on. To enable remote access pigpiod needs to be run without the -l option. Before doing this you must be aware of the security implications, only consider this on a local network that has no inbound connectivity from the Internet.

On Raspbian Jessie and later you can enable the pigpiod daemon to run as a system service:

sudo systemctl enable pigpiod.service

This will start pigpiod every time the Pi boots. To remove the -l option which is included by default, edit /etc/systemd/system/pigpiod.service.d/public.conf and change the ExecStart property, i.e.


If the file doesn’t exist, run the raspi-config application and choose “3 Interface Options”, “P8 Remote GPIO” and select “Yes”. This will make the appropriate changes and create that file if it didn’t already exist.

Make sure you set the property PIGPIOD_HOST to the hostname of your Raspberry Pi. You can also override the default pigpiod port value (8888) via the property PIGPIOD_PORT. Again these properties can be set either via command line or as environment variables.

Example command line:

java -cp diozero-sampleapps-1.2.1.jar:diozero-provider-pigpio-1.2.1.jar -DPIGPIOD_HOST=raspberrypi com.diozero.sampleapps.LEDTest 12

Generic Remote Access Library (experimental)

I am in the process of adding generic remote device access protocols to diozero, please see the diozero-remote-server and diozero-provider-remote projects. The idea is that support for these protocols can be developed for any device, including those that don’t run Java in particular the extremely cheap Wi-Fi connected ESP8266 and ESP32.

The code has been designed to be generic so as to support any communication channel and protocol. To switch between the different client implementations you currently need to modify the RemoteDeviceFactory class.

So far I have developed support for the following remote protocols:

Channel Protocol(s) Implementation Notes
HTTP JSON Server, Client GPIO (read and write), SPI. I2C support not yet implemented. Something like Server-sent Events would be required to support GPIO events.
WebSockets JSON, Google Protobuf JSON Server, JSON Client, Protobuf Client GPIO (read, write and events), SPI. I2C support not yet implemented. Java Protobuf server not yet implemented.
MQTT JSON, Google Protobuf JSON Server, Protobuf Server, Protobuf Client GPIO (read, write and events), SPI. I2C support not yet implemented.
Socket VoodooSpark Server, Client GPIO (read, write and events). I2C support not yet implemented. SPI not currently supported by VoodooSpark.
Socket pigpiod Server Client not yet ported to diozero-provider-remote.
USB firmata Arduino Server, Particle Spark Server Client not yet ported to diozero-provider-remote.

Performance is surprisingly good, I’ve been using the SSD1331Test application to check frames per second when rendering Game of Life iterations to an SSD1331 colour OLED display via SPI; I’ve not seen much difference between the various protocols. Performance is approximately half of that when run on the device itself.

The HTTP / WebSockets / MQTT channels with JSON / Protobuf protocols are planned to be simplified and replaced with a gRPC / Protobuf based solution in the future.