Tethered Raspberry Pi for Modern Camera Functionality
1793 words9 min readSpencer Kittleson

TLDR;
Code about this blog post. Drop the files over ssh into a raspberry pi zero with a micro usb cable then you should be set!
Introduction
Sony A6000/A6400 series: Part 1: Modernization · Part 2: More Hacks · Part 3 (this post) · Research & Community Resources · Burst Super-Res
As in my other posts, i’ve made further progress with getting my camera to a modern era. This one is going to be taking advantage of using bit of mobile compute and finding some parts to make it ultra compact. Also, I got a new a6400! a few new features that i really like. Before i go to far i do once to call out some of the biggest changes since my last posts (Part 1) and 2 (Part 2): no ssh into the device, the playmemories app is no longer so we cant get updated apps, and no more android subsystem. Looks like this has been rewritten by Sony.
So why is this post a bit different? We are using additiional hardware for on-the-go capture gathering/viewing. A raspberry pi zero w, gps on it, external battery, and some small cables. What does this get us? Gets us realtime shots, online/offline networking, and convience.
Get the full field guide
This build is chapter 9 of my field guide for the A6000 and A6400. The guide version has the corrected script paths, the 5 byte wire format and compression sizes I measured on a real a6400 photo.
- Getting photos off the camera fast without the Pi: gphoto2, the postview hack, and card renaming
- OpenMemories-Tweak on the A6000 and the language unlock on the A6400
- Burst super-resolution, with a free desktop app (Burst Super-Res) to do the merge
- Only in the guide: the chapter 2 firmware backup and risk notes, and a troubleshooting index for the errors people hit most, like “No Tweaks found” and the A6400 dropping into charging mode
It launched at $39. During the early release it’s $19, or $14 if you tick the box promising to send me feedback after you’ve tried it (honor system). It’s a 25-page PDF, emailed as soon as you pay.
Full disclosure: this is my own guide, and the money comes to me. If it doesn’t help you, reply to the delivery email within 30 days and I’ll refund you. Some of the mods in it are irreversible, so read the risk notes before you start.
Gear for This Build
| Gear | Purpose | Buy |
|---|---|---|
| Raspberry Pi Zero 2 W | The brains of the tethered setup; quad-core, so the gphoto2 build and JPEG compression run much faster than on the original Zero W (which also works) | Amazon |
| Micro-USB OTG host adapter (2-pack) | Breaks the Pi Zero’s micro-USB OTG port out to full-size USB-A for the camera cable | Amazon |
| SanDisk 32GB Ultra A1 microSD card | OS card for the Pi; A1 rating keeps gphoto2 + copyparty responsive | Amazon |
| Anker PowerCore Slim 10000 USB-C battery | Powers the Pi untethered in the field | Amazon |
| AC-PW20 power adapter | Dummy battery so the camera itself doesn’t die mid-session | Amazon |
The Dead Ends
Using the Sony App is kind of slow. I know they did a general good job on it. It’s just really flaky to get going. I tried a bunch of ways but it could be my phone or the camera itself. Not sure but i dont see Sony making a ton of improvements on it.
- Wi-Fi hotspot mode dumb terminal, no internet, Camera SDK only returns thumbnails without the
setPostviewImageSizehack (covered in Part 1) - USB mass storage USB 2.0 is painfully slow for 7-10MB JPEGs; camera freezes if you don’t eject safely
- Sony Camera SDK full download — the
setPostviewImageSizetrick gives one photo at a time; no enumerate API, no batch download, connection drops when leaving Smart Remote mode - FTP from camera Part 2 showed this: 70 files in 13 minutes. Not a workflow.
- gphoto2 with a laptop works perfectly, not very mobile.
There is one really cool feature about gphoto2 in PC Mode tho… camera events. Every interaction shows you exactly what gets changed on the camera. We can use that to gain insights and determine what to do next. Just dont want to have a laptop with me.
Architecture
Sony a6400 (PC Remote mode)
│ USB
▼
gphoto2 --capture-tethered
│
▼
~/downloads/NNNNN.jpg
│
├──► Bluetooth RFCOMM server
└──► Copyparty HTTP server
- Three services: tethered capture, Bluetooth RFCOMM, copyparty HTTP
- Can run all three or any subset
- Camera always connected via USB in PC Remote mode
Tethered Capture
This is the most fragile part of the system.
Most Sony cameras support PC mode. The magic of this happens here. ghoto2 can get those realtime events to stream over. As well as the full image. its only there for temporary so we need to grab while its still possible to get it.
I rebuilt gphoto2 from source. it takes awhile on the pi but more stable at 2.5.32+ . Use scripts/setup.sh to build from source.
The Lua monitor pattern (not a systemd Restart trap):
- gphoto2 exits when the USB link blips
- systemd restart is fast enough to collide with the camera still holding the USB device → “Could not claim the USB device”
- Solution: Lua script maintains one persistent gphoto2 session; kills
gvfs-gphoto2-volume-monitor, waits 5 seconds, relaunches - systemd sees a healthy Lua process and never triggers its own restart logic
The loop from sony_camera_capture.lua:
while true do
local startnum = next_filenumber()
emit(string.format("[*] Tethered session starting (next file: %05d).", startnum))
os.execute(build_capture_command(startnum))
emit("[*] gphoto2 exited; releasing USB device, reconnecting in 5s...")
kill_competitors()
sleep(5)
end
Sequential filenames:
- gphoto2’s
%Y%m%d%H%M%S.jpgsorts wrong on mobile - Use
--filenumber=N --filename %05n.%C→00001.jpg,00002.jpg - Lua script scans download directory for highest number before each session → no overwrites after crash/restart
The WorkingDirectory=/ silent failure trap:
- gphoto2 writes a temp file to CWD before moving to target filename
- Default systemd CWD is
/, not writable by service user - Result: gphoto2 exits 0, photo never appears in download directory
- Fix:
WorkingDirectory=/home/dietpi/downloadsin systemd unit
This one wasted hours. Nothing fails, gphoto2 says it’s fine, and the folder stays empty.
The USB Mode-Switching Bug
The most annoying bug in the system, and no code change fixes it. It’s physics.
References:
-
README.md— troubleshooting section -
a6400 falls from PC Control mode (
054c:0caa) to charging mode (054c:0994) -
Causes: marginal cable, insufficient Pi USB current, camera connected before USB stack is ready
-
gphoto2 can’t find the camera in charging mode
-
Fixes: short quality cable, powered USB hub, 5-second sleep in Lua monitor for re-enumeration
The Bluetooth Binary Protocol
The easiest approach was to use RFCOMM but i know its a bit slower so compression is required. I suspect this is why the Sony android is so slow. OBEX/OPP is bloated; HTTP over Bluetooth PAN/DUN is finicky on both sides
So a simple custom protocal was made, only 5 bytes of overhead per message! [1 byte opcode] [4 bytes big-endian length] [payload]
Commands:
0x01 LIST: no payload, returns0x81with newline-delimited filenames0x02 GET: payload is<quality byte><filename>, returns0x82with JPEG data0x03 WAIT: no payload. The server then pushes0x83 NOTIFYwith the filename of each new capture, so the phone knows the moment the shutter fires0xFE: error responses with ASCII messages (FILE_NOT_FOUND,BAD_QUALITY, etc.)
Quality tiers (server-side compression with Pillow/LANCZOS):
| Quality | Resize | JPEG quality | Size (one 6000×3376 a6400 shot) |
|---|---|---|---|
| 0 | None (original) | — | 11.4 MB |
| 1 | Half-size | 75 | 350 KB |
| 2 | 1200px wide | 75 | 51 KB |
| 3 | 1200px wide | 40 | 28 KB |
- Quality 3 = preview in under 10 seconds over Bluetooth
- Pi does the CPU work; phone receives final compressed JPEG
Copyparty: Zero-Config LAN Browsing
The alternative to Bluetooth when everything is on the same network.
References:
-
bash scripts/copyparty-setup.shinstalls copyparty and enables + starts thecopypartyservice -
No nginx, no Apache, no config files
-
http://<pi-ip>:8080→ full file browser with thumbnails and grid view -
Default login:
admin/admin -
Use cases: booths, events, bigger screen without Bluetooth
Lessons Learned
- Build gphoto2 from source — distro package is too old; plan for build time
- Use a Lua wrapper, not a raw systemd service — gphoto2 exits; the Lua monitor handles the USB race condition that systemd restarts can’t fix
- Set
WorkingDirectoryin your systemd unit — the silent failure is the most expensive bug in this project - Quality cable, powered hub, or neither — USB mode-switching is physics, not software
- Compress server-side for Bluetooth — Pi has the CPU; use it
- Five bytes beats HTTP on RFCOMM — length-prefixed packets are simpler and faster
- Sequential filenames for mobile — timestamps sort wrong on phone galleries
Use Cases
- Product photography — camera on tripod, Pi on shelf, check phone over Bluetooth. No desk, no laptop cable.
- Wildlife — remote trigger, instant photo availability. You’re in the field, not at a desk.
- Events — hands-free capture station. Attendees review on LAN browser, collect originals later.
- Booths and displays — self-contained photo station. Pi hides behind the setup. No laptop footprint = looks like magic.
Conclusion
A ~$15 Pi Zero replaced the laptop in my tethered setup. It runs three services off one Lua monitor and talks to the phone with a 5 byte header. The parts that hurt (USB mode switching, WorkingDirectory=/, the gphoto2 version) are written down now so you don’t have to find them the hard way.
The protocol is open. Fork the repo, add remote shutter control over Bluetooth, and tell me what you build. It was built around the a6400, but gphoto2 supports a long list of cameras.
The super-resolution hack from Part 1 might be worth a Part 4.
