Finding the default sketches

voidzero
Posts: 6
Joined: Tue Jul 16, 2024 4:22 pm

Finding the default sketches

Postby voidzero » Tue Jul 16, 2024 4:27 pm

Hi everyone,

Totally new to the ESP32, but I just received my order of two boards, the ESP32-C6-DevKitM-1 and ~C-1 and can't wait to try them out.

However, what I would like to have first is the "default sketches". I tried to search this board but I am getting a server error 500.

Where can I find the default sketches so that I can always revert to what is on the board upon factory arrival?

Much thanks! Mark

MicroController
Posts: 1734
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Finding the default sketches

Postby MicroController » Wed Jul 17, 2024 8:56 am

Not sure if there's any firmware pre-installed on the DevKits from the factory.
Since on the ESP32s the 'first-stage' bootloader is in the chip's ROM, there is no need for anything to be in flash to be able to flash a new application.
I.o.w., as long as you don't mess with the wrong e-fuses, it's pretty much impossible to 'brick' your ESP; you will always be able to just flash a new program no matter how badly the previous code behaves.

voidzero
Posts: 6
Joined: Tue Jul 16, 2024 4:22 pm

Re: Finding the default sketches

Postby voidzero » Wed Jul 17, 2024 9:29 am

Hi, thanks for your message.

When I put power onto the chip, the RGB LED goes through all 7 base colors. That's the sketch I'd like to have.

voidzero
Posts: 6
Joined: Tue Jul 16, 2024 4:22 pm

Re: Finding the default sketches

Postby voidzero » Wed Jul 17, 2024 1:50 pm

Hi MicroController, well, there's something on there that makes the RGB LED go through its seven colors. I would like to see how that is programmed.

as an aside I'm still trying to find my way with the IDE - I never used Visual Studio Code before - such a large amount of prompts and popups is a bit daunting!

voidzero
Posts: 6
Joined: Tue Jul 16, 2024 4:22 pm

Re: Finding the default sketches

Postby voidzero » Wed Jul 17, 2024 4:20 pm

I guess it doesn't matter that much anyway.

Here's a sketch I wrote that's just a pretty RGB animation.

I use it as a default - when I plug in a board I haven't used in a while and see this animation, I will instantly know the board is ready for use :mrgreen:

Enjoy:

Code: Select all

// These photons hurt my eyes! A low brightness is low enough.
#define MAXBRIGHT 24

// Initial delay during setup
#define IDELAY 600

// Delay between transitions
#define DELAY 100

// Extra after each state has completed
#define EXTRA_DELAY 1000

const int ledPin = RGB_BUILTIN;
int red = MAXBRIGHT;
int green = 0;
int blue = 0;
int state = 0;  // 0: red to yellow, 1: yellow to green, 2: green to cyan, 3: cyan to blue, 4: blue to magenta, 5: magenta to white, 6: white to red

void setup() {
  pinMode(ledPin, OUTPUT);
  neopixelWrite(ledPin, 0, 0, 0);
  delay(DELAY);

  // Let's start by just iterating over each color
  neopixelWrite(ledPin, MAXBRIGHT, 0, 0);
  delay(IDELAY);
  neopixelWrite(ledPin, 0, MAXBRIGHT, 0);
  delay(IDELAY);
  neopixelWrite(ledPin, 0, 0, MAXBRIGHT);
  delay(IDELAY);
  neopixelWrite(ledPin, MAXBRIGHT, MAXBRIGHT, 0);
  delay(IDELAY);
  neopixelWrite(ledPin, 0, MAXBRIGHT, MAXBRIGHT);
  delay(IDELAY);
  neopixelWrite(ledPin, MAXBRIGHT, 0, MAXBRIGHT);
  delay(IDELAY);
  neopixelWrite(ledPin, MAXBRIGHT, MAXBRIGHT, MAXBRIGHT);
  delay(IDELAY);

  // Smoothly fade out
  for (int i=MAXBRIGHT; i>=0; i--) {
    neopixelWrite(ledPin, i, i, i);
    delay(DELAY);
  }
  delay(EXTRA_DELAY);

  // Fade into red
  for (int i=0; i<=MAXBRIGHT; i++) {
    neopixelWrite(ledPin, i, 0, 0);
    delay(DELAY);
  }
  delay(EXTRA_DELAY);

}

void loop() {
  switch(state) {
    case 0: // red to yellow
      green++;
      if (green >= MAXBRIGHT) { delay(EXTRA_DELAY); state = 1; }
      break;
    case 1: // yellow to green
      red--;
      if (red <= 0) { delay(EXTRA_DELAY); state = 2; }
      break;
    case 2: // groen to cyan
      blue++;
      if (blue >= MAXBRIGHT) { delay(EXTRA_DELAY); state = 3; }
      break;
    case 3: // cyan to blue
      green--;
      if (green <= 0) { delay(EXTRA_DELAY); state = 4; }
      break;
    case 4: // blue to magenta
      red++;
      if (red >= MAXBRIGHT) { delay(EXTRA_DELAY); state = 5; }
      break;
    case 5: // magenta to white
      green++;
      if (green >= MAXBRIGHT) { delay(EXTRA_DELAY); state = 6; }
      break;
    case 6: // white to red
      green--;
      blue--;
      if (green <= 0 && blue <= 0) { delay(EXTRA_DELAY); state = 0; }
      break;
  }

  neopixelWrite(ledPin, red, green, blue);

  delay(DELAY);
}

Horvat
Posts: 16
Joined: Thu May 02, 2024 8:40 am

Re: Finding the default sketches

Postby Horvat » Thu Jul 18, 2024 8:46 pm

You can extract original fw via esptool read_flash. For devices like Sonoff POW it may be useful to be able to revert to original FW before flashing Tasmota or esphome.

Who is online

Users browsing this forum: Bing [Bot] and 178 guests