ESP32 – ESP-C3-32S-Kit
Table of Contents
Links
- https://www.waveshare.com/wiki/ESP-C3-32S-Kit
- https://www.waveshare.com/w/upload/0/0b/Esp-c3-32s-kit-v1.0_specification.pdf
- https://www.electronics-lab.com/getting-started-with-espressifs-esp32-c3-devkitm-1-on-arduino-ide/
- https://github.com/Wobi848/ESP-C3-32S-Kit_Button_Leds_Testing
- https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf
- https://espressif-docs.readthedocs-hosted.com/projects/arduino-esp32/en/latest/boards/ESP32-C3-DevKitM-1.html
Short Example to controll onBoard Butt0n and LED’s.
Starter Code Still in Progress
// ESP32 BOARDS PACKAGE
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
// https://4wobi.com/2022/04/14/esp32-esp-c3-32s-kit/
//
// Install ESP32 Board Package
// https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
//
// ESP32C3 Dev Module
// Flash Frequency: 40Mhz
// Flash Size: 2MB(16Mb)
//
// Source: https://microcontrollerslab.com/esp32-rgb-led-web-server/
//
/* Ai-Thinker ESP-C3-32S-Kit
* RGB LED: IO5 RGB blue;
* IO3 RGB red;
* IO4 RGB green;
* WARLM LED: IO19
* COLD LED: IO18
* RIGHT BUTTON: IO9
*/
#include
#include
String webpage = ""
"RGB control "
""
""
"";
// WIFI SETTINGS
const char* ssid = "WIFI";
const char* password = "PW";
const byte DNS_PORT = 53;
// BUTTON SETTINGS
const int buttonPin = 9;
int buttonState = 1;
int lastButtonState = 1;
// LED SETTINGS
const int warmPin = 18;
const int coldPin = 19;
int lampState = 0;
unsigned int ledTimer = 5000;
unsigned long ledLastTimer = 0;
// RGB LED SETTINGS
const int red_pin = 3;
const int green_pin = 4;
const int blue_pin = 5;
// Setting PWM frequency, channels and bit resolution
const int frequency = 5000;
const int redChannel = 0;
const int greenChannel = 1;
const int blueChannel = 2;
const int resolution = 8;
WebServer webServer(80);
void handleRoot() {
String red_pin = webServer.arg(0);
String green_pin = webServer.arg(1);
String blue_pin = webServer.arg(2);
if ((red_pin != "") && (green_pin != "") && (blue_pin != ""))
{
ledcWrite(redChannel, 1023 - red_pin.toInt());
ledcWrite(greenChannel, 1023 - green_pin.toInt());
ledcWrite(blueChannel, 1023 - blue_pin.toInt());
}
Serial.print("Red: ");
Serial.println(red_pin.toInt());
Serial.print("Green: ");
Serial.println(green_pin.toInt());
Serial.print("Blue: ");
Serial.println(blue_pin.toInt());
Serial.println();
webServer.send(200, "text/html", webpage);
}
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(warmPin, OUTPUT);
pinMode(coldPin, OUTPUT);
ledcSetup(redChannel, frequency, resolution);
ledcSetup(greenChannel, frequency, resolution);
ledcSetup(blueChannel, frequency, resolution);
ledcAttachPin(red_pin, redChannel);
ledcAttachPin(green_pin, greenChannel);
ledcAttachPin(blue_pin, blueChannel);
delay(1000);
Serial.begin(115200);
Serial.println();
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi ..");
while (WiFi.status() != WL_CONNECTED) {
Serial.print('.');
delay(1000);
}
Serial.println(WiFi.localIP());
webServer.on("/", handleRoot);
webServer.begin();
}
void loop() {
webServer.handleClient();
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && lastButtonState == 0) {
Serial.println("Button HIGH");
lastButtonState = 1;
} else if (buttonState == LOW && lastButtonState == 1) {
Serial.println("Button LOW");
lastButtonState = 0;
}
unsigned long now = millis();
if (now - ledLastTimer > ledTimer) {
ledLastTimer = now;
if (lampState == 0) {
lampState = 1;
Serial.println("Cold High");
digitalWrite(warmPin, LOW);
digitalWrite(coldPin, HIGH);
}
else {
lampState = 0;
Serial.println("Warm High");
digitalWrite(coldPin, LOW);
digitalWrite(warmPin, HIGH);
}
}
}
Download Code .zip
–