The Subtle Art of Trial and Error

Reading Time: 4 minutes
For 40 CHF you can buy a Tapo or Xiaomi webcam and it is almost ready to be used as a webcam. You take it out of the box, plug it in, add an SD card, download the app, pair it with the phone and let the phone connect it to wifi and then it detects motion, can take video, photos and more, with ease. In such an environment it's easy to forget about what we called "Plug and pray" back in the day.

Back in the geeky old days of computing there was a lot of trial and error to get things to work. You would try one thing, and see if it worked, and then another, and then a third, and then a fourth, and eventually you would either find a solution, or give up. One of the reasons I switched to Apple, rather than Linux, in 2003, is that I wanted to be able to connect to the university's wifi with ease. I expected that if I used a linux machine I would struggle with wifi.

Apple is the leader in making everything work so flawlessly, as long as they want you to do things, that trial and error is part of history. Apple controls everything, to ensure that it works "flawlessly". I put "flawlessly in quotation marks because my phone crashes or hangs on almost every one of my walks. I rebooted it today and yesterday, while walking. If I take photos during a walk the phone acts up and freezes, and stops the podcast I'm listening to.

I'm being distracted. The point is that Apple, until recently, was known for producing reliable devices. Windows is also known for dumbing down their devices more and more. They try to make it so that users just click install, and the computer does the rest. Usually webcams, printers and more are plug and play.

With Linux you're using a tinkerer's OS so things can be simple, if you buy a generic webcam and plug it in. I tried to set an android phone up as a webcam and it worked within minutes. Integration with Home Assistant was smooth and efficient.

With a Raspberry Pi 3b and a Raspberry Pi zero 2 W I have struggled for three or four hours trying to get the camera to work. You have to do A, and then you need to do B and then you need to do C. You also need to wire the camera into the board the right way.

As you're doing this from a CLI you're not seeing whether the webcam is giving a picture or not. I tried to take pictures and it appeared to take them but when I tried to get motion to work with the camera to stream to a device with a web browser I just see nothing. I get an error message about the camera not being available.

I know that the right camera is detected because I see it in the output. I just haven't taken the time to see if the images generated correspond to what I expect them to be. The subtle art of of trial and error is about having a goal and tweaking and experimenting until you get the result you want to get.

The first error is that I wired the camera the wrong way. The second error is that I don't need to use the legacy camera option with this camera. The third error is that I'm trying to get a Pi and camera module to work as a webcam before I get it to work within its own device.

I am so used to Windows, MacOS and dedicated hardware being so reliable that I forget about the trial and error part of computing that was once so familiar to those of us geeky enough to spend hours of our free time playing with computers. When computers just work it's easy for everyone to be a geek, because turning it off and on again is easy. So is plugging in a USB device.

My aim is not to [build a CinePi](https://www.raspberrypi.com/news/cinepi-a-high-end-film-camera-built-on-raspberry-pi/).My aim is to setup a webcam that I can see via Home Assistant. I can then add motion detection and more features when I achieve the initial goal of [building a Raspberry pi webcam server in minutes](https://pimylifeup.com/raspberry-pi-webcam-server/)". The instructions are for the V2 module, or a logitech device, and I'm using the V3 module, so the instructions need to be updated. That's why I'm struggling, and that's why it's interesting to do these projects.

I came across this challenge when following programming courses that were over a year old. Sometimes I had to look for the new way of doing things to get the code to behave as it was expected to. Sometimes ChatGPT, Bard and Bing are helpful to find the up to date way of doing things. It is also a case of Reading the Fabulous Manual (RTFM).

There are at least [ten Home Assistant Camera integrations](https://www.home-assistant.io/integrations/#search/camera) to experiment with, so if the method I have been experimenting with doesn't work I still have 9 other solutions to experiment with. The [FFMPEG option](https://www.home-assistant.io/integrations/camera.ffmpeg/) [looks interesting](https://jollejolles.github.io/pirecorder/other/install-ffmpeg-raspberry-pi.html).

## The Subtle Art of Trial and Error Summarised

I call it the subtle art of trial and error because the art lies in learning a methodology by which to come up against an issue and to develop a system by which to resolve the issue in an increasingly short amount of time. The point isn't in knowing how to do things. It's in knowing where to look for help. It used to be called Google Fu.

I could easily buy a webcam for 12-30 CHF now but by experimenting with various "integrations" I invest my time in learning new skills and that has value. If I get FFMPEG to work, then I can potentially build my own camera systems. Instead of reverting to film like some, I could go the other way, and experiment with concepts similar to the Cinepi.