5 tips on how to Pi

werner
4 min readOct 1, 2018

This post shares 5 tips that I have come to learn from and use when hacking things on the Raspberry Pi.

I assume you have a Raspberry Pi (or many), have played around with it, and know the basics

1. Create your own base image

Having a zillion microSD cards lying around is not fun. On top of that, remembering which project is on which one, becomes crazy.

So the solution is to standardise…

  • Choose a distribution that you are comfortable with — e.g. Raspbian
  • Flash the card and boot it up on your Raspberry Pi
  • Configure networking, ssh keys, python, and anything else you would like to always have available for a project.
  • Once done, remove the microSD card from the Pi.
  • Create a .img file of it using a computer. For example on Linux and MacOS it’s pretty much the same :
sudo dd if=/dev/{{device}} of=RPi-Base-Sep-2018.img bs=1m

Once done, you have a base image pre-configured with your requirements able to connect to your network, and accessible over it.

Every time you start a new project, simply flash a microSD card with this image.

Advanced Tip : If you’d like to take this concept further, check out the Yocto Project — It let’s you build your own custom kernels and user space components in a layered fashion. I have various Yocto configurations I use to give me the exact stack I need.

2. Use Docker

Having a base image to work with is one thing, but what about all your code?

Some would argue using a VCS such as Git or Subversion is all you need, but it’s not. Often times “embedded” code relies on libraries or OS level dependencies, which need to be setup and installed separately.

For this reason, containerising your code is the way to go, and Docker is basically a VCS for environments (and more)

Remember, Docker containers built for the x86 architecture will not work for ARM architectures, and vice versa.

Installing the Docker Engine is easy :

curl -sSL https://get.docker.com | sh

And with that, turning your Raspberry Pi into — for example — a Pi-Hole for DNS level ad blocking, is simply a matter of:

docker pull pihole/pihole

And setting your router to use your Raspberry PI as DNS server.

Advanced Tip : If you’d like to take this concept further, check out Docker Swarm and deploy containers from your computer (or anywhere) — By doing this I rarely SSH into a Pi for a project, and can deploy the same project to multiple Pi’s instantaneously.

3. Use a 3rd party camera module

Waveshare RPi Camera ( http://www.waveshare.com/rpi-camera-b.htm )

There is nothing wrong with the stock Pi Camera (especially for its price), but if you want to do anything more than take a few pictures, you’ll need something with at least adjustable focus.

I suggest the Waveshare module which I’m actively using in my face detection and recognition projects.

4. Don’t use a USB-to-Ethernet adapter

Don’t get me wrong, one of those cheap USB adapters works fine if you need two or more network ports — but the main reason you would need two or more NICs is for a firewall / gateway setup, right?

Well, you will maaaybe get 5Mbps over it — not very useful to pass your entire home network traffic over now is it?

The solution is to get a proper Ethernet hat that fits onto the GPIO header. I got a couple of these and one is actively used as part of a packet filter on my network.

5. Cool it down

It doesn’t matter what you use your Pi for, but for $1.00 you may as well get a heat sink for it’s brain. You’ll get slightly better performance, and it will last longer — but more importantly, it looks so cool!

So that’s it for now. Thanks for reading!

--

--