Remote Control of Digital Output with OSC Messages

Introduction

This page will guide the process of controlling an output signal of a BITalino R-IoT module with control messages using Open Sound Control (OSC). These can be sent over a shared local Wi-Fi network from any application with an OSC server. The R-IoT's standard firmware includes an OSC listener that's initialized once the device is switched on; this can be used to control the on-board digital output pin with an output sate of 0 or 1.

Code snippet from bitalino-riot-firmware.ino

Message Format and Configuration

The OSC message requires three arguments: an IP address, port number and an message address.

  • The device's local IP should be set to static from the configuration page. In this example we'll use the default address 192.168.1.40

  • The default service port is set as 9999

  • The message format is /<id>/output where the module ID number must match what is assigned to the configuration. You can use this format to manage multiple devices within the same local network

For more information on the accessing the device configuration, please see the Quick-start Guide.

R-IoT Configuration Page

The message must then be followed by an integer to determine the output sate. We'll present two examples that can be used to test this method.

Test #1 ServerBIT

In the example below, we use ServerBIT MAX to switch between sending /1/output 0 and /1/output 1 to the address 192.168.1.40 on port 9999using a toggle. To test, connect the R-IoT to the computer's USB port, launch Energia and open the serial monitor. From here, switch on the device and wait some seconds for the connection and calibration process before sending new OSC control messages. If the connection is successful, new lines should print in the console when a new message is received:

Test #2 Processing

Below is a simple Processing sketch that uses the oscP5 library to send messages over the network. The network parameters are kept the same as the above, and the message format is the same. First check the module ID matches the configuration before running the sketch, then click on the screen to switch between sending /<id>/output 0 and /<id>/output 1

https://gist.github.com/wprimett/9eb34757478eab2e443ed6f8a0cc81d2

Last updated

Was this helpful?