Skip to content

Instantly share code, notes, and snippets.

@peterhellberg
Last active November 24, 2025 12:50
Show Gist options
  • Select an option

  • Save peterhellberg/649a5b14717f2b6d8ff5112972aab497 to your computer and use it in GitHub Desktop.

Select an option

Save peterhellberg/649a5b14717f2b6d8ff5112972aab497 to your computer and use it in GitHub Desktop.
ESP32-C3 experiment

esp32-c3-experiment

Steps

Requires the Arduino CLI

# Dependencies
arduino-cli lib install "u8g2"
arduino-cli lib install "WS2812FX"

# Compile and upload
arduino-cli compile -b esp32:esp32:esp32c3 --upload --port /dev/cu.usbmodem1101

Links

@peterhellberg
Copy link
Author

#include <Arduino.h>
#include <WS2812FX.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

#define LED_COUNT 1
#define LED_PIN 2
#define SDA_PIN 5
#define SCL_PIN 6

WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_RGB + NEO_KHZ800);

// EastRising 0.42" OLED
U8G2_SSD1306_72X40_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);   
                                                                           
void u8g2_prepare(void) {
  u8g2.setFont(u8g2_font_ncenB14_tr);
  u8g2.setFontRefHeightExtendedText();
  u8g2.setDrawColor(1);
  u8g2.setFontPosTop();
  u8g2.setFontDirection(0);
}

void codeBase(uint8_t a) {
  u8g2.drawStr( 10, 0, "Code");
  u8g2.drawStr( 0, 13, "Base");
  u8g2.drawStr( 20, 26, "2025");
}

uint8_t draw_state = 0;

void draw(void) {
  u8g2_prepare();
 
  codeBase(draw_state&7); 
}


void setup(void) {
  ws2812fx.init();
  ws2812fx.setBrightness(255);
  ws2812fx.setSpeed(1000);
  ws2812fx.setColor(0x007BFF);
  ws2812fx.setMode(FX_MODE_STATIC);
  ws2812fx.start();
  Wire.begin(SDA_PIN, SCL_PIN);   
  u8g2.begin();
}

void loop(void) {
  ws2812fx.service();
 
  // picture loop 
  u8g2.clearBuffer();
  draw();
  u8g2.sendBuffer();
  
  // increase the state
  draw_state++;
  if ( draw_state >= 12*8 )
    draw_state = 0;

  // deley between each page
  delay(100);
}

@peterhellberg
Copy link
Author

A few other libraries available to install with the arduino-cli;

arduino-cli lib install "OneBitDisplay"
arduino-cli lib install "BitBang_I2C"
arduino-cli lib install "SparkFun SCD4x Arduino Library"
arduino-cli lib install "AnimatedGIF"
arduino-cli lib install "thinger.io"
arduino-cli lib install "Adafruit NeoPixel"

@peterhellberg
Copy link
Author

@peterhellberg
Copy link
Author

peterhellberg commented Nov 24, 2025

CodeBase2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment