Example Code for Arduino-I2C Mode Output 5V in 0-5V Range
Last revision 2026/02/11
Communicate with the GP8600 module via the I2C interface on the ESP32-E main controller to control the module to output 5V within the 0-5V range, and verify the result using a multimeter.
Hardware Preparation
- DFR1229 GP8600: I2C&PWM to 0-5V&0-10V&4-20mA ×1
- DFR0654 FireBeetle 2 ESP32-E ×1
- Multimeter ×1
- Several jumper wires
Software Preparation
- Download and install Arduino IDE: [Download Link]
- Download dependent libraries:
- DFRobot_GP8XXX Library: [Download Link]
- DFRobot_RTU Library: [Download Link]
- Library Installation Guide: [View Installation Tutorial]
Wiring Diagram

Connect the GP8600 module to the ESP32-E as shown in the diagram. The core corresponding relationships are as follows:
- Module I2C pin "+" → ESP32-E 3.3V
- Module I2C pin "-" → ESP32-E GND
- Module I2C pin "SCL" → ESP32-E SCL (default GPIO22)
- Module I2C pin "SDA" → ESP32-E SDA (default GPIO21)
Other Preparation Work
- DIP switch configuration: A0=0, A1=0, A2=0 (I2C address = 0x58)
Sample Code
Open Arduino IDE, copy the following code, and upload it to the ESP32-E:
#include <DFRobot_GP8XXX.h>
// Enable I2C communication mode
#define I2C_COMMUNICATION
// I2C address (modify according to the settings on the back of the module, default: 0x58)
#define MODULE_I2C_ADDRESS 0x58
DFRobot_GP8600_I2C GP8600(&Wire, MODULE_I2C_ADDRESS);
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize the sensor; retry continuously if initialization fails
while (GP8600.begin() != 0) {
Serial.println("Communication with the device failed. Please check if the connection is normal or if the device address is set correctly.");
delay(1000);
}
Serial.println("Successful connection!");
// Set the DAC output range to 0-5V
GP8600.setDACOutRange(GP8600.eOutputRange5V);
// Set output data (0-65535 corresponds to 0-5V)
uint16_t data = 65535;
GP8600.setDACOutData(data);
}
void loop() {
// No operations required in the loop
}
Result
- Set the multimeter to the "DC V" range;
- Connect the red probe to the module's "OUT" terminal and the black probe to the module's "GND" terminal;
- Under normal conditions, the measured voltage should be close to 5V. In this example, the actual measured output voltage is 5.009V.

Was this article helpful?
