Posted on

My Raspberry Pi Weekend

Extended weekend really. I spent my four days off this week without too much to do, but I felt super productive because it’s my first days to myself since the holiday. Amongst catchup up with washing and actually doing some drawing I set up my Raspberry Pis again.

I’ve currently got two Raspberry Pis set up – A Raspberry Pi 2 which is the main one I use. I’m doing some home automation stuff and the Raspberry Pi 2 acts as the hub of that, with a Raspberry Pi Zero feeding it data from across the room.

I just want to talk about some of the stuff I’ve done, because I’m not ready to post tutorials and code snippets yet, but I will soon!

Firstly, I have set Dexcam back up. So tweets of whatever my rabbit is up to get posted once an hour. It might be a little boring compared to last time as he now has a two floor bunny mansion, so if he’s not on the top floor it won’t really show much. The aim is to change it to sense motion, wait a second then take a picture? But for now it’s fine the way it is.

I’ve also been working with the Phillips Hue API so I can control the lights using my own code. I wasn’t going to touch them at first as anything I’d need them to do can be done via the Hue app or IFTTT. But that attitude wasn’t letting me play with code so I’ve added a few scripts to the Pi which I can call for fun.

Speaking of calling the scripts, check this out:

This is my (currently very ugly) control panel I have been making. Any scripts I’ve written can be called on this page. The bunny button takes a one-off Dexcam picture and tweets it. The lights below let me change colours or do a colour loop on the light behind our TV. 

I’m yet to add our other lights to the system. We did however discover our Hue lights fit our fish tank. SO GUESS WHAT THE RAINBOW FISH BUTTON DOES?

I know I know, that’s the most pointless thing you ever saw. But it looks freakin’ cool. Did I mention we got new fish? Uh, yeah, nothing to do with me that…

Speaking of nothing to do with me being the reason we got new fish; I also bought a temperature monitor for the Raspberry Pi. It’s attached to the zero because we needed it hidden away behind the tank and no-where near the Dexcam Pi.

So on my control centre screenshot the final figure is the tank temperature. It’s actually a little high in that screenshot which Terry is fixing. The final plan now is to set up a text alert in case the tank temperature suddenly drops, you know, in the totally hypothetical situation where someone might accidentally unplug the tank and kill them all. That, coupled with a smart plug where we can remotely flip it back on? 

I totally don’t sound like I’m trying to make up for a past mistake, huh?

I guess the best part of this whole thing is me just coding some junk for the control centre. I’ve levelled up in PHP because of it though, and written my first functional object orientated PHP scripts.

That, coupled with some Python, Bash and some pretty shady hacky things have been really fun. For example, I’m not the best coder, so the only way I saw to get the temperature to display on the Raspberry Pi 2 hosted control panel was to have the python script taking the temperature dump the output into a .txt file, then SCP the file to the main Raspberry Pi, then the PHP reads and displays it. 

Which seems rather convoluted but for me it was a good way of discovering some of the things I can do. 

Anyway, I’ve rambled enough without really showing any code or circuit set-ups so I’m going to work on prettying them up so I can write some guides!


Posted on

Kay’s default Raspberry Pi setup

Blogging this for my own reference mostly, as there’s a few things I like to set up by default when I format my Raspberry Pi. It may come in handy to people setting up though so here we go.

OS and base functions

I start by installing Raspbian, I download the .img file from here:

I then reformat my micro USB as Fat32 using Disk Utility. Then I use this command to mount the .img on to the drive via Terminal:

sudo dd bs=1m if=path_of_your_image.img of=/dev/diskn

The ‘n’ needs changing to the disk number, which can be found in Disk Utility when formatting.

Boot up The Raspberry Pi and it’ll setup Raspbian. I start off by leaving all settings at their default, but I make some changes using raspi-config

  • Enable the camera module.
  • Enable SSH access

Then close the configuration window and reboot. 

Enabling wireless internet connection

To do this I use a very cheap mini wifi dongle off eBay, it’s totally basic and was bought purely for the tininess of it. The setup I imagine applies to most wireless USB dongles:

First I plugin the USB and then run: dmesg | more | grep usb

This gives me a list of USB devices – it’s a quick check to make sure the USB dongle was picked up by the Raspberry Pi.

Then run ifconfig to get a list of network adapters. The USB dongle will be listed there, most likely as ‘wlan0’ – but make note of whatever it is listed as.

Next I run:

sudo nano /etc/network/interfaces

To edit the network connection settings, I need to add configuration for my network adapter dongle in here, here’s what I put:

iface eth0 inet manual

allow-hotplug wlan0

iface wlan0 inet manual

wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

Next, I run iwlist wlan0 scan which lists nearby wireless networks my dongle can connect to. I had to reboot a few times to get this to work, but it worked fine first time the last time I set up. So that’s just worth noting. 

If your network appears, note down the SSID of the network, it should just be your wifi network’s name.

Now edit this file as so: sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

And add this to the end of it:




And save that. Reboot the Raspberry Pi and it should be connected to the internet now. You can test this by running a quick ping 

Package Installs

The following are just a bunch of packages I install when I’m setting up which I find useful for various reasons:

apt-get update — Update everything

apt-get install ssmtp — Useful for testing email stuff

apt-get install vim — My preferred text editor. Nano is installed on the Raspberry Pi by default hence using Nano for everything so far.

Useful command list

raspi-config — Raspbian config menu, you can change hostnames, enable camera and SSH and manage other useful setup options.

raspistill -o test.jpg — Take a photo using the Raspberry Pi camera module

I’m still in the process of setting up, So I might add more to this later.