ewdicus edited this page Oct 23, 2014 · 3 revisions
Clone this wiki locally

The WireGarden library is a uniform interface for a variety of sensors and other hardware. But it's also a good example of a simple command processor and lightweight serial protocol.

Getting Started

The WireGarden library depends on a bunch of third-party libraries for individual devices. We provide a zip file that includes the libraries in this repo and the third-party libraries here: http://files.manylabs.org/WireGardenArduino.zip

Once you have those installed, you can start with the basic WireGarden sketch on the Manylabs site: https://www.manylabs.org/tool/arduinoProgrammer/sketch/2/

That sketch is also a good example of the kinds of processing your sketch will need to do to use the WireGarden library.

Device Types

A device is a piece of hardware that has driver code built into the WireGarden system. There may be multiple instances of a single device type connected at one time.

Devices are listed here: Device Types

Commands and Responses

The general message syntax is: cmd: arg1, arg2, arg3, ... | checksum

Here cmd refers to the command/message name and arg entries are the argument values. The |checksum suffix is optional. If provided, it should be a mod-256 sum of the message's ASCII values. (not including the | symbol).

Spaces in messages/commands are generally omitted. They are included here for legibility.


  • The command processor expects commands to end with \n. The Serial Monitor in the Arduino IDE can include these for you.
  • Each response is terminated with \n.
  • The default serial connection operates at 9600 baud.

General Commands

name command/message description
request version ver request a version number; returns information message with a sketch name and version number followed by board type.
full reset r removes all defined devices
memory check m returns number of available bytes in RAM
test command tc: param1, param2, ... a command for testing parameter parsing; replies with tr: and the given arguments

Device Commands

name command/message description
init device d: deviceType, pin, ... create/configure a device; set pin to zero if not needed; see the Device Types page for input device types and additional parameters
set device value s: type, pin, value1, value2, ... set the value of the given device (generally an output device)
get device value g: type, pin get the value(s) of the given device; replies with a single dv message (see below)
set send interval si: interval set the rate of sending device values; the interval (in milliseconds) should be in [0, 1000]; a value of zero halts sending
get supported devices dev returns a list of devices types that are currently enabled

Replies from Arduino

name command/message description
values v: value1, value2, ... values of all devices (including zeros for output devices)
device value dv: value1, value2, ... value(s) of a single device (requested by g command)
error e: error code an error occurred; see wgErrorCodes.h for error code values
information i: message an informational message
test reply tr: param1, param2, ... reply to test command
version reply i: sketch name, versionNumber, board type the current software version number (e.g. 0.0.1)
supported devices reply i: deviceType, deviceType, ... a list of currently enabled devices