Example Code for Arduino - Setting the UART Baud Rate

Last revision 2026/06/08

Step-by-step guide: hardware and software setup → UART wiring for AI posture and gesture sensor SEN0670 → Arduino example to change UART baud rate from 9600 to 115200 using HumanPose library and ESP32 Serial1. Docs → Tutorials → Projects → SEN0670 → Sensor Category.

Hardware Preparation

Software Preparation

Wiring Diagram

UART Connection
SEN0670-UART Wiring

Connection Description:

Sensor Pin: VCC Connect to Main Controller Pin: 5V
Sensor Pin: GND Connect to Main Controller Pin: GND
Sensor Pin: R Connect to Main Controller Pin: 26/D3
Sensor Pin: T Connect to Main Controller Pin: 25/D2

Note:

  • The default communication method of the sensor is I²C. If you need to switch to UART, use the on‑board DIP switch to change the communication method.
  • After switching, the sensor must be powered off and on again for the change to take effect.

Sample Code

**Function: **This example uses the sensor's default initial baud rate of 9600 to establish device connection, allowing one‑click modification and permanent saving of the sensor's UART serial communication baud rate to accommodate different data transmission requirements.

#include <DFRobot_HumanPose.h>

// ESP32 hardware serial 1: RX=25, TX=26, sensor default baud rate 9600
DFRobot_HumanPose_UART humanPose(&Serial1, 9600, 25, 26);

void setup() {
  Serial.begin(115200);
  Serial1.begin(9600);
  delay(100);

  while (!humanPose.begin()) {
    Serial.println("Connection failed...");
    delay(1000);
  }
  Serial.println("Connection successful!");

  // Change baud rate to 115200
  humanPose.setBaud(DFRobot_HumanPose_UART::eBaud_115200);
  Serial.println("✅ Baud rate successfully changed to 115200!");
}

void loop() {
}

Result:

The serial monitor prints a success message indicating that the baud rate has been changed. Please restart the sensor for the change to take effect.

SEN0670-Set baud

Was this article helpful?

TOP