The "Cat-Cam": Using Go and an Old Nokia Android to Catch a Midnight Intruder

Pbhaskal2 pts1 comments

The “Cat-Cam”: Using Go and an Old Nokia Android to Catch a Midnight Intruder | by Premkumar Bhaskal | May, 2026 | MediumSitemapOpen in appSign up<br>Sign in

Medium Logo

Get app<br>Write

Search

Sign up<br>Sign in

The “Cat-Cam”: Using Go and an Old Nokia Android to Catch a Midnight Intruder

Premkumar Bhaskal

3 min read·<br>May 3, 2026

Listen

Share

The Problem: A Ground-Floor Mystery<br>I live on the ground floor, and lately, I’ve had a problem. A local cat (or some other animal) has been visiting my patio and causing trouble. I wanted to see exactly what was happening, but I didn’t want to buy an expensive security camera.<br>As a software engineer, I looked at my drawer of old phones and saw my retired Nokia. It had a decent camera and build quality so I decided to turn it into a headless timelapse rig to catch the culprit.<br>The hardware: A Old Nokia android phone<br>and a charger.<br>No rooting needed (although I was prepared to root if needed with my previous experience)<br>The tech stack<br>To get this running, I used:<br>Termux: A terminal app that gives you a Linux-like environment on Android.<br>Termux:API: A tool that allows my code to control the phone’s camera<br>Go (Golang): My language of choice for the logic.<br>FFmpeg: To stitch the final photos into a video.<br>Bash: For general code stitching ( you will see)<br>The Logic: How the Program Works<br>The Go program acts as the “brain” of the camera. Its job is to wake up at specific intervals, trigger the camera, and make sure the files are saved correctly.<br>The core logic follows these steps:<br>The Ticker: I used Go’s time.NewTicker to take a photo exactly every 10 seconds.<br>The Command: The program executes a system call to the termux-camera-photo utility. Actually since main monitoring happens in night, before capturing a picture, the program uses termux API termux-torch to switch on flash light and switch off after it is done.<br>Concurrency: Go makes it easy to handle “housekeeping” (like deleting old files or logging) in the background while the camera keeps snapping photos.<br>Because it’s a compiled Go program, it’s incredibly stable. It can run for days without crashing or slowing down the phone.<br>Golang compile outside termux<br>The trick was to compile golang program outside in a mac to avoid complexity of compiling a Golang program in termux. It helped to save a lot of time which would have went in debugging compilation on termux (which has lot of known open issues).<br>A simple cross compile command was good enough. GOOS=android GOARCH=arm64 go build -o main main.go<br>Optimize storage using Image resize<br>By default the camera was taking pictures which were each of size around 2.5MB, which was actually overkill and were filling storage too fast.<br>So I had to optimize by reducing image size. I used utilitiesjpegtran and jpegoptim for this.<br>The Post-Processing: FFmpeg<br>After 24 hours, I end up with thousands of high-resolution images. To find the intruder, I don’t want to look at 8,000 pictures.<br>I use FFmpeg to “crush” those images into a high-speed timelapse video. The FFmpeg would run every 5 minutes, converting last 5 minutes pictures into a single video.<br>Daily morning I would move this images to laptop to make a combined video. (There is scope for further automation here).<br>But to be honest, I was really surprised by how efficiently FFmpeg ran even on an old mobile hardware.<br>Termux magic APIs<br>The APIs provided by termux like termux-torch and termux-camera-photo are the ones which made this activity very simple. It worked without any glitches, which was a pleasant surprise.<br>The “Tricks” to Keeping it Alive<br>Android is designed to save battery by “killing” apps that run in the background. To turn a phone into a 24/7 server, I had to use three specific engineering tricks:<br>1. The Wake-Lock (Stop the CPU from Sleeping)<br>Normally, when the screen goes off, the phone enters a “deep sleep” to save power. This would pause my Go program. I used the termux-wake-lock command. This tells the Android kernel: "Do not sleep. The CPU needs to keep working." This is the only way to ensure the camera triggers exactly every 10 seconds.<br>2. Running as a Service<br>I didn’t want to manually start the program every time. I set it up as a service using the termux-servicespackage, This means the program starts automatically in the background. If it crashes or if the phone restarts, the service ensures the Go program kicks back in immediately without me touching it.<br>3. The Power Rig<br>Since the camera, the CPU, and the Wi-Fi are running 24/7, the battery would die in 12–15 hours. The setup stays permanently connected to a charger.<br>Source code and stuff<br>All the source code is available here if you want to hack it https://github.com/prembhaskal/prem-nokia-android/tree/main/timelapse

Golang

Termux

Ffmpeg

Termux Android

Written by Premkumar Bhaskal<br>5 followers<br>·11 following

Software Engineer @Nokia

Help

Status

About

Careers

Press

Blog

Store

Privacy

Rules

Terms

Text to speech

termux camera program android nokia phone

Related Articles