Introduction: Scrappy Science Caddy

This is an instructable for a data acquisition box using a Raspberry Pi and depending on the MCP3008 8-Channel 10-Bit ADC With SPI Interface (https://www.adafruit.com/product/856). It's purpose is to help with data collection and plotting that data (using the free tool gnuplot), a series of buttons (for marking events such as start, stop, and important events), and a 16 Char x2 LCD display so that the Pi does not have to be hooked up to a monitor and keyboard to be used.

Everything in the project: drawings, schematic, BOM, sample data and plots, and code for this project is in a github repo, I recommend you check it out for any updates or issues after this instructable was posted:

https://github.com/kmkingsbury/raspberrypi-data-ac...

So, who is ready to make some science?

Step 1: Plans and Materials

SketchUp was used to plan/design the box. The drawings are attached to the page (and in git at SketchUp Drawing), and a screenshot is in the images.

The wiring schematic was done in Fritzing and is attached to the page (as well as available at Wiring Schematic ) a screenshot is also in the images.

Bill of Materials (attached and also at Github BOM ):

Hardware
ItemCountPriceUrl / Source
Red Oak Hobby Board (Common: 1/4-in x 6-in x 2-Ft; Actual: 0.25-in x 5.5-in x 2-ft)1$6.47http://www.lowes.com/pd_9365-34050-OAK6X140-U2S___
Plexiglass sheet1$2.97http://www.lowes.com/pd_55844-1638-11G0810A___
Motherboard mounts8$7.90 (for 50)http://amzn.com/B00008VF6K
Round-Head Standard (SAE) Machine Screws #4 & #6 size~16$1.24 for 12http://www.lowes.com/pd_62045-37672-491276___
Nylon Standoffs8~$2.00Local Big Box Store
Electronics
ItemCountPriceUrl / Source
Raspberry Pi 2 or 31$37.99 or $45.97http://amzn.com/B018L66L9S or http://amzn.com/B01CD5VC92
MCP30081$3.75https://www.adafruit.com/product/856
Push Buttons (green, black, red, blue)4$6.98 (for 10 in one color)http://amzn.com/B015CYF3VE, http://amzn.com/B015CYHS3U, http://amzn.com/B015CY8WJ4, http://amzn.com/B017EFQD6S
5 way navigation button1$2.95https://www.adafruit.com/products/504

Potentiometer

1$1.25https://www.adafruit.com/products/356
LCD 16x2 Char Display1$15.95https://www.sparkfun.com/products/709
3 pin polarized connector (Male & Female)4$0.50http://www.kr4.us/polarized-connectors-housing-3-pin.html
Optional: 16 Pins Round Hole DIP IC Chip Socket Adaptor1$5.16 (for 10)http://amzn.com/B00X77NYG0
Optional: PCB Board 16 Pin17.11 (for 20)http://amzn.com/B01173BKZW (I got mine for $2 at Radioshack)


Odds and Ends

  • Hook-up Wire
  • Paint & Primer (or wood stain)
  • Wood Glue
  • Small nails
  • Wire shrink wraps
  • Electrical Tape
  • Old IDE Cable for GPIO pins (http://amzn.com/B002BBNEOU)
  • Motherboard mounts (also listed above)
  • Screws #4 & #6 (also listed above)

Step 2: Building the Box

Materials Needed this Step: Red Oak, small nails, wood glue

Tools Needed this Step: Saw, Drill, Hammer, Files, Sander/Sandpaper, Dremel w/ routing bit

Measure and Cut:

  • Bottom - 5 1/2" x 6"
  • Sides (2) - 5 1/2" x 2 1/2" (With an angle of about 26.6°, for the face, marked 2" deep and 1" down)
  • Back - 5 1/2" x 2 1/2"
  • Top - 5 1/2" x 3 1/4"
  • Front - 5 1/2" x 1 1/2"
  • Cut 1/2" box joints on all sides of the bottom and the bottom edge for the sides, front and back. I recommend using a Dremel with a routing bit, the red oak is so thin at 1/4" that a regular router might be too much power, I had issues with mine and had better luck and control with the dremel.

Slots for Raspberry Pi ports:

  • Left Side - Cut a square on the left face of 2 1/4" x 1" for the raspberry pi ethernet and USB ports. If you have a router and files you can drill and cut out the square, or you can take the easy way and cut right from the edge to the depth you need.
  • Back - Cut a square 2 1/2" x 1/2" or drill individual holes for the power, HDMI, and Audio ports, just make sure the hole is large enough for the port and the width of the connector, for example my power cable while microusb is quite fat so the hole needed to be larger than just the microusb port.

Notes:

  • The Red Oak has a width of 5 1/2" so for all the pieces one dimension is already taken care of and it's only 1/4" thick so it's very easy to cut with a bandsaw or handsaw.
  • You'll notice in the images that my design originally had a lip on the angled face to align with the front piece, this was a design mistake and made the plexiglass for the front not sit properly so it was removed in the drawings.
  • Be sure to drill the pilot holes first before driving in nails or screws or it's very likely that the wood will split.
  • I also used a little wood glue to help hold it all together. Nail and glue the sides and bottom but leave the top unattached (we will mount it in a different way in the next step so it can be attached and reattached easily).
  • When creating my scrappy science caddy I originally had the sides and top all joined and the bottom detachable, this turns out to be a terrible idea because if you need to adjust wires or work on anything inside at all it's hard to get to it without removing the whole thing. So in the drawings/plans you'll see that the top and plexiglass are removable and the bottom is joined to the sides using a simple box joint.

Step 3: Mounts and Front Plate

Materials Needed this Step: Plexiglass, Motherboard mounts or standoff, screws, wood glue.
Tools Needed this Step: Saw, Drill/Drill Press, Dremel with cutting tip

Measure and Cut:

  • Plexiglass Front - 2 15/64" x 6"

For the front plate and top we want to be able to take them off and put them back on with ease (as we change out components, upgrade, or expand upon our box in the course of our science adventure). In order to do this easily I repurposed some motherboard mounts from an old computer.

Drill holes on the top and angled front edge, depending on the size of your motherboard mount or standoff used. I had to use two different hole sizes, first a narrower hole for the bottom screw of the standoff, then a slightly larger hole for the top standoff part, a little bit of wood glue holds it in place. Using a drill press made getting the correct depths quite easy

Drill holes in your Plexiglass for the analog components (I had 4 but the chip supports up to 8) connected with the 3 pin connector, the potentiometer and the 5 way navigation button. You want to measure and cut out a rectangle for the LCD.

Step 4: Wiring

Materials Needed this Step: IDE Cable, wire, Components (LCD, buttons, MCP3008, etc)

Tools Needed this Step: Solder Iron, shrink wrap, flux, glue gun.

In order to connect the LCD, MCP3008 A/D Chip, and all the various buttons to the Raspberry Pi I reused an old IDE cable, which if you pull apart just right, provides a perfect connection to the GPIO pins. This is the third or fourth time I’ve done this and have had success; but there’s also a couple pitfalls and issues to avoid.


Wire to the Notch, nothing more

In the images is a close up of one of the individual IDE pins removed from the header/connector, the red arrow marks a critical notch. This little bump is what “locks” the pin into the connector, so you don’t want to get solder past this point, otherwise the pin will not click/lock into the header and you can end up with a bad connection or a pin that likes to fall out of the connector.

Use Flux & Shrink Wrap

This goes with the previous statement, in order to solder effectively and get a good joint you’ll want to use solder flux, otherwise the “weld” to the pin could be pretty fragile. Also, the flux helps keep the solder from going past that critical bump. Finally, use shrink tubing to protect the joint and avoid contact with adjacent pins. When applying the tubing also make sure it doesn’t extend too far down and impede the pin from seating in the header/connector properly.

Avoid Bending unless Reinforced

The pins are not super durable so you want to avoid bending and flexing the pin or the joint, otherwise a break may occur and you won’t get a good (or any) connection. One way to do this is place some glue (from a hot glue gun) on the pins to hold them into the connector, apply enough to cover the entire pin, this will make it almost impossible to make changes on the connector, but it’ll make it sturdy enough so that any flexing happens in the attached wire rather than the pin and solder joint.

I used a PCB board from Radioshack and a 16 pin IC mount for the MCP3008 chip which made the wiring a lot easier.

Step 5: Sensors

Materials Needed this Step: Analog Sensors, Wire, 3 Pin Connector
Tools Needed this Step: Solder Iron, shrink wrap, flux, drill.

We're throwing science at the wall here to see what sticks so you can use whatever analog sensors you'd like, ideally they are 3 pin and use 5V.

The photos show some of the common sensors I use:

You'll need three wires for these types of analog sensors: red for 5V, black for Ground, and something else, such as green, for the data line. I like to keep the wires neat and twisted so, using a trick I learned in college, I made a little jig with alligator clips to hold and twist the wire using a handheld drill (see the photos).

Connect one end to the sensor and the other end to the 3 pin connector so it can be connected/disconnected easily.

Also be sure to wire up your sensors providing enough slack to get from the box to where your science is occurring!

Step 6: Software, Graphing, and Math, Oh My!

The box is driven by Python code available as a git repo https://github.com/kmkingsbury/raspberrypi-data-ac...

The collectdata.py python is the main workhorse and has various options.

The config.ini defines the GPIO pins used by the various components, if you follow the wiring in the Fritzing schematic then the values set in the config.ini are correct.

The wifi.py is a simple script I have launched on boot by the PI that just prints out the wifi IP address so I can SSH in to the Pi, an example of this is in the images.

For each run a data file and a metadata file is created by default this goes to /media/usb0 and will be written to a USB stick connected to the Pi (provided you setup usbmount). The data file has the datetime and the readings from the sensor. The metadata file contains the parameters used (how many channels, how often to sample, etc) as well as statistics about the data (max, min, avg, number of samples collected). Finally the metadata file also records the events from the top buttons. The top buttons as well as the 5-way navigation button do specific functions but you can modify them for any other functionality you want:

The 4 on the top are used to mark critical events during a data run, I use these for things like the start of a different event, marking state transformation (a fluid is now boiling), or even mistakes like bumping a sensor, having it come off the surface it is measuring, etc.

The 5-way Nav button on the front is used to manipulate the data being displayed on the LCD. By default the display shows the values coming out of each sensor, I then use:

  • an up push to switch the display to show the Maximum value for a sensor
  • down to display the Minimum value for a sensor
  • right to display the Average value for a sensor
  • left to display the Deviation of the current value from the Average value.
  • center push to return back to the regular default display.

The images show some examples of this.

Plots are made using the GNUPlot tool.

The github repo contains a sample-data-sets folder that contains two sample sets for reference and to help you get started with your own.

  • A Temperature reading from a 1000ml Flask as water is heated to a boil and then allowed to cool.
  • Readings for the 4 sensors when nothing is connected. When this occurs, the pin is in a "floating" state, and the output is not predictable. It is in an undefined state, that's neither 0 nor 1. In electronics this is known as the third state, an open circuit, or floating wire.

The plots for both samples are in the images.

Step 7: Final Thoughts

I was pretty happy with how my Scrappy Science Caddy turned out, and it's gotten a few practical uses so far but like any project, the moment it's done I was thinking of ways to improve on it, such as

  • Add a battery pack so it's not tied to the power cable.
  • Digital Sensors
  • A switch to change a particular sensor from 5V in to 3.3V in.

If you enjoy my instructables then please subscribe. Also, I like to post about projects as I work on them or learn new techniques and post more photos of the build process, if you like that sort of stuff then check out my facebook page https://www.facebook.com/spacemanlabs/

Thanks for reading!

Comments

author
Yonatan24 made it!(author)2016-04-04

Cool!

Do you have some kind of special lighting or something like that? Your pictures are amazing!

author
kkingsbury made it!(author)2016-04-05

Thanks, no nothing too special with the camera setup, just a Nikon D700 with a flash and white photography paper for the backdrop.

author
Yonatan24 made it!(author)2016-04-05

Oh, I see. I use the D3000, But I've heard that the smaller the number in "D" the better, But way more expensive

author
kkingsbury made it!(author)2016-04-05

The lens makes a huge difference, spend your money on quality lenses. I use a 60mm for most shots, allows me to get real close with the macro shots. This is the one I primarily use: Link: http://amzn.com/B0013A1XDY

author
Yonatan24 made it!(author)2016-04-05

My dad bought this camera several years ago, But I use it pretty much everyday.

I'd really love to have a good macro-lens for close-ups, But I don't have money for those.

I'd rather rather spend more money on projects, Than have an extremely amazing camera instead of an amazing one. My Nikon can still produce amazing pictures.

I think spending $20 more on good lighting will make a bigger difference than a $500 lens... :)

My all time favorite pictures are Bokeh, I'm addicted to taking them (I've attached below some that I think are really good)

All of my photography skills have been self taught, I'm just a 13 year old that loves making things :)

DSC_1771.JPGDSC_1408.JPGDSC_1831.JPG
author
ThomasK19 made it!(author)2016-04-03

Nicely done. As a tip: use plywood instead of raw planks since the latter tend to bend (as seen in step 2). Plywood is by far more stable.

author
kkingsbury made it!(author)2016-04-03

Nice, thanks for the tip!

author
DIY+Hacks+and+How+Tos made it!(author)2016-04-02

I love DIY lab equipment