Skip to content

ReSpeaker USB 4 Mic Array LED Control Protocol

Yihui Xiong edited this page Jan 23, 2018 · 2 revisions

中文

We can control the ReSpeaker USB 4 Mic Array's LEDs through USB. The USB device has a Vendor Specific Class Interface which can be used to send data through USB Control Transfer.

On Linux, we can run lsusb -v -d 2886: to get its USB information:

Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              9 SEEED Control

The libusb's python library - pyusb is used here. The implementation is at usb_pixel_ring_v2.py

The LED control command is sent by pyusb's usb.core.Device.ctrl_transfer(), its parameters are like:

ctrl_transfer(usb.util.CTRL_OUT | usb.util.CTRL_TYPE_VENDOR | usb.util.CTRL_RECIPIENT_DEVICE, 0, command, 0x1C, data, TIMEOUT)

We only need to care about commanddata:

command data note
0 [0] trace mode, LEDs changing depends on VAD* and DOA*
1 [red, green, blue, 0] mono mode, set all RGB LED to a single color
2 [0] listen mode, similar with trace mode, but not turn LEDs off
3 [0] wait mode
4 [0] speak mode
5 [0] spin mode
6 [r, g, b, 0] * 12 custom mode, set each LED to its own color
0x20 [brightness] set brightness, range: 0 ~ 0x1F
0x21 [r1, g1, b1, 0, r2, g2, b2, 0] set color palette
0x22 [vad_led] set center LED: 0 - off, 1 - on, else - depends on VAD
0x23 [volume] show volume, range: 0 ~ 12
0x24 [pattern] set pattern, 0 - Google Home pattern, elf - Echo pattern
  • VAD - Voice Activity Detection
  • DOA - (Sound) Direction Of Arrival