Unit 8Servos2‑I2C Control Protocol (Firmware V2.0)
1. Hardware Interface
| Item | Description |
|---|---|
| I2C slave address (7-bit) | 0x25 (base address, supporting 0x25~0x34) |
| Communication rate | Standard 100 kbps / Fast 400 kbps |
| Main control chip | STM32F030F4P6 |
| Number of channels | 8 IO channels, supporting INPUT / OUTPUT / ADC / SERVOS / PWM / RGB modes |
| Expansion interface | HY2.0‑4P I2C port |
Note: base address 0x25 + selector position (0~15) gives the final I2C slave address, range 0x25 ~ 0x34.
2. Register Overview
Continuous read/write areas: 0x00~0x07, 0x10~0x17, 0x20~0x27, 0x30~0x37, 0x40~0x4F, 0x50~0x57, 0x60~0x67, 0x70~0x77, 0x80~0xB0, 0xD0~0xD3, 0xE0~0xEB, 0xF0~0xF7, 0xFE~0xFF
| Register Address | Readable | Writable | Description |
|---|---|---|---|
0x00 | ✓ | ✓ | IO0‑IO7 mode configuration register; Value:0~5; 0:INPUT, 1:OUTPUT, 2:ADC, 3:SERVOS, 4:RGB, 5:PWM; default 0; 0 = no pull-up/pull-down |
0x10 | ✓ | ✓ | IO0‑IO7 pull-up/pull-down configuration; 1:pull-up, 2:pull-down; default 0 |
0x20 | ✓ | ✗ | IO input level read |
0x30 | ✓ | ✓ | IO output level setting; 1=high level, 0=low level |
0x40 | ✓ | ✗ | ADC low byte data, IOx_L |
0x50 | ✓ | ✓ | ADC high byte data, IOx_H; ADC value 0~4095; servo angle 0~180 |
0x60 | ✓ | ✓ | PWM duty cycle configuration; value 0~100 |
0x70 | ✓ | ✓ | RGB configuration register; bit[7:6] reserved; bit[5] refresh bit; bit[4‑0] RGB count; default 0; RGB mode supports WS2812 only |
0x80~0xB0 | ✓ | ✓ | RGB color data registers, B1/R1/G1 … B16/R16/G16 |
0xD0 | ✓ | ✓ | TIM2_FREQ_L / TIM2_FREQ_H / TIM3_FREQ_L / TIM3_FREQ_H; 1~65535; TIM2 controls GPIO0~GPIO3; TIM3 controls GPIO4~GPIO7; servos must be configured to 50Hz |
0xE0~0xEB | ✓ | ✗ | Device unique UID, 12 bytes |
0xF0 | ✓ | ✓ | Multi-purpose composite register: voltage read (Grove voltage, DC voltage), current read; Offset configuration; Refresh (write 1 to refresh the I2C address); firmware version Version; I2C address Address (0x25‑0x34) |
3. I2C Read and Write Operations
3.1 Write Operation (Host Write)
Write format: [Register Address][Data Byte]
- Single-byte write:
REG_ADDR + 1Byte Data - Multi-byte continuous write: start register address + N consecutive data bytes, supporting batch writing to continuous register areas.
Important: to configure Servo mode, the corresponding timer must be set to 50Hz, otherwise PWM cannot output the servo signal.
- TIM2: PWM frequency of GPIO0~GPIO3 channels
- TIM3: PWM frequency of GPIO4~GPIO7 channels
3.2 Read Operation (Host Read)
- The host sends the 1-byte start register address
- An I2C read is initiated, and the module returns the subsequent register data sequentially from that address
- Reading a contiguous register area in one operation is supported.
4. IO Mode Configuration Register 0x00
Each IO channel can be configured independently. Value definitions:
| Value | Mode | Description |
|---|---|---|
0 | INPUT | Input mode, pull-up/pull-down configurable |
1 | OUTPUT | Normal output mode |
2 | ADC | ADC acquisition mode, 0‑4095 |
3 | SERVOS | Servo mode, angle 0‑180°; depends on the TIMx timer at 50Hz |
4 | RGB | WS2812 RGB strip mode |
5 | PWM | PWM output mode, duty cycle 0‑100 |
By default all IOs are in INPUT mode with no pull-up/pull-down.
5. Pull-up/Pull-down Configuration Register 0x10
| Value | Function |
|---|---|
0 | No pull-up/pull-down (floating input) |
1 | Pull-up enabled |
2 | Pull-down enabled |
6. IO Level Registers
0x20(R): IO input status read,1is high level,0is low level.0x30(R/W): IO output level setting, effective in OUTPUT mode only,1outputs high level,0outputs low level.
7. ADC Registers 0x40 / 0x50
The ADC is 12-bit, with a value range of 0 ~ 4095.
0x40: ADC low byte of each channel; 0x50: ADC high byte of each channel.
8. PWM Duty Cycle Register 0x60
- Value range:
0 ~ 100, representing a percentage. - The PWM frequency is configured by the TIM2 / TIM3 registers.
9. RGB Control Registers 0x70 ~ 0xB0
0x70: bit5=1 triggers a WS2812 data refresh; bit[4‑0] sets the number of RGB LEDs.0x80‑0xB0: RGB data, stored in B, G, R order, supporting up to 16 WS2812 LEDs.
RGB mode supports WS2812 single-wire RGB LEDs only.
10. Timer Frequency Registers 0xD0‑0xD3
| Address | Item | Description |
|---|---|---|
0xD0 | TIM2_FREQ_L | TIM2 frequency low byte, GPIO0‑3 |
0xD1 | TIM2_FREQ_H | TIM2 frequency high byte |
0xD2 | TIM3_FREQ_L | TIM3 frequency low byte, GPIO4‑7 |
0xD3 | TIM3_FREQ_H | TIM3 frequency high byte |
Hard requirement for servo driving: set the TIMx frequency to 50Hz, otherwise Servo mode produces no PWM output.
Value range: 1 ~ 65535.
11. UID Read 0xE0‑0xEB
- 12 bytes in total, read-only; the device unique hardware UID; supports continuous reading starting from any offset within the range.
12. Composite Register 0xF0 (Multiple Functions Multiplexed)
This register area is multiplexed; read and write accesses correspond to different sub-functions.
12.1 Voltage and Current Read (Read)
- Grove voltage, DC high voltage: unit mV
- Total current sampling: unit mA
Hardware detection indicator LED logic:
- DC high voltage detection: when the DC voltage is higher than 8.5V, the red LED lights up.
- Grove low voltage detection: when the Grove voltage is lower than 4.5V, the green LED lights up.
12.2 I2C Address Modification (Write)
Write to 0xF0:
- Offset: selector offset
0‑15 - Refresh bit write
1: refresh and update the I2C slave address;
Final I2C address = 0x25 + Offset, range 0x25 ~ 0x34; the configuration takes effect immediately and is saved after power-off.
12.3 Firmware Version Read (Read)
Read the corresponding offset of 0xF0 to return the Software Version.
12.4 Current I2C Address Read (Read)
Read the corresponding offset of 0xF0 to return the currently effective I2C slave address.
13. Power-on Default State
- All IOs default to INPUT mode with no pull-up/pull-down.
- TIM2 / TIM3 default to 0; using Servo mode requires manually setting 50Hz.
- The RGB refresh bit defaults to 0.
- The I2C default base address is
0x25.
14. Important Notes
- Configuring Servo mode requires setting the corresponding timer frequency to 50HZ, otherwise PWM will not be output.
- The PWM frequency in PWM and Servo modes is controlled separately by two timers: TIM2 controls GPIO0~GPIO3, TIM3 controls GPIO4~GPIO7.
- When the DC voltage is higher than 8.5V, the small red LED lights up.
- When the GROVE voltage is lower than 4.5V, the small green LED lights up.
- RGB mode supports WS2812 RGB LEDs only.
- I2C continuous read/write operations are only allowed within the "continuous read/write areas" marked in this document.
- The module has no IRQ interrupt pin; all status is polled by the host through active I2C reads.
15. Recommended Operation Order
- Power on, then read the UID/version to verify I2C communication;
- Set the IO modes according to your application (INPUT / OUTPUT / ADC / SERVOS / PWM / RGB);
- If using Servo, configure TIM2 / TIM3 = 50Hz;
- Configure the pull-up/pull-down, PWM duty cycle, and RGB parameters;
- Read and write IO, ADC, and voltage/current;
- To modify the I2C address: set the Offset and write Refresh=1 to refresh the address.