Skip to content

RoboBoard X4

RoboBoard X4 remote ESP32

Operate RoboBoard X4 remotely using Totem App and Arduino Library.
For user manual read documentation section.

API Reference

Arduino code to connect RoboBoard X4 remotely.
Note: RoboBoard has to run TotemApp service in order to be discoverable.

#include <TotemRoboBoardX4.h>
TotemRoboBoardX4 board;
void setup() {
  // Connect to RoboBoard X4 (over Bluetooth)
  board.connect();
  // Set RGB to red
  board.rgbColor(125,0,0);
  // Spin Motor
  board.dcSpinA(40);
  // Spin Servo
  board.servoSpinA(50);
}
void loop() { }

Connection

Functions to establish and control Bluetooth connection.

state board.connect()

state board.connectName(name)

state board.connectAddress(address)

Initiate Bluetooth connection to the board.
Parameter:
name - connect only if name matches
address - connect only if BLE address matches
Returns:
state - [true] connected, [false] failed

state board.isConnected()

Is connection active.
Returns:
state - [true] connected, [false] disconnected

board.disconnect()

Terminate active connection

address board.getAddress()

Get connected board BLE address.
Returns:
address - String object containing address XX:XX:XX:XX:XX

board.addOnConnectionChange(function)

Register connection state change event.
Parameter:
function - function name void onConnectionChange()

#include <TotemRoboBoardX4.h>
TotemRoboBoardX4 roboboard;
// Detect connection state change event
void onConnectionChange() {
  if (roboboard.isConnected())
    { /* Connected */ }
  else
    { /* Disconnected */ }
}
// Initialize program
void setup() {
  // Register connection state event
  roboboard.addOnConnectionChange(onConnectionChange);
  // Connect to RoboBoard over Bluetooth
  roboboard.connect();
}

Information

Functions to receive board information and configuration.

state board.getButton()

Read button (BOOT) state.
Returns:
state - [true] is pressed, [false] not pressed.

voltage board.getBattery()

Read battery voltage.
Returns:
voltage - [8400:12600] voltage in millivolts.

version board.getVersion()

Get firmware version.
Returns:
version - String object containing firmware version.

version board.getDriverVersion()

Get motor driver firmware version.
Returns:
version - String object containing firmware version.

version board.getRevision()

Get board revision.
Returns:
version - String object containing board revision.

name board.getName()

Get configured board name.
Returns:
name - String object containing

model board.getModel()

Get type of robot board is installed in (configured with setModel()).
Note: not used at the moment.
Returns:
name - 16-bit identifier

hex board.getColor()

Get configured board appearance color.
Returns:
hex - [0:0xFFFFFF] 24-bit color code.

state board.getInvertDC()

Get if all DC motor ports are inverted.
Returns:
state - [true] invert, [false] not inverted

state board.getAutobrakeDC()

Get if all DC motor autobrake is enabled.
Returns:
state - [true] brake, [false] coast

Motor control

Servo and DC motors control functions.

board.servoSpinA(pos)

board.servoSpinB(pos)

board.servoSpinC(pos)

Spin servo motor to position.
Parameter:
pos - [-100:100]% position. [0] center

board.servoSpinABC(A,B,C)

Spin all servo motors to individual position with a single command.
Parameter:
A,B,C - [-100:100]% position. [0] center

board.dcSpinA(power)

board.dcSpinB(power)

board.dcSpinC(power)

board.dcSpinD(power)

Spin DC motor.
Parameter:
power - [-100:100]% power. [0] stop

board.dcBrakeA(power)

board.dcBrakeB(power)

board.dcBrakeC(power)

board.dcBrakeD(power)

Brake DC motor.
Parameter:
power - [0:100]% power. Default 100%

board.dcSpinABCD(A,B,C,D)

Apply individual spin power to all DC motors with a singe command.
Parameter:
A,B,C,D - [-100:100]% power. [0] stop

board.dcBrakeABCD(A,B,C,D)

Apply individual brake to all DC motors with a singe command.
Parameter:
A,B,C,D - [0:100]% power. Default 100%

