Parts: 1 | 2
It’s finally time to get some work done on a project I’ve been thinking about for a while. Keeping with the theme of Nerd-Wedding, and paying attention to how important our friends are to us, I will be making a box that requires the best man, and the maid of honor, to input a 4-digit code of their own choosing before it opens to reveal the rings we will exchange during the ceremony. Below are the requirements:
- Come up with a cool name. Current project code name is ConsentBox v2.0
- Not look fucking ugly.
- Battery operated (Raspberry Pi)
- Get maid of honor / best man PINs from text files, recognize whether either was entered
- (decide if they both need to be entered for one box to open or if each opens a different compartment) – Need some input from the love on this one. If ONLY there was SOME WAY for her to see this and comment on it…
- Write Python to reflect the above. This is the easiest step as I will be reusing code I made for a different project.
- Build / repurpose box to open automagically. I will be making an interference fit “lock” (or two) that is/are operated by servo[s]. Also springs will be involved.
- Python for Servos? Currently looking at using servomaster or pigpio
Aaaand that’s about all that comes to mind. Below will be an account of today’s successes and failures in terms of setup and getting back on the horse with my favorite kind of pi and most hated kind of programming!
Getting the Raspberry Pi up and stable:
Decide if you need a GUI. In this case I don’t, and I want this to be as small and streamlined as possible (we will be using some VERY inefficient code, I know, I wrote it) so we will be securing the latest Raspian Lite from the Raspberry Pi Foundation. https://www.raspberrypi.org/downloads/raspbian/
Choose what you’ll be using to burn your image to card. I will be using win32diskimager, which I have found to be wonderfully fast and reliable at reading and writing images to or from SD Cards. https://sourceforge.net/projects/win32diskimager/
Unzip the image you downloaded and burn that bad boy!
Get your fresh Pi off the windowsill, hook it up to a monitor, and get going! Default user: pi default password: raspberry
- Change your password by issuing ‘passwd’
- use ‘sudo raspi-config’ to expand the storage to use the whole card, set your keyboard, time, and wifi country values in localization options. Bonus points for setting your hostname to something other than the default.
- Exit raspi-config, but don’t reboot yet.
- enable ssh by typing ‘sudo touch /boot/ssh’
- reboot by issuing ‘sudo reboot’
- Login again! with your new password! Look at you go!
- Configure WiFi. Issue ‘sudo nano /etc/wpa_supplicant/wpa_supplicant.conf’
- Add a block like this to the end of your file:
- Save your changes using Ctrl+o and hitting enter at the suggested filename (hint, it’s just the current filename) and then exit using Ctrl+x
- reboot again
- Yay! it worked.
This is where our steps will probably diverge. I have a NAS at home that proves it’s use over and over, and this is no exception. Because I’m not a fucking masochist, I’ll be using Atom to edit the python files I’ll be writing for this project, those will be saved onto my NAS, and the pi will execute them from there. So now we get to start mapping (in Linux its called ‘mounting’….heh….heh…) shares! Prerequisite to the below is that you have a user already set up for you Pi’s on the share. I do, and you should too. You would be amazed how handy it is to be able to grab any file you want from anywhere in your home.
- Create a directory that you will use as your mount point. I call mine ‘General’ because that is the name of the share that it will be using on my NAS. I prefer to do this in /home/pi ‘mkdir /home/pi/General’
- Make sure you are in /home/pi ‘cd /home/pi’
- Verify that everything is working by mounting the share once ‘sudo mount -t cifs -o username=pi@nasName,password=password //nasNameOrIP/General ~/General’
- Verify that it is indeed mounted by either ‘cd’ing to it or just use ‘df -h’
- It’s there you say? Sweet!
- Set it mount every time you start by issuing ‘sudo nano /etc/fstab’
- At the bottom of your fstab, add the following: ‘//nasNameOrIP/General /home/pi/General cifs username=pi@nasName,password=password 0 0’
- Save and exit as before
- reboot as before
- verify it auto-mounted!
Now we have the framework for not wanting to chop our dicks off every time we need to create or modify code for this to run. In a future post I’ll go through how everything is setup and some of the code. Fun Fun!