Skip to content

X4 features

Totem RoboBoard X4 has a lot of functionality. This tutorial will describe each one with instructions how to use it. For commands reference view page X4 module.

Before start

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

Module image

ESP32 240Mhz processor

Board is powered by dual-core 240Mhz ESP32 processor. It's very popular among Arduino community and has built-in WiFi, Bluetooth Classic, Bluetooth Low Energy wireless protocols. Totem Library utilizes BLE protocol to communicate with smartphone and other Totem modules. Bluetooth Classic - with PS3/PS4 controllers.
Built-in features examples are available at Arduino → File → Examples → Examples for ESP32 Dev Module. Or look in Github repository.
Some features may not be available, cause ESP32 is embedded in X4 board or some what is occupied by Totem Library.

3 Servo channels

3 on-board servo motor channels are available. Rated for 5 Volts. Each is marked with letter A, B, C and can be controlled individually.
Most servo motors can turn it's arm 180 degrees. 0° - center, 90° - left, -90° - right. It corresponds with percentage of turn: 0% - center, 100% - left, -100% - right. X4 commands accepts percentage parameter.
Servo angle visualization:
Servo arm angles

Totem.X4.write("servoA", 100); // Set channel A to 90° angle
Totem.X4.write("servoB", 0);   // Set channel B to 0° angle
Totem.X4.write("servoC", -50); // Set channel C to -45° angle

4 DC channels

4 on-board DC motor channels are available. Each is marked with letter A, B, C, D and can be controlled individually.
Motor spin direction and power (speed) can be controller. X4 passes current from connected battery and controls output voltage with PWM. The higher the voltage, the faster motor will spin. Maximum voltage may vary depending on battery state of charge (8.4V-12.6V).
Power values corresponds with percentages:
0% - (no power, 0.0V)
100% - (full power forward, 11.1V)
-100% - (full power backward, -11.1V)

Totem.X4.write("motorA", 100); // Set channel A to spin forward (11.1V)
Totem.X4.write("motorB", 0);   // Set channel B to power off (0.0V)
Totem.X4.write("motorC", -100); // Set channel C to spin backward (-11.1V)
Totem.X4.write("motorD", -25);  // Set channel D to spin backward (-2.78V)

4 GPIO channels

4 on-board GPIO pins are available with analog and PWM modes. It works similar as GPIO pins on standard Arduino board. Pinout is marked in the right of pins connector. VCC - 3.3V source. GND - ground. A, B, C, D - GPIO pins.
For more information read X4 GPIO pins reference.

Module X4 GPIO

Totem.X4.write("gpioA", HIGH); // Set Pin A to 3.3V
Totem.X4.write("gpioA", LOW);  // Set Pin A to 0V (GND)
int state = Totem.X4.readWait("gpioA"); // Read Pin A state.
// state == HIGH - connected to VCC, state == LOW - connected to GND
Serial.println(state == HIGH ? "HIGH" : "LOW");

Values from 0 to 20. 50hz modulation.

Totem.X4.write("gpioA/analog", 20); // Set Pin A to 3.30V
Totem.X4.write("gpioA/analog", 10); // Set Pin A to 1.65V
Totem.X4.write("gpioA/analog", 0);  // Set Pin A to 0.0V

Measure potentiometer position connected to pin C. Wiring:
Potentiometer connection

int value = Totem.X4.readWait("gpioC/analog"); // Read value of potentiometer
Serial.println(value); // Print value

4 RGB LED

Back side of the board contains 4 individually controllable RGB LEDS. Each LED can be set to particular color and brightness.
First parameter 0-255 controls percentage of brightness (0-100%). Second parameters controls amount of Red, Green, Blue color (0-255).

Module X4 RGB led

Totem.X4.write("rgbA", 255, 0, 255, 0); // Set LED A to GREEN color.
Totem.X4.write("rgbB", 255, 255, 255, 0); // Set LED B to YELLOW color (RED+GREEN).
Totem.X4.write("rgbC", 255, 255, 255, 0); // Set LED B to YELLOW color (RED+GREEN).
Totem.X4.write("rgbD", 255, 0, 0, 255); // Set LED D to BLUE color

Totem BUS

Totem BUS connectors allows to attach other Totem modules and control them from X4 module. Each module is identified with number in a white square. For reference of each module check Modules information.
Modules can be connected in any order and daisy-chained. Connector provides power and communication.

TotemModule module(57); // Define connected module with it's number
void setup() {
    Totem.X4.begin(); // Initialize X4 board
    module.write("indicate"); // Blink led on the connected module 57.
}

MEMS sensor

The MEMS is a LSM6DS3. It is a 3-axis accelerometer and 3-axis gyroscope. Connected with ESP32 trough I2C. Can be used with any Arduino library for LSM6DS3.

Bug

There is LSM6DS3 Arduino libraries incompatibility with ESP32 Arduino implementation.
Requires line _wire->end(); to be removed in order to compile. We are solving this.

USB port

miniUSB connector is present for code upload from PC to X4 board.
X4 board cannot be powered from USB! It requires either DC or battery input.

Bluetooth

Totem Library uses BLE to advertise board appearance. This allows to connect it with smartphone using Totem App. This process is running in background, alongside your written Arduino code. Totem.X4.begin(); must be called inside void setup() { function in order to make X4 discoverable! If smartphone connectivity is not required, Totem.X4.beginNoBLE(); can be used.
Bluetooth Classic is used to connect with PS3/PS4 controllers.

Documentation and examples of BLE DIY solutions can be found in ESP32 arduino repository.

WiFi

ESP32 has integrated WiFi capability. Examples of usage can be found in ESP32 arduino repository.

LED indications

Red led next to DC jack - indicated battery charging status:
Blinking - battery not detected.
On - battery is charging.
Off - battery is charged.
NOTE: sometimes led can start blinking when battery is charged.

Red led next to user button for indicating board state:
Short rapid blink - board started or indicated.
Blinking - initialization error (consult forum).
On - running.

Board state LED can be overridden:

Totem.X4.write("led", 1); // Turn LED On
Totem.X4.write("led", 0); // Turn LED Off

User button

By default this button is inactive and left for user implementation.
Example code how to turn off LED on button press:

#include <Totem.h>

void onModuleData(ModuleData data) {
    // Check if event came from button
    if (data.is("button")) {
        // Update LED with inverted button state
        Totem.X4.write("led", !data.getInt());
    }
}

void setup() {
    Totem.X4.begin(); // Initialize X4 board
    Totem.X4.attachOnData(onModuleData); // Register onModuleData function
    Totem.X4.subscribe("button"); // Subscribe to button state change events
}

void loop() {

}

On/off switch

Used to turn X4 board power on or off without disconnecting DC jack or battery.
Battery can be charged while button is set to OFF position.

DC input

15V DC input for powering board and charging battery.
Recommended to use only supplied DC power adapter.
Specifications: 30W, 15V, 2A, 5.5/2.0mm center-positive connector.

Battery input

Battery input for connecting 11.1V Li-Ion battery.
Recommended to use only supplied battery.
Specifications: 3S Li-Ion 11.1V 2200mAh, JST-VH connector.

Charging indication: LED indications