Amelia uses hardware!

I know, its hard to believe.

But I have had a few projects in mind (variations of them too) for a while now, and a raspberry pi seemed like a more complete starting point than some of the other circuit boards out there (I'm looking at you Arduino). Raspberry pi comes with several of its own OS, including Raspbian, and Noobs. For my project, I decided to use Raspbian stretch. I also added a ssh file (file named ssh with nothing but a command to prompt the drive name) for good measure.

I've wanted a way for my Echo Dot to connect to my LAN (and all the APIs that are available through that) for a while now, and my first project with a pi was to get all that set up. The AWS part was not fun to work in, but the raspberry pi sure was after I got the hang of things!

The first thing you'll want to do when you get a raspberry pi is get it booted up and enable SSH. I'm borderline-hardware inept, and so this process (which really should only take 5 minutes) took me 2 days. I also lack an HDMI monitor since all my work is done on laptops, and this was something raspberry pi kind of expects you to own. I found out a few things while I was connecting my first raspberry pi, among them that it can be done with nothing but a laptop but that is a more difficult process.

A raspberry pi is basically just a minimalist computer, and once you've got it plugged in and hooked up (usually through ethernet) it should show up on an arp -a command for IPs in your local network. This part was mostly painless for me since I've got my router set up to use fixed IPs, but if you use dynamically generated IPs you might want to switch that over before you start trying to work with a pi. On a windows machine, the process is slightly more cumbersome just because you have to SSH in through putty instead of command line, but one day windows will catch up to the rest of the operating systems with its command line...I hope.

Once you've SSHed in, you should see a login prompot, where the username is pi and its waiting for a password. Did you guess raspberry? Because if so, you are correct. You'll want to change the password or create a new user account and delete the default one immediately though, since anyone and their mom will be able to get into your pi from your local network just by googling the default settings if you don't. Once you've logged in, you'll see a boot screen which you can then navigate to do things like boot your raspberry pi automatically, change that account/pass set up, change the network settings, change advanced settings...the sky is the limit.

I had a few things I needed my pi to do for me. Firstly, it needed to receive and poll SQS messages. Secondly, it needed to connect to 3 different APIs, and then run some functions off of them depending on which message was in the SQS queue. The programming for most of this was pretty easy, I recommend getting the code solid on the machine you are going to tunnel into the pi from (run it on a local server or command line or wherever) and then once you're sure it works, get it ftped onto the pi.

Now this is argueably a vanity thing, but the raspberry pi could use a casing unless you like the circuit board appearance. Its more fragile when its exposed like that though, I can attest that I had at least 2 people almost put heavy hardware like a hammer down on top of mine. If you buy a starter kit for a raspberry pi, it will likely come with one that fits for that model, but otherwise you can find some pretty cheap (and nice ones) through google searching. They're simple to snap together, and they will protect your pi from unobservant friends and relatives.

The last step I had to implement was getting the raspberry pi to run my code on boot. This was a little annoying, only because my initial efforts to use rc.local did not work. I ended up using some code in the /etc directory to call an exce command line function on boot.

That's really about all there is to it! I got my pi auto-booting, and then running my code as soon as it starts up without having to expose it directly to the internet. Because it looks for SQS messages, I can send a command like "TV On" or "Party Lights" and it will handle it via a switch case to know which API it should connect to and then use to run functions. I also bundled several API calls together for certain commands, like "Movie Time", which will turn off the lights, turn on the TV and turn the speakers volume up. All in all, I'm pretty pleased with where this project is at, but long term I'd love to get it connected to my cell phone so it can detect which room I'm in by the signal strength and turn the lights on/off accordingly. For now, that's a future project, but it will probably end up happening, knowing me.

Now that I've gotten a taste for the pi, though, I've got half a dozen project ideas that I can't wait to start. Raspberry pis are ridiculously fun.