Example Code for Arduino - Get Learned Gesture List

Last revision 2026/06/08

Step-by-step guide to wire the AI posture and gesture sensor SEN0670 to FireBeetle 2 ESP32-E, install DFRobot_HumanPose in Arduino IDE, and run example code to print the learned gesture list via I2C. Path: Docs → Tutorials → Projects → SEN0670 → Gesture & Posture Sensors.

Hardware Preparation

Software Preparation

Wiring Diagram

  1. I²C Connection (The following examples all use I²C communication)

Connection Description:

Sensor Pin: VCC Connect to Main Controller Pin: 5V
Sensor Pin: GND Connect to Main Controller Pin: GND
Sensor Pin: C Connect to Main Controller Pin: 22/SCL
Sensor Pin: D Connect to Main Controller Pin: 21/SDA
  1. 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.

Other preparations

Learned custom gestures or postures can be viewed using the host computer software or via this example. Before using this example, please make sure the sensor has already learned custom gestures/postures using the host computer software.

Sample Code

Function: Initialize gesture sensor via I2C, read and print saved gesture list via serial port.

#include <DFRobot_HumanPose.h>

// Fixed I2C configuration
const uint8_t I2C_ADDR = 0x3A;
DFRobot_HumanPose_I2C humanPose(&Wire, I2C_ADDR);

void setup()
{
  Serial.begin(115200);

  // Initialise the sensor
  while (!humanPose.begin())
  {
    Serial.println("Sensor connection failed...");
    delay(1000);
  }
  Serial.println("Sensor connected successfully\n");

  // Set hand detection mode (change to ePose if you want to read the posture list)
  humanPose.setModelType(DFRobot_HumanPose::eHand);

  // Get learned list
  LearnList list = humanPose.getLearnList(DFRobot_HumanPose::eHand);

  Serial.println("===== Learned List =====");
  for (int i = 0; i < list.size(); i++)
  {
    Serial.print("ID: ");
    Serial.print(i);
    Serial.print("   Name: ");
    Serial.println(list[i].c_str());
  }
}

void loop()
{
  // No loop needed, only read once
}

Result:

| Due to the limited RAM of the Arduino UNO R3 main board, it cannot retrieve the complete learned list. Only the first 4 items of the learned list can be displayed, but recognition functionality is not affected. If 8 custom gestures have been learned, all of them can be recognised and detected. |

Was this article helpful?

TOP