Pushing Arduino Data to MySQL via PHP Part 2: The Server

tempdataIn the last post, I talked about how to send data from the Arduino to the MySQL server.

Today, I’ll cover how I’m receiving and displaying that data on the server side.  I’ll put the code for the webpages into this post but I’ll put everything together in a nice little package at the end of everything.  I mentioned last post that the end trick was to let the server worry about processing the data instead of the Arduino.  I’m running this on my NAS but it could be run on any standard web server with PHP and SQL.

For the purposes of this code, I’ve placed the files in a directory called “temps” on the root of the web server.  If you want to put them elsewhere, such as “temperaturelog” or “home/temps” or wherever, you’d need to alter the code of the Arduino in the previous points to replace the temps directory with the directory you plan to use.  I’m going to assume that the reader has a basic LAMP (Linux, Apache, MySQL, PHP) stack style server and knows the basics of how to create databases and run things on it.  If not you can Google the basic set up, though I may do a quick write up and reference it here eventually.

You’ll need to create a database called “housetemps” and import the linked structure file into it.  (If you know what you’re doing in PHP you can rename housetemps)   This will create a table int he database called “temperature” with the following columns: id, event, sensor, celsius, humidity, datestamp.  This will give you the basic structure needed to run the php code on the server.  A quick rundown of what these values are used for…

  • id – A standard auto incriminating id value for SQL
  • event – Time and date of when the event happened
  • sensor – A text based identifier for each probe.  This example uses one probe but could be altered for more.
  • celsius – The temperature reading, it doesn’t actually have to be Celsius, that’s just the default of the probe.
  • humidity – Humidity reading in percent humidity
  • datestamp – A date only time stamp, used for sorting the data when you review it later.

Now that you have the core database structure set up, the server needs to know the credentials for connecting to the database.  Since this is used by several files, it’s best to put the info in it’s own file and use an include statement int he PHP to add it.

In the “temps” directory create a file dbconnect.php and add int he following code, changing the values listed for the values used when setting up the database…

<?php
$MyUsername = “USERNAME”;  // enter your username for mysql
$MyPassword = “PASSWORD”;  // enter your password for mysql
$MyHostname = “localhost”;      // this is usually “localhost” unless your database resides on a different server

$dbh = mysql_pconnect($MyHostname , $MyUsername, $MyPassword);
$selected = mysql_select_db(“housetemps”,$dbh);
?>

Next you’ll need a way to get data into the table.  This is done using add_data.php, which is called by the Arduino in the code shown previously.

Make a file in the “temps” directory called add_data.php, and add the following code.

<?php
// Connect to MySQL
include(‘dbconnect.php’);

{
$dateget = date(“Y-m-d”);
// Prepare the SQL statement
$SQL = “INSERT INTO housetemps.temperature (sensor ,celsius, humidity, datestamp) VALUES (‘”.$_GET[“serial”].”‘, ‘”.$_GET[“temperature”].”‘, ‘”.$_GET[“humid”].”‘, ‘$dateget’)”;

// Execute SQL statement
mysql_query($SQL);
}

// Go to the review_data.php (optional)
header(“Location: review_data.php”);
?>

The code is pretty straight forward. The first section includes our previously created log on credentials.  The last section forwards the page on to review the data.  The meat is in the middle with the SQL statement.  The line $dateget = date(“Y-m-d”); creates a Year-Month-Day date for sorting later.  The next line creates the SQL query using variables passed via the url, the third part executes this query adding the data to the database.

The final piece of this whole thing is the review_data.php file.  This file displays the results in a nice looking table.

<?php
// Start MySQL Connection
include(‘dbconnect.php’);
?>

<html>
<head>
<title>Arduino Temperature Log</title>
<style type=”text/css”>
.table_titles, .table_cells_odd, .table_cells_even {
padding-right: 20px;
padding-left: 20px;
color: #000;
}
.table_titles {
color: #FFF;
background-color: #666;
}
.table_cells_odd {
background-color: #CCC;
}
.table_cells_even {
background-color: #FAFAFA;
}
table {
border: 2px solid #333;
}
body { font-family: “Trebuchet MS”, Arial; }
</style>
</head>

<body>
<h1>Arduino Temperature Log</h1>

<p>Select Date:
<?php

$sql = “SELECT DISTINCT datestamp FROM temperature”;
$result = mysql_query($sql);

