Example Code for Arduino-I2C Communication
Last revision 2026/01/08
This article guides you through setting up I2C communication on Arduino using the Beetle RP2350 and GR10-30 Gesture Recognition Sensor, complete with hardware requirements, wiring diagrams, and sample code ensuring effective gesture detection and data display via the Arduino IDE serial monitor.
Hardware Preparation
Software Preparation
- Download and install RTU library
- Download and install GR10-30 library file
Wiring Diagram

| Mainboard | Pin name | Module | Pin name |
|---|---|---|---|
| Beetle RP2350 | GND | Analog Angle Sensor | GND |
| Beetle RP2350 | 3V3 | Analog Angle Sensor | VCC |
| Beetle RP2350 | 4 | Analog Angle Sensor | SDA |
| Beetle RP2350 | 5 | SIM7600G 4G Module | SCL |
Sample Code
#include "DFRobot_GR10_30.h"
DFRobot_GR10_30 gr10_30(GR10_30_DEVICE_ADDR, &Wire);
void setup() {
Wire.begin();
Serial.begin(115200);
while(gr10_30.begin() != 0){
Serial.println(" Sensor initialize failed!!");
delay(1000);
}
Serial.println(" Sensor initialize success!!");
gr10_30.enGestures(GESTURE_UP|GESTURE_DOWN|GESTURE_LEFT|GESTURE_RIGHT|GESTURE_FORWARD|GESTURE_BACKWARD|GESTURE_CLOCKWISE|GESTURE_COUNTERCLOCKWISE|GESTURE_CLOCKWISE_C|GESTURE_COUNTERCLOCKWISE_C);
}
void loop() {
if(gr10_30.getDataReady()){
uint16_t gestures = gr10_30.getGesturesState();
if(gestures&GESTURE_UP){
Serial.println("Up");
}
if(gestures&GESTURE_DOWN){
Serial.println("Down");
}
if(gestures&GESTURE_LEFT){
Serial.println("Left");
}
if(gestures&GESTURE_RIGHT){
Serial.println("Right");
}
if(gestures&GESTURE_FORWARD){
Serial.println("Forward");
}
if(gestures&GESTURE_BACKWARD){
Serial.println("Backward");
}
if(gestures&GESTURE_CLOCKWISE){
Serial.println("Clockwise");
}
if(gestures&GESTURE_COUNTERCLOCKWISE){
Serial.println("Contrarotate");
}
if(gestures&GESTURE_CLOCKWISE_C){
Serial.println("Continuous clockwise");
}
if(gestures&GESTURE_COUNTERCLOCKWISE_C){
Serial.println("Continuous counterclockwise");
}
}
delay(1);
}
Result
Open the Arduino IDE serial monitor, the monitor window correctly printed out the sensor data.
Additional Information
Beetle RP2350 provides 1 set of I2C communication interface: I2C0. The pin distribution is as follows:
| Pin Number | I2C Function |
|---|---|
| 4 | I2C0/SDA |
| 5 | I2C0/SCL |
Was this article helpful?