Lights control

RGB lights and single LED control functions.

board.setLED(state)

Turn (red) LED.
Parameter:
state - [0] off, [1] on

board.rgbColorA(hex)

board.rgbColorB(hex)

board.rgbColorC(hex)

board.rgbColorD(hex)

board.rgbColorA(red,green,blue)

board.rgbColorB(red,green,blue)

board.rgbColorC(red,green,blue)

board.rgbColorD(red,green,blue)

Set color to individual RGB light.
Parameter:
🔴 red - amount of red color [0:255]
🟢 green - amount of green color [0:255]
🔵 blue - amount of blue color [0:255]
hex - hexadecimal color code [0:0xFFFFFF]

board.rgbColor(hex)

board.rgbColor(red,green,blue)

Set color to all RGB lights.
Parameter:
🔴 red - amount of red color [0:255]
🟢 green - amount of green color [0:255]
🔵 blue - amount of blue color [0:255]
hex - hexadecimal color code [0:0xFFFFFF]

board.rgbColorTotem()

Set all RGB lights to Totem color.

board.rgbColorReset()

Set RGB lights to default board color (configured with setColor()).

User commands

Send user defined data between RoboBoard X4 and Totem Library.

status board.sendValue(id,value)

Send value to remote RoboBoard.
Parameter:
id - 32-bit identifier
value - 32-bit value
Returns:
status - [true] success, [false] error

status board.sendString(id,string)

status board.sendString(id,data,length)

Send string (text) or data array to remote RoboBoard.
Parameter:
id - 32-bit identifier
string - String object
data - pointer to array
length - array length
Returns:
status - [true] success, [false] error

value board.readValue(id)

Read value from remote RoboBoard. Calls TotemApp.addOnRead() handler.
Parameter:
id - 32-bit identifier
Returns:
status - [0:0xFFFFFFFF] value

string board.readString(id)

Read string (text) from remote RoboBoard. Calls TotemApp.addOnRead() handler.
Parameter:
id - 32-bit identifier
Returns:
string - String object

board.addOnReceive(function)

Register event to intercept data sent from remote RoboBoard
with functions TotemApp.sendValue(), TotemApp.sendString().
It accepts value and string functions. Both can be added at the same time.
Parameter:
function - void onReceiveValue(int id, int value)
function - void onReceiveString(int id, String string)

#include <TotemRoboBoardX4.h>
TotemRoboBoardX4 roboboard;
// Intercept value sent by TotemApp.sendValue() (from RoboBoard)
void onReceiveValue(int id, int value) {

}
// Intercept string sent by TotemApp.sendString() (from RoboBoard)
void onReceiveString(int id, String string) {

}
// Initialize program
void setup() {
  // Register value and string receive functions
  roboboard.addOnReceive(onReceiveValue);
  roboboard.addOnReceive(onReceiveString);
  // Connect to RoboBoard over Bluetooth
  roboboard.connect();
}

board.functionA(value)

board.functionB(value)

board.functionC(value)

board.functionD(value)

Send value to RoboBoard function event.
Parameter:
value - any 32-bit value

Configuration

Configure board settings (retained after power off).

board.setName(name)

Change board name.
Parameter:
name - board discovery name (30 bytes max)

board.setColor(hex)

board.setColor(red,green,blue)

Change board initial color.
It may be displayed inside mobile application or on-board RGB lights.
Parameter:
🔴 red - amount of red color [0:255]
🟢 green - amount of green color [0:255]
🔵 blue - amount of blue color [0:255]
hex - hexadecimal color code [0:0xFFFFFF]

board.setModel(model)

Assign type of robot board is installed in.
Note: not used at the moment.
Parameter:
model - [0:0xFFFF] 16-bit identifier

board.setInvertDC(state)

Invert all DC motor ports.
Parameter:
state - [true] invert, [false] not inverted

board.setAutobrakeDC(state)

Brake all DC motors when power is set to 0.
Parameter:
state - [true] brake, [false] coast

board.resetConfig()

Reset stored configuration (factory reset).

board.restart()

Restart connected board.