Diy mini companion

DIY Robot Companion with ESP32-S3 and OLED Display (Battery Powered) | Kids Robotics | MakeMindz
MakeMindz

DIY Robot Companion with ESP32-S3 and OLED Screen

Meet your very own pocket robot buddy! It blinks, looks around, smiles, gets surprised and even falls asleep when you ignore it. It runs on a rechargeable battery, so it can sit on your desk or ride in your bag.

  • Level: Intermediate
  • Time: about 2 hours
  • Ages 11+ (with an adult helper)

What are we building?

A companion gadget is a little electronic friend with a personality. Ours has a tiny OLED screen for a face, an ESP32-S3 as its brain, and a lithium battery with a charging module for its energy. One button changes its mood.

Try it: pick a mood and watch the face change, just like the real screen will.

Mood: Happy

What you need

PartHow many
ESP32-S3 development board1
0.96 inch OLED display, 128×64, SSD1306, I2C (4 pins)1
TP4056 lithium charger module with protection (the one with 6 pads and two chips)1
3.7V lithium battery (LiPo pouch or 18650) with built-in protection1
5V boost converter module (such as MT3608) set to 5V1
Small slide switch1
Push button1
Jumper wires, breadboard, double-sided tape1 set
Small box or 3D-printed case1
About the charger: I used the common TP4056 module because it matches the name on your parts list as closely as possible. If your module is really an IP5306 (a power-bank chip that charges the battery and gives 5V out), you can skip the boost converter and connect its 5V output straight to the ESP32-S3 5V pin.
Using an ESP32-S3 board with a built-in OLED? Skip the separate screen. Look up which pins the screen uses on your board and change SDA_PIN and SCL_PIN in the code.
Battery safety, please read! Lithium batteries can get hot or catch fire if they are shorted, punctured, charged the wrong way round or left charging unattended. Only an adult should connect the battery. Check the + and − twice, use a battery with a protection circuit, never charge it while you sleep or leave, and stop using any battery that is puffy, hot or damaged.

How it works

  • Charge: plug USB into the TP4056. It fills the battery safely and its LED shows when it is full.
  • Boost: a battery gives 3.7V. The boost converter lifts it to a steady 5V for the ESP32-S3.
  • Think: the ESP32-S3 runs the code. Every few seconds it picks a random place to look and a random time to blink.
  • Draw: it paints the eyes and mouth on the OLED using simple shapes, many times every second, so they seem to move.
  • Feel: each button press changes the mood. If nobody presses it for 60 seconds, the robot falls asleep.

Circuit diagram

ESP32-S3 board 3V3GNDGPIO8 (SDA)GPIO9 (SCL) GPIO4GND5V pin OLED 0.96" VCCGNDSDASCL Mood button BatteryTP4056Switch5V boost all GND wires join Battery B+ / B− go to TP4056 B+ / B−. Power for the robot comes from TP4056 OUT+ / OUT−.

Pin table

FromTo
ESP32-S3 3V3OLED VCC
ESP32-S3 GNDOLED GND
ESP32-S3 GPIO8OLED SDA
ESP32-S3 GPIO9OLED SCL
ESP32-S3 GPIO4Mood button, other leg to GND
Battery + / −TP4056 B+ / B−
TP4056 OUT+Slide switch, then 5V boost IN+
TP4056 OUT−5V boost IN− and the common GND
5V boost OUT+ / OUT−ESP32-S3 5V pin / GND
Before connecting the ESP32-S3: power the boost converter on its own and use a multimeter to turn its small screw until the output reads 5.0V. Some ESP32-S3 boards label the GPIO pins differently, so check yours. No resistor is needed for the button because the code switches on the built-in pull-up.

Step-by-step instructions

  1. Test the screen on a breadboard

    With the battery not connected, wire only the OLED and the button to the ESP32-S3, powered by USB. In the Arduino IDE, install the esp32 by Espressif board package, then the libraries Adafruit SSD1306 and Adafruit GFX from Library Manager.

  2. Upload the code

    Choose Tools > Board > ESP32S3 Dev Module, pick your port, paste the code below and click Upload. You should see “Hi! I’m Bolt” and then the eyes appear. Press the button to change the mood.

  3. Wire the battery power

    With an adult, set the boost converter to 5.0V first. Then connect battery, TP4056, switch and boost converter as in the diagram, with the switch off. Connect the boost output to the ESP32-S3 5V and GND last.

  4. Build the case

    Place the OLED in a window cut into the lid. Fix the board, charger and battery inside with double-sided tape, leaving the TP4056 USB port reachable for charging. Mount the button and switch on the side. Make sure no bare wire touches the battery.

  5. Play with your robot buddy

    Slide the switch on. Watch it blink and look around. Press the button to change its mood, and leave it alone for a minute to see it fall asleep. To charge, plug a USB cable into the TP4056 and wait for its LED to show that it is full.

Uploading new code later: turn the slide switch off before you plug in the USB cable to the ESP32-S3, so the battery and the computer never feed power into each other.

Arduino code

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

#define SDA_PIN 8              // change if your board uses other pins
#define SCL_PIN 9
#define BTN_PIN 4

