Basicmicro (MCP / RoboClaw) Example

This example demonstrates how to use the espp::Basicmicro component to talk to a Basicmicro MCP236 / MCP266 (or RoboClaw-family) motor controller over UART using the packet serial protocol. It:

  1. reads the firmware version, main battery voltage and unit status,

  2. resets the encoders,

  3. runs a gentle duty-cycle ramp on motor 1 while reading back the encoder count and speed, then ramps back down and stops, and

  4. periodically logs the motor currents and board temperature.

Table of Contents

Requirements

  • ESP-IDF installed and get_idf available in your shell

  • A Basicmicro MCP / RoboClaw controller configured for packet serial mode at 38400 baud, address 0x80 (the defaults used by this example)

Hardware

ESP32 (this example)

MCP / RoboClaw

GPIO 17 (UART1 TX)

S1 (RX)

GPIO 16 (UART1 RX)

S2 (TX)

GND

GND

Adjust the pins / port / baud rate at the top of basicmicro_example.cpp to match your wiring.

Build

# From repo root
cd components/basicmicro/example
get_idf
idf.py set-target esp32
idf.py build

Flash and Monitor

idf.py flash monitor