I’ve been doing it wrong!
I picked up a 10 pack of these 7 segment red LED displays for less than $5. Since each display requires connecting to a minimum of 8 of the 10 pins (9 if using the decimal point), they aren’t exactly easy to work with. Sure, you can buy these where 2 or 4 displays are already connected in a nice package, controlled with the help of an integrated circuit, but where is the fun in that?
If you need to use more than 1 or 2 displays (at 8-9 pins per display), you’ll quickly run out of pins on your microcontroller or Raspberry Pi. The most common way to work with several of these displays is called multiplexing. It’s a method where you briefly turn on one display, turn it off, turn on the next one, and turn it off. You repeat this through all of your displays and then start over. If you do this fast enough, the human eye thinks all of the displays are on at once. It’s pretty slick!
The advantages of multiplexing are:
- Fewer wires/pins needed to drive the displays.
- Lower power consumption since the LEDs on only one display are lit.
Let’s get our hands dirty, shall we?
Seven of the pins on one of these displays match up to the 7 segments (labeled a through g), one pin is for the decimal point (DP), and the two remaining pins can be used for the common cathode (cc), though you only need to connect one or the other. Over to the right you can see how all of the pins and LED segments are arranged. Pretty straight forward.
I’m using 6 of these displays in a project, so I needed a lot of wires. It got complex and tangled in a hurry, but amazingly, I connected all the wires without a single mistake on my first try. 🙂 For the most part, I based my circuit design off of this schematic…
The end result is something like the Fritzing screenshot below. With so many wires overlapping, it’s not easy to see what’s really going on here. I suggest grabbing wiring.fzz from my GitHub repo and playing around with it in the Fritzing app.
When I went to write my proof of concept code, I decided to use the Gpiozero Python library to simplify working with the LEDs. The library allowed me to set up a couple of arrays for the LED segments and the 6 digits (displays)…
segment_leds =  for i in range( len( segment_pins ) ) : segment_leds.append( LED( segment_pins[i] ) ) digits =  for i in range( len( digit_pins ) ) : digits.append( LED( digit_pins[i] ) )
Then I could easily loop through and toggle the LEDs in a display as necessary…
for i in range( len( digits ) ) : for j in range( 7 ) : if ( numbers[ digit_values[i] ][j] ) : segment_leds[j].on() else : segment_leds[j].off()
To make sure things worked I count up from 999000 and then start back at 000000 after hitting 999999. You can see the full code on GitHub.
Now for some visual proof that I actually got it all working! Here it is running when I keep one digit lit for 5/10,000th of a second before turning it off and lighting the next digit.
You’d never know that only one digit is turned on at a time, would you?
If I change from 0.0005 to 0.05 of a second you can start to see that only one display is on at any point in time.
You may also notice it’s counting up a low slower due to the way this code increments the counter. Don’t worry about that.
When I keep each digit turned on for half of a second you can really see how this works.
An issue I’m running into on a Pi Zero is when the processor gets busy doing other tasks, there is a bit of flicker across the displays. You can see this a couple of seconds in to the first video. I’m guessing the code would perform much better on a Raspberry Pi 3B. For my project it’s not a concern, but I want to mention it in case you follow this for your own project. You may also pick up what looks like random flickering of a single digit here and there but that’s due to video timing; the human eye doesn’t see any of that when it’s in front of you.
If necessary, you can take multiplexing a step further and only light up an individual LED on each display at a time, with a method called charlieplexing. It will use even less power, but due to the speed at which you need to switch from one LED to the next, especially across an array of multiple displays, you lose brightness to the human eye.
Mom gets what Mom wants. The necessary parts came in to build Mom’s Raspberry Pi-Hole server, so I thought I’d take the extra time to keep track of every step, trying to make it as easy and low-cost as I could. This meant not attaching a monitor or keyboard through the entire process. Hopefully someone will benefit from this guide. It looks long and scary, but I tried to be as thorough as possible. Nothing here is particularly difficult if you can follow directions.
Note: these instructions are for using a Mac.
Step 1: Buy the Parts
At a minimum, I recommend:
Make sure the microSD card is class 10, because it’s faster and don’t be afraid to go for 16GB since they are so cheap. Adafruit sells a budget pack which includes everything above except the WiFi adapter. If you don’t want to use WiFi, you could get something like this Ethernet Hub and USB Hub.
I also recommend some type of case. It may be small, but it’s still a computer with electrical components. 😉 I bought the Adafruit Raspberry Pi Zero Case this time around, but I don’t like how loose the GPIO slot cover is. Three cases I use with my own Zeros and like (ordered by preference) much better are:
- Pibow Zero Case for Raspberry Pi Zero v1.3
- Zebra Zero for Raspberry Pi Zero – Black Ice GPIO T2
- Adafruit Pi Protector for Raspberry Pi Model Zero
Shouldn’t cost more than $50.
Step 2: Install the Operating System (Raspbian)
- Download Raspbian.
- Download ApplePi Baker and extract the app from the zip file.
- Plug the SD card into your computer, probably via a USB card reader or SD card adapter.
- Launch ApplePi Baker. It’ll ask for your MacOS user password.
- Select your SD card on the left side.
- Uncheck Auto eject after successful restore.
- Click the Restore Backup button and browse to select the Raspbian file you downloaded. Once selected it’ll start writing to your SD card. It should look like this…
- While that is running, save this sample wpa_supplicant.conf file. If you set Format to All Files you can remove the
.txtwithout MacOS adding it back on. This file needs to be named exactly
- Open the file in TextEdit. Replace
with the name of your WiFi network and
YOUR_PASSWORDwith your WiFi password. Save the file.
- When ApplePi Baker is finished click OK and quit the app.
- Copy the updated
wpa_supplicant.conffile to the SD card.
- Open the Mac’s Terminal app.
cd /Volumes/bootand hit Enter.
touch sshand hit Enter.
- Quit Terminal.
- Eject the SD card via Finder and then remove it from your computer.
Step 3: Prepare the Raspberry Pi
- Slide the SD card into the slot on your Pi Zero.
- Put the Pi Zero into your case if you have one.
- Plug the USB cable and WiFi adapter into the micro USB port labeled USB. Hint: it’s not the one on the end. You should end up with it looking like this…
- Now you’re ready for power! Plug your power supply into the other micro USB port (nearest to the edge) and into your power source.
- You should see some activity from the green light (labeled ACT) near the power connection.
Step 4: Access the Pi
If you did the second half of step 2 correct, the Pi should have been able to connect to your WiFi network. Give it 1-2 minutes to go through the entire boot process.
- Open the Mac Terminal app again.
ssh firstname.lastname@example.org hit Enter.
- Using the IP address for SSH may work better for you
ssh email@example.com you’ll need to find it in the DHCP list in your router’s admin.
- Using the IP address for SSH may work better for you
- If everything worked, it’ll connect and you will be asked if you want to continue. Type
yesand hit Enter.
- Then you’ll be asked for the password. Type
raspberry(you won’t see any characters on the screen) and hit Enter. This should log you in and set you at the command prompt…
Step 5: Run Software Updates
sudo apt-get updateand hit Enter.
- When it finished you’ll be back on the command prompt. Type
sudo apt-get upgradeand hit Enter. When it asks Do you want to continue? [Y/n], type
y, hit Enter, and wait.
Step 6: Configure Your Pi
sudo raspi-configand hit Enter.
- Any mouse/trackpad devices won’t work in here, so get used to the tab, Enter, and arrow keys.
- Change User Password. Remember it!
- Choose Advanced Options and then Hostname. Set a new “computer name” instead of the default raspberrypi. When you’re done and back to the main menu, select Finish and perform the reboot.
- You’ll lose your connection when the Pi is rebooting. Terminal will send you back to the local Mac command prompt. Wait 1-2 minutes.
Step 7: Install Pi-Hole
- Connect back to your Pi via ssh, but this time you need to use your new hostname. For example if I had set
nickspithe new command I would type is
ssh firstname.lastname@example.org. You’ll be prompted again to continue and enter the password. Do both.
curl -sSL https://install.pi-hole.net | bashand hit Enter.
- Accept all of the defaults when prompted during installation.
- At the end it’ll give you a bunch of information on an Installation Complete! screen. Make note of the IP address and admin password. Hit Enter.
- It’ll do a little more and then send you back to the command prompt along with providing all of the information again.
- Change the password right away with the command:
pihole -a -p PASSWORD_YOU_WANT_TO_USE
Step 8: Configure Your Router
- Now you need to make your router pass all DNS requests through this Pi-Hole server. Every router is different so you may need to look up how to configure yours if you don’t know how. You want to set the first DNS server to the IP address you wrote down. I like to set Google DNS as a secondary/backup, which is
Step 9: Profit
Enjoy your mostly ad-free browsing and faster network!
Step 10: Notes
It’s not advised to unplug the Pi from power when it’s running. You could corrupt the SD card. SSH in (you’re a pro by now) and issue the shutdown command:
sudo shutdown -h now
Wait about a minute before unplugging power (make sure the activity light has been off at least a few seconds). You can also issue a restart command if you need to:
Periodically it’s a good idea to update the software:
sudo apt-get update
sudo apt-get upgrade
With all of that said… if you plan to run anything else on this server, I recommend going with more power, probably a Raspberry Pi 3 Model B. The Zero I originally used wasn’t enough to handle Home Assistant and Homebridge running on the same machine.
I’ve been using a Keurig for a years. It’s fast, easy to use, and I rarely want more than one cup of coffee. During a trip to Puerto Rico a few years ago, we made coffee using a French Press and I’ve never been able to forget about it. The flavor and experience was completely different.
I have a hard time coming up with a Christmas list anymore, so I asked for an AeroPress this year and got it. I’m really enjoying my new morning ritual.
1. Measure out 15-18g of coffee beans.
2. Grind the beans.
This JavaGear Aromata Grinder works well and is easy to do while the water is heating up on the stove.
3. Insert the plunger, flip it over, and dump in the coffee grounds. Fill with water, stir, and let stand for 1 minute.
4. Place the filter and screw cap on the end.
As shown below, I’m using a mesh filter. If you’re using paper filters (1 or 2), get it wet with hot water and place directly in your end cap.
5. Flip it all over, placing on your coffee cup in one motion. Be quick!
When the sound of dripping coffee changes to air hissing it’s time to stop.
A big change is that I’m only getting a 4 oz cup of coffee each morning, but to be honest it hasn’t been an issue. I’ve never drank coffee for quantity and the quality improvement is hard to beat.
Blue Bottle Coffee has been on my radar for years. I signed up for a sample and loved it, so I quickly subscribed to get a 12 oz bag every 2 weeks ($19). The difference from the Starbucks beans I was given is unbelievable. If you have any other recommendations, please let me know.