Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-WROOM Bluetooth-Enabled Battery-Powered Button Interface with OLED Display

View and Edit Project In Cirkit DesignerImage of ESP32-WROOM Bluetooth-Enabled Battery-Powered Button Interface with OLED Display

Circuit Documentation

Summary

This circuit is designed to interface an ESP32 microcontroller with various input and output components, including momentary push buttons, a rocker switch, an LED, an OLED display, and a power management system. The ESP32 is programmed to handle Bluetooth communication, display information on the OLED screen, and read battery voltage levels.

Component List

  1. Rocker Switch (4 Pin)

    • Pins: 1, 2, 3, 4
    • Description: A 4-pin rocker switch used to control power to the circuit.
  2. LED (Blue, Two Pin)

    • Pins: Cathode, Anode
    • Description: A blue LED used for visual indication.
  3. Momentary Push Button Switch

    • Pins: 1, 2, 3, 4
    • Description: A 4-pin momentary push button switch used for user input.
  4. 18650 Battery in Holder

    • Pins: GND, VCC
    • Description: A 18650 battery holder providing power to the circuit.
  5. USB Type C Power Delivery Dummy Breakout

    • Pins: SDA, SCL, V+, Vout, GND, Data -, Data +
    • Description: A USB Type C breakout board for power delivery and I2C communication.
  6. Power Cell - LiPo Charger/Booster

    • Pins: JST -, JST +, VCC, GND, 5V, PS, EN
    • Description: A LiPo charger and booster module for managing battery power.
  7. Pushbutton

    • Pins: Pin 1, Pin 2, Pin 3, Pin 4
    • Description: A 4-pin pushbutton used for user input.
  8. ESP32-WROOM

    • Pins: 3V3, EN, SP, SN, 34, 35, 32, 33, 25, 26, 27, 14, 12, GND, 13, 23, 22, TX0, RX0, 21, 19, 18, 5, 17, 16, 4, 0, 2, 15, SD1, SD0, CLK, 5V, CMD, SD3, SD2, USB
    • Description: A versatile microcontroller with built-in Wi-Fi and Bluetooth capabilities.
  9. OLED 128x64 I2C Monochrome Display

    • Pins: VDD, GND, SCK, SDA
    • Description: A monochrome OLED display for visual output.
  10. Resistor (10k Ohms)

    • Pins: pin1, pin2
    • Description: A 10k Ohm resistor used in the voltage divider circuit.
  11. Resistor (20k Ohms)

    • Pins: pin1, pin2
    • Description: A 20k Ohm resistor used in the voltage divider circuit.

Wiring Details

Rocker Switch (4 Pin)

LED (Blue, Two Pin)

Momentary Push Button Switch

18650 Battery in Holder

USB Type C Power Delivery Dummy Breakout

Power Cell - LiPo Charger/Booster

Pushbutton

ESP32-WROOM

OLED 128x64 I2C Monochrome Display

Resistor (10k Ohms)

Resistor (20k Ohms)

Code Documentation

#include <BluetoothSerial.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

BluetoothSerial SerialBT;

const int buttonPins[] = {32, 33, 25, 26};
const int pairButtonPin = 16;
const int ledPin = 2;
const int voltagePin = 34; // Pin connected to the voltage divider
const float R1 = 10000.0; // Resistor R1 value in ohms
const float R2 = 20000.0; // Resistor R2 value in ohms
const float Vref = 3.3; // Reference voltage of the ESP32 ADC

unsigned long lastDebounceTime[4] = {0, 0, 0, 0};
const unsigned long debounceDelay = 200;
unsigned long lastBlinkTime = 0;
bool isBlinking = false;
unsigned long blinkStartTime = 0;

void setup() {
  Serial.begin(115200);
  SerialBT.begin("ESP32_BT"); // Bluetooth device name
  pinMode(ledPin, OUTPUT);
  for (int i = 0; i < 4; i++) {
    pinMode(buttonPins[i], INPUT_PULLUP);
  }
  pinMode(pairButtonPin, INPUT_PULLUP);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.display();
}

void loop() {
  unsigned long currentTime = millis();