Example Code for Arduino - Setting the UART Baud Rate
Last revision 2026/06/08
To set the UART baud rate for the AI Posture and Gesture Sensor, connect it to the FireBeetle 2 ESP32-E using UART. Use the DIP switch to change the communication method from I²C to UART, then power cycle the sensor. In the Arduino IDE, include the DFRobot_HumanPose library and use the provided code to modify the baud rate. The example changes the baud rate from 9600 to 115200, which is saved permanently. Ensure the sensor is restarted for the change to take effect.
Hardware Preparation
- Gravity: AI Posture & Gesture Sensor (SKU: SEN0670) ×1
- FireBeetle 2 ESP32‑E (SKU: DFR0654)
- USB Type‑C cable ×1
- PC ×1
Software Preparation
- Programming environment: Click to download Arduino IDE
- Download and install the sensor library: DFRobot_HumanPose
- Please click here to view: How to install a library?
Wiring Diagram
UART Connection

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.

Was this article helpful?
