Skip to content

[03] Mini Board X3

Robotics controller with Bluetooth connectivity and motor drivers. For full description read Totem Shop page.

TotemModule module(03);

Module image

Module commands

Before start

• Install programming environment by following tutorial on Arduino setup.
• Join our community forum for any questions: https://forum.totemmaker.net.

Command naming convention

Some commands controls various channels (A, B, C, ...). There is a logic behind command naming for flexibility:
write("commandA", 10) - will set value 10 for individual channel A.
write("commandAll", 100) - will set value 100 for all existing channels.
write("commandABCD", 10, 20, 30, 40) - will set individual values for A, B, C, D channels.
write("commandABC", 10, 20, 30) - will set individual values for A, B, C channels.
Only commands listed in "Module commands" will be accepted. Other variations will be discarded.
All commands are case sensitive! Calls like CommandA, COMMANDa, motorA/BRAKE will be ignored.

Configuration

Commands starting with "cfg" retains it's value after module power off. Used as module configuration parameters.

cfg/robot/name ( string )

Description: Configure robot name visible during connection.
Value: Any string value up to 30 bytes max. Default is "Totem X4".
module.write("cfg/robot/name", "My robot"); // Set robot name

cfg/robot/model ( int )

Description: Configure Totem robot model (MiniTrooper, Truck, ...).
Used to identify type of the robot. Can be configured to any value by user. Also received with getModel().
Value can be generated with command: TotemModule::hashModel("model").
Value: 16bit hash of robot model name. Default is 0.
// Set robot model to Truck
module.write("cfg/robot/model", TotemModule::hashModel("Truck"));
// Check if robot is Truck
ModuleData data;
if (module.readWait("cfg/robot/model", data) &&
    data.getInt() == TotemModule::hashModel("Truck")) { }

cfg/robot/color ( int )

Description: Configure robot color.
Used to recognize robot appearance by it's color. It may be displayed inside mobile application or on-board RGB LED.
Value: 24bit RGB color value (without brightness). Default is 0.
module.write("cfg/robot/color", 0x0000FF); // Set robot color to BLUE
// Alternative to set individual RGB colors:
module.write("cfg/robot/color", 0, 0, 255); // Set robot color to BLUE

cfg/motorABCD/invert ( int , int , int , int )

Description: Configure motor output polarity.
Individual motors can be configured to invert it's spinning direction. Allows to fix reversed motor wiring without reconfiguring robot controls.
Value: 0 or 1 per each channel. Default is 0.
// Invert channels A and B. C, B - not inverted (default).
module.write("cfg/motorABCD/invert", 1, 1, 0, 0);

cfg/reset ( )

Description: Reset all module configuration to factory default.
module.write("cfg/reset"); // Reset all module settings to default

DC motor control

motorA ( int )

motorB ( int )

motorC ( int )

motorD ( int )

Description: Set individual DC motor A, B, C, D channel power.
Value: Percentage of power 0-100%. Negative value will spin backwards.
module.write("motorA", 100); // Write channel A

motorABCD ( int , int , int , int )

Description: Set all motor channels with one command call.
Value: Percentage of power 0-100%. Negative value will spin backwards.
module.write("motorABCD", 100, 50, 0, -100); // Write channels A, B, C, D

Servo motor control

servoA ( int )

servoB ( int )

Description: Set servo A, B channel position.
Value: Position of servo angle. Value from -100 to 100. It maps to 0° to 180°. 0 equals 90°.
module.write("servoA", 0); // Set servo channel A to 90° angle

Light bar control

leds ( int )

Description: Control red LED bar.
Value: 12 bits, each representing individual on-board LED. 1 - on, 0 - off.
module.write("leds", 0b110011110011); // Set led bar to: on|on|off|off|on|on|on|on|off|off|on|on

Battery

battery ( )

Description: Get connected battery voltage. This command is read-only.
Value read: Voltage in millivolts. Divide by 1000 to get volts.
// Read battery voltage
int voltage = module.readWait("battery").getInt(); // Result: 3350 -> 3.350V
// 'readWait' will delay code execution until result is received from the module.
ModuleData data; // Prepare variable to store read result
module.readWait("battery", data); // Perform read with wait until result is received
bool voltage = data.getInt(); // Get battery value from result. 3350 -> 3.350V
// Function that will receive all subscribed commands of module
void onModuleData(ModuleData data) {
    if (data.is("battery")) { // Check if received command is "battery"
        bool voltage = data.getInt(); // Get battery value from result. 3350 -> 3.350V
        Serial.print("Battery voltage = ");
        Serial.println(voltage);
    }
}
void setup() {
    module.attachOnData(onModuleData); // Register onModuleData function
    module.subscribe("battery"); // Subscribe to receive any state change of battery
}