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

ESP32-Based Battery-Powered Universal IR Remote with OLED Display

View and Edit Project In Cirkit DesignerImage of ESP32-Based Battery-Powered Universal IR Remote with OLED Display

Circuit Documentation

Summary

This circuit is designed to function as an IR remote control system using an ESP32 microcontroller. The system includes an IR receiver, an IR transmitter, an OLED display for user interaction, and multiple tactile switches for input. The circuit is powered by a 18650 battery and includes a TP4056 module for battery charging. The ESP32 microcontroller is programmed to handle IR signals, display messages on the OLED, and respond to button presses.

Component List

  1. ESP32 Wroom Dev Kit

    • Description: Microcontroller with Wi-Fi and Bluetooth capabilities.
    • Pins: 3V3, EN, VP, VN, GPIO 34, GPIO 35, GPIO 32, GPIO 33, GPIO 25, GPIO 26, GPIO 27, GPIO 14, GND, GPIO 13, SD2, SD3, CMD, V5, GPIO 23, GPIO 22, TXD, RXD, GPIO 21, GPIO 19, GPIO 18, GPIO 5, GPIO 17, GPIO 16, GPIO 4, GPIO 0, GPIO 2, GPIO 15, SD1, SD0, CLK
  2. TSOP312 IR Receiver

    • Description: Infrared receiver for capturing IR signals.
    • Pins: GND, Vs, Data
  3. Resistor (200 Ohms)

    • Description: Resistor with a resistance of 200 Ohms.
    • Pins: pin1, pin2
  4. Ceramic Capacitor

    • Description: Capacitor with a capacitance of 0.1 µF.
    • Pins: pin0, pin1
  5. 18650 in holder

    • Description: Battery holder for 18650 lithium-ion battery.
    • Pins: GND, VCC
  6. USB C breakout board

    • Description: Breakout board for USB-C connector.
    • Pins: VBUS, GND, CC1, D-, D+, CC2
  7. 940nm Infrared LED Transmitter Module

    • Description: Infrared LED module for transmitting IR signals.
    • Pins: IN, 5V, GND
  8. TP4056

    • Description: Lithium-ion battery charger module.
    • Pins: OUT-, B-, B+, OUT+, IN-, IN+
  9. SSD1306 I2C OLED Display

    • Description: OLED display with I2C interface.
    • Pins: SCL, SDA, GND, VCC
  10. BC547 Transistor

    • Description: NPN transistor.
    • Pins: Collector, Base, Emitter
  11. Electrolytic Capacitor

    • Description: Capacitor with a capacitance of 1 µF.
    • Pins: -, +
  12. Resistor (10k Ohms)

    • Description: Resistor with a resistance of 10k Ohms.
    • Pins: pin1, pin2
  13. Tactile Switch Buttons - 12mm Square

    • Description: Tactile switch button.
    • Pins: 3, 1, 4, 2

Wiring Details

ESP32 Wroom Dev Kit

TSOP312 IR Receiver

Resistor (200 Ohms)

18650 in holder

USB C breakout board

940nm Infrared LED Transmitter Module

TP4056

SSD1306 I2C OLED Display

BC547 Transistor

Tactile Switch Buttons - 12mm Square

Code Documentation

#include <IRremoteESP8266.h>
#include <IRrecv.h>
#include <IRsend.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>

// Pins
#define RECV_PIN 27
#define IR_LED_PIN 26
#define BUTTON_PIN_BASE 32 // GPIO for buttons starting from 32
#define OLED_RESET -1 // Use default for I2C OLED

// Constants
#define NUM_BUTTONS 8
#define MAX_REMOTES 5

// Globals
IRrecv irrecv(RECV_PIN);
IRsend irsend(IR_LED_PIN);
decode_results results;
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);

struct Remote {
  uint64_t codes[NUM_BUTTONS];
};

Remote remotes[MAX_REMOTES];
int currentRemote = 0;
int currentButton = 0;
int storedRemotes = 0;

// Functions
void setup() {
  Serial.begin(115200);
  
  // IR Setup
  irrecv.enableIRIn();
  irsend.begin();
  
  // OLED Setup
  if (!display.begin(SSD1306_I2C_ADDRESS, OLED_RESET)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);

  // Button Setup
  for (int i = 0; i < NUM_BUTTONS; i++) {
    pinMode(BUTTON_PIN_BASE + i, INPUT_PULLUP);
  }

  // Startup Message
  displayMessage("IR Remote Ready");
}

void loop() {
  // Navigation and interaction logic
  handleButtons();
  
  // Check for IR input to capture or use
  if (irrecv.decode(&results)) {
    handleIRSignal();
    irrecv.resume();
  }
}

void displayMessage(String message) {
  display.clearDisplay();
  display.setCursor(0, 0);
  display.println(message);
  display.display();
}

void handleButtons() {
  for (int i = 0; i < NUM_BUTTONS; i++) {
    if (!digitalRead(BUTTON_PIN_BASE + i)) {
      delay(200); // Debounce
      if (i == 0) {
        // Add Remote Logic
        addRemote();
      } else if (i == 1) {
        // Show Remote Logic
        showRemote();
      } else if (i == 2) {
        // Delete Remote Logic
        deleteRemote();
      }
      return;
    }
  }
}

void handleIRSignal() {
  uint