[Tutorial] Linking VEX Brain V5 with Arduino (or Raspberry Pi, esp32 etc.)

Tutorial: Linking VEX Brain V5 with Arduino (or Raspberry Pi, esp32 etc.)(English&Chinese)

教程:把VEX V5主控与Arduino(或者树莓派,esp32等)连接通信(中英双语)

*All of the files can be found in the link below


:star:Star if you like it

Hey everyone! Today I’ll show you how to handle communication between VEX Brain V5 and Arduino(as example). First we need to know the logic of their communication. We can know the pinout of smart ports from here, so we can find out a simple process:

Black: RS485-A
Red: RS485-B
Green: GND
Yellow: Power(12V)

Hardware 硬件

First of all, we need to buy an RS485 to TTL module in order to change the A and B lines of RS485 represented by the black and red lines of VEX to UART level, and connect the A and B lines and GND on the right side.
Then buy a 12V to 5V step-down module to power the Arduino. Connect GND and VIN to VEX’s GND and Power, connect GND and Vout to Arduino’s GND and VCC (5V)
I made a pcb board to allow the VEX to plug into a breadboard and bring out the pins.
All you have to do is as follows:

Software 软件

Sending information through the serial port on the Arduino side requires this

#define BAUDRATE 115200
//Baudrate, make sure it's the same with VEX side. 
void setup() {
void loop() {

Receiving information through the serial port on the VEX side requires this

motor Arduino = motor(PORT20, ratio18_1, false);

#define BAUDRATE 115200
int main() {

  // Initializing Robot Configuration. DO NOT REMOVE!

  vexGenericSerialEnable(Arduino.index(), 0);
  vexGenericSerialBaudrate(Arduino.index(), BAUDRATE);

Here are all the functions for using the VEX as a generic device.

// Generic serial port comms to any device
void                vexGenericSerialEnable( uint32_t index, int32_t options );
void                vexGenericSerialBaudrate( uint32_t index, int32_t baudrate );
int32_t             vexGenericSerialWriteChar( uint32_t index, uint8_t c );
int32_t             vexGenericSerialWriteFree( uint32_t index );
int32_t             vexGenericSerialTransmit( uint32_t index, uint8_t *buffer, int32_t length );
int32_t             vexGenericSerialReadChar( uint32_t index );
int32_t             vexGenericSerialPeekChar( uint32_t index );
int32_t             vexGenericSerialReceiveAvail( uint32_t index );
int32_t             vexGenericSerialReceive( uint32_t index, uint8_t *buffer, int32_t length );
void                vexGenericSerialFlush( uint32_t index );

*All of the files can be found in the link below


:star:Star if you like it

Wish you good luck !