Skip to content

vitorccs/esp32-c3-relay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32-C3 LED Relay

A simple ESP32-C3 project to control a LED strip via a web interface and a physical push button. The web page reflects the current LED state in real time.

Turned Off

Turned On

The push button

Simple API

Additionally, the LED can be controlled via a simple API, making it easy to integrate with home automation (e.g.: set up a cron job to turn it on and off automatically):

  • POST http://192.168.1.190/off
  • POST http://192.168.1.190/on

NOTE: Change http://192.168.1.190 to your actual device IP. Assign a Static IP to your device in your home router.

Protoboard

The connectors are: 12v Power Source, Push Button, 12v LED Strip.

Schematics

Option A) 5v LED Strip

Option B) 12v LED Strip

Notes:

  1. Gate resistor (220Ω) is optional but recommended to prevent spikes.
  2. Pull-down resistor (10kΩ) between Gate and GND is optional but prevents accidental turn-on during boot.

Components

  • 01 ESP32-C3 Mini board
  • 01 Push Button
  • 01 Green LED
  • 02 220Ω Resistors
  • 01 10KΩ Resistor
  • 01 N-channel MOSFET able to work with 3.3v logic (e.g.: IRFZ44N)
  • 01 LED Strip (5v or 12v)
  • 01 Power Supply (5v or 12v)
  • 01 Mini 360 DC-DC Bulk Converter (in case the Power Supply is 12v)

About PlatformIO IDE

Platform IO is a plugin for Microsoft Virtual Studio Code. It is a more robust IDE compared to official Arduino IDE. It also allows us to easily create our own private libraries and use a more object oriented code.

About the code

The PINs can be customized in the main.cpp

#include <Arduino.h>
#include <NoDelay.h>
#include <HttpServer.h>
#include <WifiHandler.h>
#include <PushButton.h>
#include "types.h"

#define RELAY_PIN 0
#define BUTTON_PIN 1
#define LED_PIN 2
#define WIFI_SSID "MY_SSID"
#define WIFI_PWD "MY_PASSWORD"

Fritzing file

About

Simple ESP32-C3 project to control a LED strip from a web page

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages