Living Room Server

While playing games on an Arm box with an NVidia card and reasonable frame rates is cool, that’s not exactly what the developer box was intended to do. The idea is, as I said earlier, to give people the same experience of developing on an x86 box. Playing games is obviously part of it, but with an underpowered CPU, the bottleneck will move away from the GPU, even with nouveau drivers, pretty soon.

Other people are reporting using it as a build machine, so I decided to use it as a local (private) cloud box, replacing our ageing media server (Celerom dual core based).

The Hardware

Board with no GPU, two HDDs, in an empty rack-mount case

For this application, we don’t need a GPU at all, so no need for any PCI devices. I’ve also decided to add back the 1TB hard-drive, as the media partition. Interesting enough, the board + SSD use about 12W on idle without the spinning rust, but 17W with it: 50% more! With the prices of 1TB SSD falling, I’ll be investing in one pretty soon.

Everything else was still the same. Same main SSD disk, same 8GB of RAM. The only change was to flip the jumper to make it boot when powered, given that I won’t have access to the power button any more.

The Form Factor

For a few weeks, I left the original case in the living room. While it worked fine, it was big, clumsy and there really was no good place for it. So I decided to buy a 1U rack-mount case.

Too many cases to choose from, most of them over £100 and with all bells and whistles I don’t need. But I remembered one that we used in the Linaro lab a while ago: SuperMicro SC512-260B.

picoPSU adaptor cable is a tad too short

It has more than enough space for the (slightly too large) mother board, two HDDs and the power supply, and you can get used ones for £40 on Ebay.

So I got one, installed the board in it and was quickly reminded of the data centre experience. Unsurprisingly, the giant fan was a bit too much, given that the CPU has a passive heat-sink and the DIMM is right in front of it, stopping any decent air-flow. After removing it, I then realised the PSU was equally noisy, if not worse. For data centre standards, it was relatively silent, but for a living room, while people are trying to watch a film, is unacceptable.

Back to the original case until I find a solution. None of the 1U PSUs are remotely silent and people reporting having to buy sound proof racks for their homes. I wasn’t going to cash out that much, nor I have space in the house for that, so I had to fine another way. It was then that I remembered that the board is really really low powered (12W is nothing), and that other similar boards (for example, the Macchiato Bin) are powered by a 12V PSU.

Wall mounted system. 12V on the right, network on the bottom

That’s when I found picoPSU. For £25, you get up to 80W (4x more than I could ever need) and zero noise. The PSU is completely silent and, guess what, accepts 12V input.

With that in, I could power the board silently and managed to remove the PSU and everything else other than the outer case. I printed an adaptor for the 12V socket where the 1U PSU used to sit, but only later realised the mother board is too big and the 20-pin sits too far from the end of the unit, so the cable is just too short.

Nothing that a ceramic drill couldn’t fix. I hacked the side of it (literally, the metal is all dented) and screwed the 12V input to it. Given this is not a rack mount anything, it will do just fine.

Finally, I printed some mounting brackets, fixed them 19″ apart and hanged the server behind the router, in an invisible corner of the living room. Neither noise nor visual pollution.

The Software

For the cloud software, there isn’t much choice. You either pay for the services (with money and your privacy), or you run ownCloud / Nextcloud. After asking folks that know a lot more about clouds than I do, it seems Nextcloud is the one to go. It might not be as complete as ownCloud (given its history), but it’s the one that has the highest chance at succeeding while still remaining mostly upstream.

Installation is pretty trivial via snap. After installing, you should follow the installation guideline to enable the Admin user, create users, enable HTTPS, etc. You can play a bit with the plugins and configurations on the website, but I realised Nextcloud is a bit on the slow side.

Of course, with an A53 @ 1GHz, I wasn’t expecting a lot. But I had a shared instance for a while on a cloud server and it was even worse. Looking at the CPU load, it’s mostly empty, with one or two CPUs maxing out. This means that the access is serialised into one process and everything is done inside it. It’s reasonable for large powerful servers with hundreds of users, but it’s inadequate for smaller (more scalable) servers or shared cloud servers, where standard Apache works very well.

I don’t know what the structure of Nextcloud is, and it seems to rely heavily on MySQL, which could explain why everything has to be serialised. Using cached static objects (especially for images and videos, which take many seconds to load and usually crash the PHP memory limit).

All in all, it’s better than building by hand, but honestly, for such a hype, I was expecting a much more professional product.

Conclusion

The machine is suitable for web workloads, and I believe the shortcomings of Nextcloud would be felt in an equally priced x86 box. The form-factor, however, gains silence from consuming under 20W at full loads (less when I get a new SSD), not needing any active heat-sink on the CPU and not having a GPU at all. Even with the large motherboard, I could still have half the size on the rack-mount and still fit everything perfectly. All of that at a fraction of the power budget of a Celeron-based NUC.