echo “<select name=’datestamp’ onchange=’location = this.options[this.selectedIndex].value;'”;
while ($row = mysql_fetch_array($result)) {
$current = $row[‘datestamp’];
echo “<option value=’review_data.php?dateselect=$current’>$current</option>”;
}
echo “</select>”;
?>

<table border=”0″ cellspacing=”0″ cellpadding=”4″>
<tr>
<!–    <td class=”table_titles”>ID</td> –>
<td class=”table_titles”>Date and Time</td>
<td class=”table_titles”>Sensor Serial</td>
<td class=”table_titles”>Temperature in Celsius</td>
<td class=”table_titles”>Percent Humidity</td>
</tr>
<?php
// Retrieve all records and display them
$SQL = “SELECT * FROM temperature WHERE datestamp LIKE ‘”.$_GET[“dateselect”].”%’ ORDER BY id ASC”;

//Execute the SQL
$result = mysql_query($SQL);

// Used for row color toggle
$oddrow = true;

// process every record
while( $row = mysql_fetch_array($result) )
{
if ($oddrow)
{
$css_class=’ class=”table_cells_odd”‘;
}
else
{
$css_class=’ class=”table_cells_even”‘;
}

$oddrow = !$oddrow;

echo ‘<tr>’;
//       echo ‘   <td’.$css_class.’>’.$row[“id”].'</td>’;
echo ‘   <td’.$css_class.’>’.$row[“event”].'</td>’;
echo ‘   <td’.$css_class.’>’.$row[“sensor”].'</td>’;
echo ‘   <td’.$css_class.’>’.$row[“celsius”].'</td>’;
echo ‘   <td’.$css_class.’>’.$row[“humidity”].'</td>’;
echo ‘</tr>’;
}
?>
</table>
</body>
</html>

The core of this file was lifted from the previously mentioned guide on Tweaking4All.  The problem I had with their results was that it simply displayed an endless list.  I am polling every 15 minutes, so this list tends to grow unwieldy very quickly.  This is where the datestamp marker comes into play.  I added this little chunk of code at the top of the table.

<?php

$sql = “SELECT DISTINCT datestamp FROM temperature”;
$result = mysql_query($sql);

echo “<select name=’datestamp’ onchange=’location = this.options[this.selectedIndex].value;'”;
while ($row = mysql_fetch_array($result)) {
$current = $row[‘datestamp’];
echo “<option value=’review_data.php?dateselect=$current’>$current</option>”;
}
echo “</select>”;
?>

This creates a menu based on unique values of datestamp.  Selecting a value forwards you to review_data.php with a date attached, then review_data.php only shows data that matches that datestamp.  This allows a single day to be viewed easily.  In the future I may add a bit more to this menu, eventually, the list of dates will also become unwieldy in length.  I also plan to run numerous sensors at once with different names so I’ll likely also add a second menu so the list can be sorted down by sensor name.

I’m also looking to add a bit more functionality to the code in the form of a graph, so it will be easier to see trend lines in the data.  The data I have now is from my office, in a well insulated basement room, so the trend lines are rather boring, but when there are several sensors in different rooms in the main area of the house, or even outside, this data becomes more interesting and useful.  I’ll go into this at a later day though…

 

 

Pushing Arduino Data to MySQL via PHP

Arduino+EthernetThis is part of my little ongoing project of learning with the Arduino.  I want to give a mention to Tweaking4all’s guide to PHP, SQL and Arduino, because I started out using it as a base for this section of the project, though I altered a few parts to work with my sensors and Ethernet board.  That guide definitely pointed me in the right direction and made me realize just how simple it would be to actually push data to the server.

My initial approach to the problem was that I needed the Arduino to run some SQL queries and interact directly with the database and insert readings and other variables.  In the end, all I needed was a PHP file on the server to interact with the database, and the proper call from the Arduino to the PHP file.

I started out with basic code to dump dummy data (ie not variables) to a database running on my laptop.  I couldn’t get UIPEthernet linked int he Tweaking4all guide to work so I just used the default Arduino Ethernet libraries.  I also simplified the code down to one probe, though adding more temperature probes will be trivial.  After I managed to get the dummy data to post reliably, I moved on to adding variables in place of the dummy values.  Once again, I couldn’t get the OneWire library to load properly and work with my senors, so I went back to the basic DHT-11 library that I knew work.  This actually simplified things considerably, I used the same calls I had done previously in testing and instead of pushing them directly tot he serial port, I dumped them to some variables which are then passed to the SQL statement.

I also added variables and functions to read Humidity, since he original article doesn’t have humidity readings included.

