Hi. Does someone know how to control onboard RGB LED on ESP32-S3?
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 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.
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
}
The UM ProS3 was mentioned here, and incase you came here because of that (like I did), you might find that the BlinkRGB example does not work also. Just for a different reason. (Not the same solution as found here.)
This is because the RGB led on the UM ProS3 is powered by the second "LDO2" 3.3V power line, which for me was off by default. Thus, you need to enable this separate "LDO2" 3.3v power line in the "setup()" to get the BlinkRGB example to work.
On the UM ProS3, the LDO2 enable pin is "RGB_PWR" or "LDO2", and for me was pin 17. The RGB pin was 18. (From "pins_arduino.h" in the "...\variants\um_pros3" ESP32 hardware folder for the Arduino IDE.)
See the two lines added to the "setup()" code, just below the "// No need to initialize the RGB LED" comment line...
/*
BlinkRGB
Demonstrates usage of onboard RGB LED on some ESP dev boards.
Calling digitalWrite(RGB_BUILTIN, HIGH) will use hidden RGB driver.
RGBLedWrite demonstrates controll of each channel:
void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val)
WARNING: After using digitalWrite to drive RGB LED it will be impossible to drive the same pin
with normal HIGH/LOW level
*/
//#define RGB_BRIGHTNESS 64 // Change white brightness (max 255)
// the setup function runs once when you press reset or power the board
void setup() {
// No need to initialize the RGB LED
pinMode(RGB_PWR , OUTPUT); // Set the RGB_PWR pin to OUTPUT
digitalWrite(RGB_PWR , HIGH); // Turn on the RGB_PWR (LDO2)
}
// the loop function runs over and over again forever
void loop() {
#ifdef RGB_BUILTIN
digitalWrite(RGB_BUILTIN, HIGH); // Turn the RGB LED white
delay(1000);
digitalWrite(RGB_BUILTIN, LOW); // Turn the RGB LED off
delay(1000);
neopixelWrite(RGB_BUILTIN,RGB_BRIGHTNESS,0,0); // Red
delay(1000);
neopixelWrite(RGB_BUILTIN,0,RGB_BRIGHTNESS,0); // Green
delay(1000);
neopixelWrite(RGB_BUILTIN,0,0,RGB_BRIGHTNESS); // Blue
delay(1000);
neopixelWrite(RGB_BUILTIN,0,0,0); // Off / black
delay(1000);
#endif
}
I have an ESP32-S3 Devkit C1 hw rev 1.0. It doesn't have that pad that i can short. And none of the program is working to light up that rgb led. It works fine for other stuff. But I cant just light up that led. Help pls !
the following worked on my ESP32-S3-DevKitC-1
// test RGB LED
// https://github.com/espressif/arduino-esp32/blob/114965010529c004ce914fea773095274ea2ce4d/libraries/ESP32/examples/GPIO/BlinkRGB/BlinkRGB.ino#L25-L37
void setup() {
// No need to initialize the RGB LED
Serial.begin(115200);
delay(3000);
#ifdef RGB_BUILTIN
Serial.println("RGB_BUILTIN");
#else
Serial.println("no RGB_BUILTIN");
#endif
}
// the loop function runs over and over again forever
void loop() {
#ifdef RGB_BUILTIN
digitalWrite(RGB_BUILTIN, HIGH); // Turn the RGB LED white
delay(1000);
digitalWrite(RGB_BUILTIN, LOW); // Turn the RGB LED off
delay(1000);
neopixelWrite(RGB_BUILTIN,RGB_BRIGHTNESS,0,0); // Red
delay(1000);
neopixelWrite(RGB_BUILTIN,0,RGB_BRIGHTNESS,0); // Green
delay(1000);
neopixelWrite(RGB_BUILTIN,0,0,RGB_BRIGHTNESS); // Blue
delay(1000);
neopixelWrite(RGB_BUILTIN,0,0,0); // Off / black
delay(1000);
#endif
}
EDIT: Board I selected Tools>Board>ESP32S3 Dev Module
RGB_BUILTIN defined by ESP32 Dev Module works on the ESP32-S3-DevKitC-1 other ESP32S3 boards may have an onboard LRGB connected to a different pin or no RGB at all