If you want additional network ports, you can get a 90-degree PCI riser (which fits into the x1 slot) or a flexible PCI cable (so you can fit on the x8) and add up to four ports easily in the one slot available. I haven’t tested routing workloads on the dev box yet, but the CPU is more powerful than the majority of the routers available, so I doubt there will be any performance issues. If you have done that, feel free to add comments below.

Security Camera without remote access

Ever since our garage doors got broken by burglars (they also broken others, stolen things, etc.), I wanted to get a security camera. However, it looks like there’s only two choices: a full sized CCTV system, costing many hundreds of pounds, with a lot of equipment and complicated setup, or cheap stupid WiFi cameras that not only require cloud access (to a cloud I don’t trust), but also opens up access to Mirai.

In 2016, the malware was already wide spread across the Internet and caused a huge Internet blackout, delivering hundreds of GB/s bandwidth in multiple DDoS attacks, also crippling many first grade websites like PayPal, Twitter and Spotify. Here’s some good coverage (as usual) by Ars and Engadget.

After the storm, I really though the IoT industry would shake up, grow up and a year or so later, we’d have better devices. Alas, mid-2017 still had vulnerable cameras in massive botnets. None of the big manufacturers issues recalls (only one small company did, AFAIK), and the cameras you find on Amazon today are the same you would find at the time of Mirai.

So, I had two choices: either pay premium for a full CCTV kit and spend weeks installing it all around my house (and getting the ire of the local community for a massive spy-shop), or build my own camera. Of course, I opted for the latter…

CameraApp

I’m not a very creative person when it comes to names (our kids have all standard names, as we do), so CameraApp sounds like a name as good as any. What it is, basically, is a Python script that pools a PIR sensor for movement, and when it sees it, the camera takes a snapshot (optionally flashing an LED). That simple. The main loop is about 10 lines of Python on a RaspberryPi. The snapshots go into a directory that has a simple PHP script, which generates thumbnails of new pictures and print a simple gallery of the images in a very crude HTML.

If you setup a web server on the board, you have yourself a gallery. If you mount that directory into a NAS, and have a web server on another machine, you have a remote server and backup. All of the security is managed by two simple concepts:

  1. System security: No root passwords, clamped down Linux, only access via SSH keys, only open necessary ports, etc. Left as an exercise to the sysadmin.
  2. Isolation: No access to the Internet needed, in or out, so if you want to get to the images from outside you’ll need to either VPN in or DMZ an external server out. If you DMZ your camera, you get what you deserve.

While I could have used any small gadget board, I decided to go with the RaspberryPi. Not only I had 4 of them lying around the house, but it’s the easiest one to find proper Linux distributions, compatible hardware on Amazon and instructions on the Internet.

Case Design

We also happen to have a 3D printer, and while it’s fun, it’s not easy to find uses for it to pay its own cost. Honestly, anything useful I can print on it, is cheaper on Amazon. So, if I get the chance to design something out of nothing, that’s a good use case for the printer.

On Thingverse, I looked for RaspberryPi cases, and you can find a huge list, so I just picked the simplest looking one (so I could mod). Then, using TinkerCAD, I designed from scratch a case for every component (PIR, LED, Camera) and joined them together into a face that would snap into the base. The project is here. That part took a lot of iterative print-try-mod cycles and the final design went back to Thingverse here.

Putting it all together

So, after printing and assembling the components, it looked like this:

The software was developed in the Pi itself, by connecting it to the TV (via HDMI) and using wireless keyboard/mouse and the Python IDE that comes with Raspbian. This setup makes it a lot easier to develop than Arduino or mbed, as everything I do can be live tested directly on the board, instead of having compiler-flash-no-output problems all the time.

After the development period was over, I could remove everything from the Pi but the power cable (remember, 2A at least), and use the on-board WiFi module for connectivity. This makes it extremely simple to put the camera in random hard-to-reach places. You could, in theory, use a battery (if it is able to provide 2A), but that means a big 20Ah would only provide a day or two and it would crash when the juice runs out (damaging the filesystem).

Uses

While this is great for indoor snooping and holiday reassurance, it needs more than what’s in the package to be actually useful (like most other cameras). The only use that actually comes for free as is, is the cookie jar example, but you don’t want to teach your kids to only do the right thing because someone is watching, so scratch that.

Holiday reassurance

For this use case, you’d just connect the camera and place it facing a door or the whole room. But if you keep the pictures in the camera’s filesystem, well, the burglar will take it too, and you’re back to square one. If you keep the pictures in a server, the burglar can also take the server, and your backups, so you need external backup. Luckily, Linux has good support for cloud storage, including safe (and encrypted) options, so you don’t need to trust the manufacturer.

You can either mount the Images directory directly on the cloud disk, or setup an rsync to push it once in a while in a cron job. In that case, you can easily look at the pictures while still on holidays, contact the police, send them the pictures and get it started even before you come back home.

Package Monitoring

Another problem that this could solve is package monitoring (ex. taking pictures of a door to see if a package has arrived), but this Python script won’t work because PIR sensors only detect movement of things that emit IR and boxes usually don’t. Extending to this usage would probably mean writing a slightly different script to take pictures every minute and compare with the previous. If similar enough, replace, try again.