The final hurdle I came across, for some reason, the delay() function wasn’t working properly.  I set it to poll every 15 minutes (in milliseconds) but it never posted a new update beyond the initial one when powered on.  If I tried a shorter interval, such as 5 minutes (in ms), I got new readings every 30 seconds or so.   In the end, I used a better method of handling time with currentmills.  This reads the current number of milliseconds since the last reading.  By reading currentmills and comparing it to the last reading “time” I can verify if it’s been 15 minutes since the last reading.  This method is not super precise and has some play on interval but I’m not doing anything requiring perfect timing with this project.

In the end, I ended up with the following code for the Arduino:

#include <SPI.h>
#include <Ethernet.h> // Used for Ethernet
#include “dht.h”

dht DHT;

#define DHT11_PIN 5

// **** ETHERNET SETTING ****
// Arduino Uno pins: 10 = CS, 11 = MOSI, 12 = MISO, 13 = SCK
// Ethernet MAC address – must be unique on your network – MAC Reads T4A001 in hex (unique in your network)
byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };
// For the rest we use DHCP (IP address and such)

EthernetClient client;
char server[] = “SERVERIP“; // IP Adres (or name) of server to dump data to
int  interval = 360000; // Wait between dumps
unsigned long previousMillis=0;

void setup() {

Serial.begin(9600);
Ethernet.begin(mac);

Serial.println(“RamenJunkie’s Ethernet Temperature Probe based on Tweaking4All Probe”);
Serial.println(“-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n”);
Serial.print(“IP Address        : “);
Serial.println(Ethernet.localIP());
Serial.print(“Subnet Mask       : “);
Serial.println(Ethernet.subnetMask());
Serial.print(“Default Gateway IP: “);
Serial.println(Ethernet.gatewayIP());
Serial.print(“DNS Server IP     : “);
Serial.println(Ethernet.dnsServerIP());
}

void loop() {

unsigned long currentMillis=millis();

if((currentMillis – previousMillis) > 900000)
{
previousMillis=currentMillis;
// READ DATA
Serial.print(“DHT11, \t”);
int chk = DHT.read11(DHT11_PIN);
switch (chk)
{
case DHTLIB_OK:
Serial.print(“OK,\t”);
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print(“Checksum error,\t”);
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print(“Time out error,\t”);
break;
default:
Serial.print(“Unknown error,\t”);
break;
}

// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println(“-> Connected”);
// Make a HTTP request:
client.print( “GET /temps/add_data.php?”);
client.print(“serial=”);
client.print( “Probe1” );
client.print(“&”);
client.print(“temperature=”);
client.print(DHT.temperature,1);
//      client.print(“88”);
client.print(“&”);
client.print(“humid=”);
client.print(DHT.humidity,1);
//      client.print(“88″);
client.println( ” HTTP/1.1″);
client.print( “Host: ” );
client.println(server);
client.println( “Connection: close” );
client.println();
client.println();
client.stop();
}
else {
// you didn’t get a connection to the server:
Serial.println(“–> connection failed/n”);
}

}

Serial.print(currentMillis);
Serial.print(”  “);
Serial.println(previousMillis);

delay(10000);
}

A few notes to anyone wanting to try to use this.

  • You will need to set the server IP to the IP of your database.
  • You can alter the time interval between readings with the interval variable as well.
  • If you plan to use more than one Arduino probe (which you can), you’ll want to change the MAC address settings.  it can be any MAC value really since you’re just assigning it manually but having multiple devices with the same MAC will cause issues.  I’d recommend simply increasing the last value (31) by one.
  • You can change the line “client.print( “Probe1″ );” to name the probe whatever you want.  The original code read serial numbers but I’m not sure if DHT-11 handles serial numbers or not.  I’d also recommend changing it if you run more than one Arduino probe to the same database.

This will create basic output from the Arduino.  The other half of this is to set up a server running SQL to receive the data, but I’ll cover that in the next entry.  I based it off the code linked above in Tweaking4all but altered it to take in the Humidity as well as allow for viewing individual dates.

Arduino: Cheap Sensors Cheap Results…

Temperature and Humidity SenorsI mentioned last post I had ordered some cheap Temperature and Humidity Sensors for my Arduino boards.  Well they came in, and so I got to do some nice experimenting with code to test them out.  I already had a bit of code from the DHT Test Sketch (Arduino programs are called Sketches) that would poll one sensor and display the results over serial.  Sort of the ultimate goal here is potentially running several fo these sensors around the house and polling them to gather temperature data and store it in a data base that can be accessed via the web.

