T ThinkEdge Learn

Security Camera: From Light on a Sensor to a Stream You Can Store

A camera is a sensor, a processor and a compressor. Understand those three stages and you can judge any camera on its real numbers instead of its resolution.

security camera diy security camera wifi security camera ip camera
Maker Hardware and IoT · Puts storage and latency numbers before resolution marketing

What a camera really does

Light falls on a silicon sensor and is converted into charge, then into digital numbers. A colour sensor has a Bayer filter over it, so each pixel only records one colour and the rest is worked out by interpolation. The camera then sets an exposure, a gain and a white balance, and produces one still frame. That part is the same in a $30 camera module and a professional broadcast lens.

A video stream is thousands of those frames, and raw frames are far too big to send anywhere. The frames are compressed, and the compression is where the numbers that matter come from. A 1080p stream at 30 frames per second runs at roughly 2 Mbit/s with modern H.265 compression. At that rate you store about 0.9 GB an hour, 21 GB a day, and around 640 GB for a month of continuous recording. Resolution is the least interesting of the published numbers. A 4 Mbit/s stream gives a better-looking recording than 2 Mbit/s, but a 4 megapixel image of an empty corridor at 4 frames per second is worth less than a 2 megapixel image at 30 frames per second of a doorway, because frames per second is what tells you what happened.

Latency and light decide whether a camera is useful

A camera that takes two seconds to show you the doorway is a recording, not a warning. That delay comes from the encoding, the network and the playback buffer, and the biggest single contributor is usually the buffer used to smooth out jitter in the network. Recording to a local SD card removes the network from the path entirely and gives you near real-time feedback.

Light is the other constraint. A sensor needs photons, so in the dark you get noise unless the camera adds light. Infrared illuminators work around 850 nm, which most silicon sensors can detect even though the eye cannot see it, and the camera switches its filter and exposure when it detects darkness. The switch has a cost: colour becomes monochrome, and the image can look flat. Which is why the best cheap systems are motion-triggered rather than always-on. A passive infrared sensor watches for a body moving across the scene and wakes the camera to record for a few seconds. Because most of the time nothing happens, the storage cost falls by a factor of fifty to a hundred, and the interesting footage is exactly the footage you keep.

Step by step

  1. Capture a single still image

    Take one frame from a camera module and save it to an SD card. Doing this first separates the imaging problem from the streaming problem.

  2. Measure the real bitrate

    Stream for a minute and measure the bytes on the wire. The number will surprise you, and it is what sets the storage bill.

  3. Work out the storage requirement

    Multiply the measured bitrate by the hours you intend to record, then by 30. This is the calculation that decides between a card, a drive and a subscription.

  4. Add a PIR trigger

    Connect a passive infrared sensor so the camera only records when something moves. Compare the daily storage with the always-on version.

  5. Add night vision

    Switch on an infrared illuminator and adjust the sensor's gain and exposure for the dark scene. Compare the result with the daylight frame.

  6. Test the whole loop against the real link

    Stream over Wi-Fi to a laptop on the same network and measure the end-to-end delay. If it is more than a second, move the encoder closer to the sensor.

What you'll need

ItemQtyWhy
ESP32-CAM module with OV2640 camera1A camera and an MCU on one board, so the image is compressed before it ever touches the network.
Arduino Mega 25601More RAM than an Uno for buffering frames, and the serial hub project shows how to pair it with other sensors.
PIR motion sensor1The trigger that cuts storage by a factor of fifty and keeps the footage that matters.
Infrared LED array with a lens, 850 nm1Illuminates the scene in darkness where the sensor cannot see on its own.
MicroSD card module and 32 GB card1Local recording removes the network from the latency path and keeps working when the internet does not.
5 V, 2 A power supply1Cameras, illuminators and an SD card write all at once, and a marginal supply causes dropped frames.

Practise it before you build it

Every step above has a matching circuit in the ThinkEdge Learn simulator. The simulator runs a real Arduino sketch against a modified-nodal-analysis solver, so digitalWrite actually drives the LED on screen and the readings change when you change the wiring — no hardware, no burnt components.

Common questions

How much storage does a security camera need?

At 2 Mbit/s for 1080p, budget about 21 GB a day, so a 1 TB drive holds roughly 45 days of continuous recording and a 256 GB card about 12 days. Motion-triggered recording changes the figure completely: the same drive can then hold months, because the camera is idle most of the time.

Is an IP camera better than analogue for a school?

For a classroom lab, IP is easier to teach because the video is a file you can open in any player and analyse frame by frame. Analogue is still cheaper per camera over long distances and is what most commercial systems use. The deciding factor is usually storage and whether you want to run your own analytics.

Can I build a DIY security camera for less than a commercial one?

You can, and it is a good project, but the commercial version wins on image quality, low-light performance and weatherproofing, which are the three things that are hard to build. The DIY version wins on being able to see exactly what the camera does, which is the reason to build it in a class.

Related guides

ESP32 IoT Projects: From a Single Sensor to a Live DashboardFive ESP32 IoT projects that teach sensors, MQTT publishing, deep sleep and reconnection, each staged so the logic runs in a browser simulator first. Smart Lighting: The Driver, the Controller and the RadioSmart lighting is a driver, a controller and a radio. Learn PWM, current limits, MOSFET switching and flicker, then build a lamp you can query. Mesh Networking: How Nodes Relay Data for Each OtherA mesh network lets nodes relay data for each other. How flooding and hop limits work, what mesh costs in latency, and when a simple star is better. Raspberry Pi 5: What Changed Inside and How to Teach With ItThe Raspberry Pi 5 has a faster CPU, a new RP1 I/O chip and a 5 V power supply. What changed, what it costs, and how to use it in a classroom.

Try the full simulator with your class

103 guided circuit projects, 21 lessons and an in-browser Arduino simulator. The first 15 projects are free, no account needed. NCERT Science mapping on 47 projects, with Arabic and English copy in the regional builds.