Build a Throwable Spy-Cam Ball Robot | ESP32-CAM Robotics Project for Kids

Build a Throwable Spy-Cam Ball Robot | ESP32-CAM Robotics Project for Kids
Kids' Robotics Lab

Build a Throwable Spy-Cam Ball Robot

Toss it like a cricket ball. It lands, pops open, raises its camera, and streams live video — all powered by an ESP32-CAM, a servo, and a few LEDs. Here's how to build your own, step by step.

📡 LIVE VIDEO STREAMING...

Mission Overview

How does a throwable camera ball actually work?

The idea is simple: a tough little ball you can toss into a bush, over a wall, or across a field. The moment it stops rolling, it wakes itself up and shows you what's around it on a screen.

🏏Throw it
Toss the ball into the area you want to see.
→
📍It lands
A simple sensor feels the impact and bounce.
🌸Unfolds
The servo motor opens the shell like a flower.
→
📷Camera rises
The ESP32-CAM lifts up and starts streaming.

Shopping List

Parts you'll need

Everything on this list is beginner-friendly and easy to find online or at a local electronics shop.

1
ESP32-CAM moduleThe brain and eye of the robot — it's a tiny Wi-Fi computer with a built-in camera.
2
SG90 micro servo motorPushes the shell open and lifts the camera mast.
3
2x bright LEDs + resistorsLights up the area so the camera can see in the dark.
4
Vibration/tilt sensor (SW-420)Detects the "thump" when the ball lands.
5
3.7V LiPo battery + chargerSmall rechargeable power pack that fits inside the ball.
6
Hollow foam/plastic ball shellCut into hinged "petals" so it can fold and unfold.
7
Jumper wires + mini breadboardConnects everything together neatly.
8
FTDI USB programmerUsed only to upload the code to the ESP32-CAM.

Wiring Guide

Circuit diagram

Here's how all the parts connect. Keep wiring neat so it folds nicely inside the ball shell.

LiPo 3.7V Battery ESP32-CAM GPIO 4 → LED GPIO 12 → Servo GPIO 13 → Sensor 5V / GND → Power SG90 Servo Opens the shell LEDs Light the scene Tilt Sensor Feels the landing

Simplified wiring: battery powers the ESP32-CAM, which controls the servo, LEDs, and reads the tilt sensor.

Build Log

Step-by-step build instructions

Prepare the ball shell

Cut a lightweight hollow ball into 4 hinged petals that can fold inward and spring open. Foam balls or 3D-printed shells both work well.

Mount the ESP32-CAM

Fix the ESP32-CAM at the centre of the ball on a small platform, lens facing upward, so it points outward once the mast rises.

Attach the servo and mast

Connect the servo horn to a small rod (the "mast"). When the servo turns, the mast should push the camera up through the open petals.

Wire the LEDs and sensor

Connect the LEDs (through resistors) and the tilt/vibration sensor to the ESP32-CAM's GPIO pins, following the circuit diagram above.

Add the battery

Tuck the small LiPo battery into the base of the shell and connect it to the ESP32-CAM's 5V and GND pins.

Upload the code

Connect the ESP32-CAM to your computer using the FTDI programmer and upload the code from the next section using the Arduino IDE.

Test before you throw!

Place the ball on a soft surface first, tap it gently to trigger the sensor, and check that the shell opens and the video stream appears on your phone or laptop.

Code Room

Arduino code for the ESP32-CAM

This sketch waits for the "landing" sensor to trigger, then opens the shell, turns on the lights, and starts the live video stream.

spy_ball.ino
// Portable Spy-Cam Ball — main sketch
// Board: AI-Thinker ESP32-CAM

#include "esp_camera.h"
#include <WiFi.h>
#include <ESP32Servo.h>

// ---- Wi-Fi details ----
const char* ssid     = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";

// ---- Pin setup ----
#define LED_PIN     4
#define SERVO_PIN   12
#define SENSOR_PIN  13

Servo lidServo;
bool hasLanded = false;

// starts the camera's video streaming server
void startCameraServer();

void setup() {
  Serial.begin(115200);
  pinMode(LED_PIN, OUTPUT);
  pinMode(SENSOR_PIN, INPUT);
  lidServo.attach(SERVO_PIN);
  lidServo.write(0); // shell starts closed

  // ---- Camera configuration ----
  camera_config_t config;
  config.pin_d0 = 5;   config.pin_d1 = 18;  config.pin_d2 = 19;
  config.pin_d3 = 21;  config.pin_d4 = 36;  config.pin_d5 = 39;
  config.pin_d6 = 34;  config.pin_d7 = 35;
  config.pin_xclk = 0; config.pin_pclk = 22;
  config.pin_vsync = 25; config.pin_href = 23;
  config.pin_sscb_sda = 26; config.pin_sscb_scl = 27;
  config.pin_pwdn = 32; config.pin_reset = -1;
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_JPEG;
  config.frame_size = FRAMESIZE_VGA;
  config.jpeg_quality = 12;
  config.fb_count = 1;

  esp_camera_init(&config);

  // ---- Connect to Wi-Fi ----
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(400);
    Serial.print(".");
  }
  Serial.println("\nWi-Fi connected!");
  Serial.println(WiFi.localIP());
}

void loop() {
  // ---- Wait until the ball lands ----
  if (!hasLanded && digitalRead(SENSOR_PIN) == HIGH) {
    Serial.println("Impact detected — unfolding!");
    delay(300); // let it settle for a moment

    digitalWrite(LED_PIN, HIGH);   // lights on
    lidServo.write(90);             // open the shell & raise the mast
    delay(600);

    startCameraServer();               // begin streaming video
    hasLanded = true;
  }
}

The startCameraServer() function comes straight from the official ESP32-CAM "CameraWebServer" example that ships with the Arduino ESP32 board package — once it runs, you can view the live video by opening the ESP32-CAM's IP address in a web browser.

Important Notes

Safety and good practice

Adult supervision required. Soldering, wiring batteries, and cutting the ball shell should always be done with a parent, teacher, or mentor nearby.

Use it responsibly. This is a hobby robotics project best used for things like search-and-rescue practice, wildlife watching, backyard games, or checking a hidden spot before entering it (like a cave or a den) — always with the permission of anyone whose space you're filming, and never to spy on people without their knowledge.

Battery care. Only use a proper LiPo charger, never puncture or overcharge the battery, and store it somewhere cool and dry.

Quick Answers

Frequently asked questions

What is an ESP32-CAM used for?

The ESP32-CAM is a small, low-cost Wi-Fi module with a built-in camera. It's popular in robotics and DIY electronics for projects like smart doorbells, robot vision, wildlife cameras, and — like here — a throwable streaming camera ball.

Is this project okay for beginners?

Yes! It uses common, beginner-friendly parts and free, well-documented example code. Kids new to robotics should build it together with an adult, especially for the soldering and battery steps.

Do I need to know how to code to build this?

Not really — the code above is based on the standard example that comes with the ESP32 Arduino library, so you mostly just need to fill in your Wi-Fi name and password and upload it.

Can the servo really make the ball "unfold"?

Yes. A single micro servo can rotate a simple hinge or push-rod mechanism enough to spring open a lightweight foam shell and lift a small camera mast a few centimetres — plenty to clear the top of the ball.

What else can I build with an ESP32-CAM and a servo?

The same core parts can become a pan-tilt security camera, a robot car with a moving camera head, a smart peephole viewer, or a remote-controlled periscope.

Built for curious young makers 🛠️ — Kids' Robotics Lab
Always build and test with an adult. Have fun and stay safe!

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