The first step is getting a Sketch that would poll each sensor and output the result over the serial monitor, preferably with labels.  I started out cutting and pasting the original single sensor code repeatedly and altering the pin before realizing a loop would be way more efficient for this task.  After some fiddling I came up with the following Sketch which polls pins 2-7 sequentially in 2 second intervals and outputs the data to the serial monitor.  This code requires the basic DHT includes from the DHT library.

//
//    FILE: Six Sensor Temp/Humidity Probe.ino
//  AUTHOR: Josh Miller
// VERSION: 0.1.00
// PURPOSE: DHT library based sketch for multiple Temp/Hum probes on Arduino
//     URL: http://www.joshmiller.net
//
// Released to the public domain
//

#include “dht.h”

dht DHT;

void setup()
{
Serial.begin(115200);
Serial.println(“Multi Sensor Temp/Humidity Readings”);
Serial.println(“Version 1.0”);
Serial.println(“Modified DHT Library Version”);
Serial.println(“By Josh Miller, josh@lameazoid.com”);
Serial.println();
}

void loop()
{
int i=1;

while (i<7)
{
// READ DATA

int chk = DHT.read11(i+1);
switch (chk)
{
case DHTLIB_OK:
Serial.print(“\t”);
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print(“Checksum error,\t”);
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print(“Time out error,\t”);
break;
default:
Serial.print(“Unknown error,\t”);
break;
}
// DISPLAY DATA
Serial.print(“Probe “);
Serial.print(i);
Serial.print(” : Humidity is: “);
Serial.print(DHT.humidity, 1);
Serial.print(“, Temperature is: “);
Serial.print(DHT.temperature, 1);
Serial.println(” C “);

i++;
delay(2000);
}

}
//
// END OF FILE
//

