ESP32-S3 onboard RGB LED

Hi. Does someone know how to control onboard RGB LED on ESP32-S3?

2 Likes

Its a neopixel LED so use an appropriate library such as;

Thank you. I followed the example. It compiles but the LED doesn't work neither on pi 38 nor 48.

#include <Adafruit_NeoPixel.h> 

#define PIN 48
#define NUMPIXELS 1

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 500

void setup () {  
  
  pixels.begin();

}

void loop () {

  pixels.clear();

  for(int i=0; i<NUMPIXELS; i++) {
    pixels.setPixelColor(i, pixels.Color(0, 150, 0));
    pixels.show();
    delay(DELAYVAL);
  }

}

Select an esp32s3 as your board type. Go to Files->Examples->ESP32->GPIO->BlinkRGB for an example of how to use the onboard RGB LED.

If you use LED_BUILTIN as the LED name, the RGB LED will blink white like a normal LED.

You don't mention which exact board you have :wink: I found https://esp32s3.com/files/schematic-pros3.pdf which has the RGB LED on pin IO18.

Note:
I do not know anything about ESP32-S3 so IO18 might well be pin 38 or 48; no idea.

PS
One of the AdaFruit boards has the Neopixel on pin IO33 (schematic: Adafruit Learning System)

I went through all the pins, both with digitalWrite and pixels with no effect. It could also be that my board is damaged. I'll figure it out somehow.

Thank you very much.

I thought there may be a problem with PWM on ESP32-S3, which I could also not get working. So I tried this code on ESP32-C3, it works just fine. It really looks like it is a PWM problem after all.

#include <Adafruit_NeoPixel.h> 

#define PIN 8 // ESP32-C3 built-in RGB led
#define NUMPIXELS 1

Adafruit_NeoPixel pixels (NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 500


void setup () {  
    Serial.begin (115200);

    Serial.printf ("   PIN %i\n", PIN);          
    
    //pinMode(pin, OUTPUT);           

    pixels.begin();

    pixels.clear();

    for(int i=0; i<NUMPIXELS; i++) {
      pixels.setPixelColor(i, pixels.Color (100, 50, 200));
      pixels.show();
      delay(2000);
    }

}

void loop () {

}

PWM has absolutely nothing to do with NeoPixel-type LEDs.

The Adafruit Neopixel library work fine, for the on board RGB LED, with both my ESP32S3 devkit boards, so its seems unlikely their is an 'issue' with the libraries.

Hey I got the same issue with my esp32-s3-wroom-1 (n16r8) module. The solution was to connect the rgb pins

Then you can use pin 48 to blink the rgb led. I used Fastled library and it works fine.

3 Likes

Indeed. It works! What a funny trick. Thank you.

There's no need to involve any third-party libraries. You can simply use the built-in neopixelWrite function:

I had the same problem with the Waveshare ESP32-S3-DEV-KIT-N8R8. i used the default tutorial (https://www.waveshare.com/wiki/ESP32-S3-DEV-KIT-N8R8) to make the board work with the arduino ide.

no arduino sketch (neither blink led, nor blink rgb) worked though the pinout (https://www.waveshare.com/wiki/File:ESP32-S3-DEV-KIT-N8R8-04.jpg) shows that the rgb led could be controlled with pin 38.

The Library pins_arduino.h defines the pin in a strange way so the default sketch simply doesnt work because the value of RGB_BUILTIN is wrong for this board.

#define PIN_NEOPIXEL        48
static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+PIN_NEOPIXEL;
#define RGB_BUILTIN LED_BUILTIN

RGB_BUILTIN then is 97.

With the default Esp32 BlinkRGB Example and

void loop() {
  #define RGB_BUILTIN 38
  digitalWrite(RGB_BUILTIN, HIGH);   // Turn the RGB LED white
  delay(1000);
...
}

it works.

so look at the pinout of the board. there should be something like RGB_LED somewhere.

try this its worked for me for the same Esp-32-s3 built-in led

#include <Adafruit_NeoPixel.h>

// Define the pin where the built-in RGB LED is connected
#define LED_PIN 48

// Define the number of LEDs in the strip (usually 1 for built-in LED)
#define NUM_LEDS 1

// Create an instance of the Adafruit_NeoPixel class
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
// Initialize the NeoPixel library
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}

void loop() {
// Cycle through some colors

// Red
strip.setPixelColor(0, strip.Color(255, 0, 0)); // Red
strip.show();
delay(1000);

// Green
strip.setPixelColor(0, strip.Color(0, 255, 0)); // Green
strip.show();
delay(1000);

// Blue
strip.setPixelColor(0, strip.Color(0, 0, 255)); // Blue
strip.show();
delay(1000);

// Yellow
strip.setPixelColor(0, strip.Color(255, 255, 0)); // Yellow
strip.show();
delay(1000);

// Cyan
strip.setPixelColor(0, strip.Color(0, 255, 255)); // Cyan
strip.show();
delay(1000);

// Magenta
strip.setPixelColor(0, strip.Color(255, 0, 255)); // Magenta
strip.show();
delay(1000);

// White
strip.setPixelColor(0, strip.Color(255, 255, 255)); // White
strip.show();
delay(1000);

// Turn off
strip.setPixelColor(0, strip.Color(0, 0, 0)); // Off
strip.show();
delay(1000);
}

Thanks for the program [smazaidi] (Profile - smazaidi - Arduino Forum) that got my esp32 S3 Dev kit RGB NeoPixel lighting up very pretty. Pin 48 was the ticket for my dual USB board off of Amazon. Now if I could get this board to work with an older VFO program that runs fine on an esp32 life would be great. Oh well, if everything worked fine on the first try we couldn't learn or have any fun.

#include <Adafruit_NeoPixel.h>

// Define the pin and the number of LEDs

#define LED_PIN 21

#define LED_COUNT 1

// Initialize the NeoPixel library

Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {

strip.begin(); // Initialize the strip

strip.show(); // Initialize all pixels to 'off'

strip.setBrightness(50); // Set brightness (0-255)

}

void loop() {

// Cycle through different colors

setColor(255, 0, 0); // Red

delay(1000);

setColor(0, 255, 0); // Green

delay(1000);

setColor(0, 0, 255); // Blue

delay(1000);

setColor(255, 255, 0); // Yellow

delay(1000);

setColor(0, 255, 255); // Cyan

delay(1000);

setColor(255, 0, 255); // Magenta

delay(1000);

setColor(255, 255, 255); // White

delay(1000);

setColor(0, 0, 0); // Off

delay(1000);

}

void setColor(uint8_t red, uint8_t green, uint8_t blue) {

strip.setPixelColor(0, strip.Color(red, green, blue)); // Set the color of the first pixel

strip.show(); // Update the strip to show the color

}