Skip to main content

reSpeaker XVF3800 USB Mic Array with XIAO ESP32S3 RGB Test

Objective

This code controls the colorful LED ring on the reSpeaker XVF3800 USB 4-Mic Array using an ESP32S3 microcontroller via I2C communication. It changes the LED's effect, color, speed, and brightness by sending specific commands. The ESP32S3 tells the XVF3800 what to do using bytes of data through the Wire library (I2C). You can pick your own colors using RGB values like orange, red, or blue. Once uploaded, the LEDs light up with the effect, color, and brightness you selected.

pir

How It Works

This Arduino sketch is designed to control the WS2812 RGB LED ring on the ReSpeaker XVF3800 using the I2C protocol. It uses the Wire.h library to communicate with the XVF3800's internal controller and send specific instructions to adjust the LED effect, color, speed, and brightness. You can customize the LED behavior without changing the XVF3800 firmware — everything is handled from the ESP32S3!

Code

#include <Wire.h>

#define XMOS_ADDR 0x2C
#define GPO_SERVICER_RESID 20

#define GPO_SERVICER_RESID_LED_EFFECT 12
#define GPO_SERVICER_RESID_LED_COLOR 16
#define GPO_SERVICER_RESID_LED_SPEED 15
#define GPO_SERVICER_RESID_LED_BRIGHTNESS 13

void setup() {
Wire.begin();
Serial.begin(115200);
delay(1000);

setLEDEffect(1); // LED effect ID 1
setLEDColor(0xFF8800); // LED color: orange (24-bit RGB)
setLEDSpeed(1); // Speed: 1
setLEDBrightness(255); // Brightness: max
}

void loop() {
// No repeating actions needed
}

void xmos_write_bytes(uint8_t resid, uint8_t cmd, uint8_t *value, uint8_t write_byte_num) {
Wire.beginTransmission(XMOS_ADDR);
Wire.write(resid);
Wire.write(cmd);
Wire.write(write_byte_num);
for (uint8_t i = 0; i < write_byte_num; i++) {
Wire.write(value[i]);
}
Wire.endTransmission();
}

void setLEDEffect(uint8_t effect) {
uint8_t payload[1] = { effect };
xmos_write_bytes(GPO_SERVICER_RESID, GPO_SERVICER_RESID_LED_EFFECT, payload, 1);
Serial.println("LED effect set.");
}

void setLEDColor(uint32_t color) {
uint8_t payload[4] = {
(uint8_t)(color & 0xFF), // Red
(uint8_t)((color >> 8) & 0xFF), // Green
(uint8_t)((color >> 16) & 0xFF), // Blue
0x00 // Reserved (some systems may expect 4 bytes)
};
xmos_write_bytes(GPO_SERVICER_RESID, GPO_SERVICER_RESID_LED_COLOR, payload, 4);
Serial.println("LED color set.");
}

void setLEDSpeed(uint8_t speed) {
uint8_t payload[1] = { speed };
xmos_write_bytes(GPO_SERVICER_RESID, GPO_SERVICER_RESID_LED_SPEED, payload, 1);
Serial.println("LED speed set.");
}

void setLEDBrightness(uint8_t brightness) {
uint8_t payload[1] = { brightness };
xmos_write_bytes(GPO_SERVICER_RESID, GPO_SERVICER_RESID_LED_BRIGHTNESS, payload, 1);
Serial.println("LED brightness set.");
}

pir

Tech Support & Product Discussion

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...