const char* NAME = "Bolt";     // give your robot a name!

Adafruit_SSD1306 display(128, 64, &Wire, -1);

enum Mood { HAPPY, NORMAL, SURPRISED, SLEEPY };
Mood mood = HAPPY;

float lookX = 0, lookY = 0;
int targetX = 0, targetY = 0;
unsigned long nextBlink = 0, blinkEnd = 0, nextLook = 0, lastPress = 0;
bool lastBtn = HIGH;

void drawEye(int cx, int h) {
  int cy = 26;
  if (mood == HAPPY && h > 10) {            // happy "^" eye
    display.fillCircle(cx, cy + 6, 18, WHITE);
    display.fillCircle(cx, cy + 14, 18, BLACK);
  } else if (mood == SLEEPY) {                 // closed eye
    display.fillRoundRect(cx - 18, cy + 6, 36, 5, 2, WHITE);
  } else {                                     // open eye with a pupil
    display.fillRoundRect(cx - 18, cy - h / 2, 36, h, 10, WHITE);
    if (h > 14) {
      display.fillCircle(cx + lookX, cy + lookY, mood == SURPRISED ? 4 : 8, BLACK);
    }
  }
}

void drawMouth() {
  if (mood == HAPPY) {                         // smile
    display.fillCircle(64, 50, 9, WHITE);
    display.fillCircle(64, 46, 9, BLACK);
  } else if (mood == SURPRISED) {
    display.drawCircle(64, 54, 5, WHITE);
  } else if (mood == SLEEPY) {
    display.setTextSize(1);
    display.setCursor(96, 4);
    display.print("z z");
  } else {
    display.drawFastHLine(56, 54, 16, WHITE);
  }
}

void setup() {
  pinMode(BTN_PIN, INPUT_PULLUP);
  Wire.begin(SDA_PIN, SCL_PIN);
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    for (;;);                                  // screen not found
  }
  display.setTextColor(WHITE);
  display.clearDisplay();
  display.setTextSize(2);
  display.setCursor(10, 14);
  display.print("Hi! I'm");
  display.setCursor(10, 36);
  display.print(NAME);
  display.display();
  delay(2000);
  randomSeed(micros());
  lastPress = millis();
}

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

  bool btn = digitalRead(BTN_PIN);
  if (lastBtn == HIGH && btn == LOW) {        // button pressed
    mood = (Mood)((mood + 1) % 4);
    lastPress = now;
    delay(30);                                 // debounce
  }
  lastBtn = btn;

  if (now - lastPress > 60000UL) mood = SLEEPY;   // falls asleep

  if (now > nextLook) {
    targetX = random(-8, 9);
    targetY = random(-4, 5);
    nextLook = now + random(1500, 3500);
  }
  if (now > nextBlink) {
    blinkEnd = now + 150;
    nextBlink = now + random(2000, 6000);
  }
  lookX += (targetX - lookX) * 0.2;            // glide to the target
  lookY += (targetY - lookY) * 0.2;

  int h = (now < blinkEnd) ? 4 : (mood == SURPRISED ? 40 : 30);

  display.clearDisplay();
  drawEye(34, h);
  drawEye(94, h);
  drawMouth();
  display.display();
  delay(20);
}

Tips and troubleshooting

The screen stays black

Check VCC, GND, SDA and SCL. Some OLEDs use address 0x3F instead of 0x3C, so try changing it in display.begin(). Also check that your pins match your board.

It works on USB but turns off on battery

Check that the boost converter really gives 5V and that the battery is charged. A weak battery or a loose switch can make the board restart.

The TP4056 LED never changes

Check the battery polarity and the USB cable. Red usually means charging, and blue or green means full, but it depends on the module.

My module is an IP5306 and it switches itself off

Some IP5306 modules turn off when the load is very small. Press its button again, or add a small extra load as the module’s instructions suggest.

My screen is a different size

This code is for 128×64 screens. A smaller screen, like a 0.42 inch, needs a different library setup and smaller eyes.

What did we learn?

  • I2C lets the OLED talk to the ESP32-S3 with just two wires.
  • Animation is drawing, clearing and redrawing many times a second.
  • Random numbers make a robot seem alive.
  • Battery power needs a charger, protection and the right voltage.

Try these challenges

  • Add a new mood, like “angry” or “love” with heart eyes.
  • Show the time or battery level on the screen.
  • Add a touch sensor or a buzzer so it chirps when it is happy.
  • Use the ESP32-S3’s Wi-Fi to show the weather on its face.

Questions kids ask

Why not connect the battery straight to the board?

A battery gives 3.7V and changes as it drains. The 5V pin likes a steady 5V, so the boost converter keeps things stable.

Can I use my phone charger?

Yes, a normal 5V USB charger works for charging through the TP4056.

How long does the battery last?

It depends on the battery size. A 1000 mAh battery will usually run a small OLED gadget for several hours.

Build a friend that blinks back! Made your own robot buddy? Share it with us.

Follow MakeMindz for more kids robotics and maker projects.

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
★★★★★ Young inventors love it!
🖨️
3D Print
All parts
⚡
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 ₹300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
★★★★★ Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 ₹200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course