You should replace the picture to make sure light and shadows only play a small enough role between two pictures, not the entire day. Also, comparing images will need additional software (like imagemagick), unless that’s your cup of tea and you want to do it all from scratch.

If the package you want to monitor is actually your pet, then the camera will work out of the box, providing you put the sensor on maximum, to capture the low heat that pets emit, compared to humans.

External CCTV

This is the use case I had in mind, but unfortunately, PIR sensors don’t work well through windows. That’s because glass is a good IR insulator, so this camera would pick up a mob with pitchforks and torches, but not much else. Unless you’re an orc afraid of your life, you’ll need to place the camera outside, and well, that comes with a lot of problems on its own.

First, the case will need to be waterproof (or at least resistant), and that’s a challenge on its own. The Pi is a computer, and as such, needs cooling, which is usually done by air passing on top of the CPU (or its heat sink). Heat it too much and the Pi dies, bricking the camera. Moreover, you will need to give some maintenance on the board some time later, so packing it as a one-off won’t do any good.

Second, taking power outside is usually done with proper extensions, not many of them with USB options, and not many USB adaptors are waterproof. So, the best option is to put the device inside a shed, providing the shed has power, of course. At least, taking power to a shed is a lot simpler (the endpoints are inside the house/shed) and then regular adaptors and bluetac would work for fixing the camera somewhere.

If your shed has solar power and a battery, giving the low consumption of the camera, it could last the whole summer at the very least.

The one thing I’ll have to add later is a way to configure the camera via a text file. As is, it doesn’t support night vision (even if your camera does), as this is a PiCamera option, along many others that one could easily add to the camera setup phase in the script. That’s my next step, which will go into GitHub as soon as I’m done.

Dash Cam

A bit of bluetac would work to put that case as is on your dashboard and the car’s power socket usually has more than enough power to support a 5V 2A adaptor. But again, you would have to write a new Python script to take videos instead of snapshots. I’d also add a big button to start/stop recording and a large USB dongle to store the videos (they’ll get big).

Educational Value

Getting a camera was the idea, but the most important take out was to show the kids how easy it is to do something functional. By using the right tools, things essentially build themselves.

A few of the takeaways:

  • By using the RaspberryPi instead of an Arduino, I could develop the app on the board itself and test it as I went, which really have shorten the development cycle.
  • It also allowed me to download Raspbian, which comes with absolutely everything I needed (OS, GUI, IDE, Python, PiCamera, GPIO, browser for searching).
  • It also allowed me to purchase the right devices on Amazon (especially the camera!) and everything worked out of the box.
  • By doing it in the living room (on the only TV), I forced my kids to watch and sometimes help. Seeing only the final product makes it look like magic.
  • The 3D printer was really helpful, as initially I have lost a lot of time looking for software bugs when actually the pins got disconnected by touching it.
  • And it turned out to be half of the fun, printing, fitting, trying again.
  • I hate to say this, but, by doing it in Python and PHP, I could really leverage the APIs and modules. Writing it in C++ would have been a nightmare and totally pointless.
  • And I could also find a dozen other projects that did similar things, and even steal a bit of code from them, refactor, change completely.

Closing Words

In the end, building stuff is always half the fun, so you have to plan accordingly. If you need a camera today, go buy on Amazon, but if you have some time to spare on your holidays and are bored of looking at the cold rain outside, a project like this really shines.

If this project interests you in anyway, feel free to collaborate (on GitHub, TinkerCAD, Thingverse), and let me know (in the comments or as GitHub issues) of ideas you have and problems you find. Happy hacking!

 

 

Geeks United! It’s time to recycle!

It’s time to recycle using your hand craft abilities!

Computer Chip Trivet

Don’t you know what to do with those old computer chips laying around? What do you think about a stylish trivet? Instructions are simple to follow: all you need are some computer chips , grout, adhesive, and a tile square.

Once you’re all finished, you’ll have a nicely geekified trivet for all your hot stuff.

You’ll really impress your geeky friends with this genuinely useful kitchen tool that you can make: a trivet built out of old computer chips.

Follow this link for full instructions.

Hard Drive Wind Chimes

The drive platters themselves are also quite remarkable: precisely made aluminium patters with a surface not unlike recording tape. The disks make a lovely clear note if you strike them, so it was only natural to make them into a set of wind chimes.

An interesting side effect is that the shiny shiny platters reflected little spots of light into the house. Naturally, if you have cats, they’ll love it too.


Follow this link for full instructions.


Hard Drive Picture Frames

So, you’ve disassembled hard drives, taken the magnets out, made wind chimes out of the platters, and so on. One thing that you might have left over is a set of printed circuit boards. Funny shaped printed circuit boards, with holes in them.

Here’s how to turn those leftover PCBs into fabulous geek-chic picture frames.

It’s done! Hang it on something ferromagnetic!

Here’s a completed picture frame, hanging on a wire bookshelf.

Follow this link for full instructions.