Arduino with 6 Senors...I don’t have my Network Shields yet so I can’t play around with getting these numbers to dump into an SQL database (probably one running on my NAS) just yet.  This basic proof of concept though is great since it allowed me to learn some code and test the basic functionality of the sensors.  This code can be modified for any number of sensors by changing the “while (i<7)” line to “while (i<# of Pins/sensors Used)”.

Wiring up the bread board was also a bit of a tricky task, mostly because of the sheer number of connections being made.  Each sensor gets a +Voltage and Ground connection off the bus bar and a wire from the senor.  The new cheap sensors use a different pin out from my “official” expensive senor, not really a problem, but something to look out for.

After wiring everything up, I could plug the Arduino into my laptop and open the serial monitor on the appropriate baud rate and record the results.  The results are actually a bit worrying but further testing will be needed to verify the integrity of the results…

Multi Sensor Temp/Humidity Readings
Version 1.0
Modified DHT Library Version
By Josh Miller, josh@lameazoid.com

Probe 1 : Humidity is: 58.0, Temperature is: 25.0 C
Probe 2 : Humidity is: 46.0, Temperature is: 27.0 C
Probe 3 : Humidity is: 41.0, Temperature is: 29.0 C
Probe 4 : Humidity is: 40.0, Temperature is: 26.0 C
Probe 5 : Humidity is: 35.0, Temperature is: 30.0 C
Probe 6 : Humidity is: 36.0, Temperature is: 32.0 C
Probe 1 : Humidity is: 58.0, Temperature is: 25.0 C
Probe 2 : Humidity is: 46.0, Temperature is: 27.0 C
Probe 3 : Humidity is: 41.0, Temperature is: 29.0 C
Probe 4 : Humidity is: 40.0, Temperature is: 26.0 C
Probe 5 : Humidity is: 35.0, Temperature is: 30.0 C
Probe 6 : Humidity is: 36.0, Temperature is: 31.0 C
Probe 1 : Humidity is: 58.0, Temperature is: 25.0 C
Probe 2 : Humidity is: 46.0, Temperature is: 27.0 C
Probe 3 : Humidity is: 42.0, Temperature is: 29.0 C
Probe 4 : Humidity is: 40.0, Temperature is: 26.0 C
Probe 5 : Humidity is: 36.0, Temperature is: 30.0 C
Probe 6 : Humidity is: 37.0, Temperature is: 30.0 C
Probe 1 : Humidity is: 58.0, Temperature is: 25.0 C
Probe 2 : Humidity is: 46.0, Temperature is: 27.0 C
Probe 3 : Humidity is: 42.0, Temperature is: 29.0 C
Probe 4 : Humidity is: 40.0, Temperature is: 26.0 C
Probe 5 : Humidity is: 36.0, Temperature is: 29.0 C
Probe 6 : Humidity is: 37.0, Temperature is: 30.0 C
Probe 1 : Humidity is: 58.0, Temperature is: 25.0 C
Probe 2 : Humidity is: 46.0, Temperature is: 27.0 C
Probe 3 : Humidity is: 43.0, Temperature is: 28.0 C
Probe 4 : Humidity is: 40.0, Temperature is: 26.0 C
Probe 5 : Humidity is: 36.0, Temperature is: 29.0 C
Probe 6 : Humidity is: 38.0, Temperature is: 30.0 C

Probe 1 is the official sensor, the one that cost me $10, the other 5 are cheap probes, they cost me like $9 total.  I have to assume that Probe 1 is pretty accurate and probably has gone through some quality testing before being sold.  The other 5, for all I know, are rejects that were swept off of some floor in China by the janitor.  The point is, all of the readings of the cheap sensors are pretty off from each other, especially the humidity.  This may actually be the case if these sensors were in separate rooms or even any distance from each other, however, these senzors are all within a few centimeters of each other on the same bread board.

There may be a few things happening here causing this discrepancy, and I only say this because they are at the very least consistent with themselves.

One, it’s possible, that there isn’t enough juice to run all of the sensors at once.  If they are being under powered, I would likely get bad readings.  I can easily test this by running each sensor independently with the old single probe Sketch.

Two, it’s possible that while no accurate to each other, they are accurate to themselves.  I don’t really know what these numbers actually mean, I am assuming % Humidity and Degrees C.  It may be some sort of internal scale factor and I simple need to adapt the program to return scaled results.  The issue with this will be that each probe is polled in a loop, so there isn’t really an easy way to apply a different scale factor to each sensor individually.

Whatever the case, the Temperature is at least semi precise, which is what I care more about anyway.  I’ll probably continue with the project with the idea that if I really want accurate results I could eventually invest in better sensors.  The next step on the software end will be to add network functionality to record the data.  On the hardware end I plan to use some CAT5 wire to allow the probes to be positioned in various places beyond just the Bread Board.

OSEPP Arduino Starter Kit

Arduino and a Raspberry Pi 2BSo, a month or so ago, while traveling for work, I was bored in the hotel room and found out there was a Fry’s Electronics around the corner from the hotel. I decided to pop in and look around and see if I could find anything interesting. I also wanted to see how much Raspberry Pi 2B boards were there (and if they were comparable to Amazon.) They had a couple of Pis, a large selection of basic electronic components and a pretty decent selection of Arduino shields and parts.

I’d been looking into getting an Arduino for a while and decided what the hell. There may have been single packed Arduino boards but I really couldn’t tell from the cards which was the base board an which was just an add on shield. I ended up with the OSEPP Arduino Basic Starter Kit.  Honestly, since I hadn’t ever used an Arduino, I didn’t own an Arduino, and I had some basic but not super amazing electronics skills, this really was the best choice.

The kid includes a lot of nice basic parts as well as a guide book to get you started using these basic parts.  The box itself promotes the major projects of “Volt Meter”, “LED Game” and “Electronic Buzzer”.  It also runs through the basics of lighting up some LEDs.  The tutorials are decent though I wish there was a little more on the basics of how to work the bread board and the little wires.  It’s not hard to figure out, but it also isn’t super self explanatory if you didn’t have any experience with electronics at all.  the Volt meter tutorial is less exciting than hoped and the Buzzer just runs up the music scales but it could be modified to play a tune using the little piezo buzzer.

WP_20150630_09_21_48_ProThe LED game is neat, but simple.  You make the lights flash in sequence and you must press the button when the appropriate light is flashing, which causes the lights to flash faster.  There is also a 7 segment LED in the kid, which you make count down from 9 to 0.  This actually has a lot of fun potential and I have some ideas for it but I need to figure out how to light up both numbers to display a number (such as say, a temperature).

After exhausting the fun of the starter manual, on my next trip to the area, I bought a temperature and humidity sensor and wired it up.  This was a bit trickier since it required figuring out how to find and download the necessary libraries and modifying the code a bit to get it to read properly.  In the end, I managed to get things working though, which was kind of great since the AC in my hotel room didn’t have a digital read out, so I could know exactly how cold it was and why I was either freezing or sweating.

So, fast forward a bit more again, I’ve got some fun ambitions going and the idea of playing with several Arduino projects.  Unfortunately, while cheap, Arduino boards can add up to expensive.  Unless you buy cheap Chinese knockoffs for $3 apiece off of AliExpress.  I also have some cheap Network boards and temperature sensors coming.  Five boards total, five sensors and two network shields, for around $35, really isn’t too bad of a deal if it all works.

And thus, I have a ton of Arduino boards to play with now.

IMGP5277

 

 

Raspberry Pi Rack

Even before buying any Raspberry Pi computers, I had this sort of vision for neat rack to put several of them in. The idea evolved a bit as the logistics of it got ironed out but after picking up a second Pi (and planning to get a third), I went and built the thing.

Raspberry Pi Rack

Sorry for the mediocre pictures, I didn’t think to take photos until things were running and I didn’t really want to unplug it. It currently holds a Raspberry Pi B+ and a Raspberry Pi2 B, the B+ is running a ZNC server to keep me connected to several IRC channels and the Raspberry Pi 2B is running a small OpenSIM server, though I’ll probably re-purpose it since in testing performance seems to top out at around 2000 Prim cubes and 4 Avatars. The instance I’ve got running on my VPS is much more suitable. On the other hand, it could be a good place to “archive” builds.

Raspberry Pi Rack

The build itself is pretty straight forward. I used (roughly) the following materials picked up at Lowes:

  • 3 pieces of 10×8 plexiglass cut to 5×7 size.
  • 6 6″ #8 thread rods.
  • 8 (2 packages) of #8 rounded caps.
  • 3 packages of #8 nuts
  • 6″ Micro USB cables from Amazon
  • Cat 5 Cable cut and crimped as needed
  • 1 Netgear Switch I had already
  • 1 Choetech 40W Smart power from Amazon.
  • The smaller screws holding the Pis in are 4mm i believe, and it took two packages of them (16 screws and 32 nuts).

The hardest part was working with the Plexiglass pieces. I could have cut it with the Dremel but the edge would have been all crooked for sure. Instead I scored and snapped them, which did leave a jagged edge on one edge but it could easily be sanded off. On a starting note, the Plexiglass comes with a plastic protective layer, this should be left ON until final assembly to protect the clear surface as much as possible.

Anyway, to cut the sheets down, I used a square and a box cutter to but a line where I wanted the break to be on one side, then clamped the sheet down on the edge of the workbench between the surface and a 2×4. The 2×4 was mostly to help protect the surface of the plexiglass from the clamps. The cut edge should be on the up side, right at the edge of the surface and the 2×4 (or whatever) at the edge on top. The Plexiglass should snap more or less cleanly off. I had some small chips left hanging on the shorter 1″ breaks to shorten the shelves to 7″ from 8″. I used a small hammer while the pieces was still clamped down to chip these down a bit.

The real trick was drilling the holes. In the end, I found the best results came from clamping all of the plastic sheets together between some boards and drilling them all at once. There should be a piece of wood completely covering the bottom of the drilling spot to help support the plexiglass as the drill penetrates through.

I had some trial and error trying to drill my sheets separately, so the holes are not perfect. For the mounting holes I laid the Pi itself where I wanted it and uses a pen to mark the holes. I probably could have done a bit better with a paper guide though.

Assembly was pretty easy, just a lot of tedious screwing of nuts as the thread rods were fed through the holes. Each shelf takes at a minimum, one nut above and below to hold them in place and the rounded caps go on the top and bottom. The power supply and switch are not mounted, they are simply sandwiched in place between the shelves, though the supporting long bars were positioned around the Switch to prevent it from sliding left or right or backwards.

The Power supply I picked because it has two standard wall outlets on one side. I used the Dremel to cut holes in the top sheet to allow these plugs to be accessible. I wanted the unit to be as self contained as possible, these plugs give me a place to plug the Switch in. It’s important when choosing a power supply that it has enough power on all ports to power a Pi. A USB HUB doesn’t work since it will distribute power across all the ports. Several ports I looked at had 2 “high output” ports for iPads and iPhones but the rest were lower output.

The USB power cables were 6″ jumpers I found on Amazon and the CAT 5 cable were small jumpers I made myself with ends and a crimper. When I add the back two Pis I’ll need different cables though, likely cables with a 90 degree connector and definitely longer ones.

Raspberry Pi Rack

The whole package sits nicely on top of my desktop box next to my Synology NAS.