Things used in this project
|Hand tools and fabrication machines:|
This project is 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:
So, who is ready to make some science?
SketchUp was used to plan/design the box. The drawings are in git at SketchUp Drawing, and a screenshot is in the images.
The wiring schematic was done in Fritzing and is available at Wiring Schematic, and a screenshot is also in the images.
Bill of Materials (also at Github BOM ):
Item Count Price Url / 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.47
Plexiglass sheet 1 $2.97
Motherboard mounts 8 $7.90 (for 50)
Round-Head Standard (SAE) Machine Screws #4 & #6 size ~16 $1.24 for 12
Nylon Standoffs 8 ~$2.00 Local Big Box Store
Item Count Price Url / Source Raspberry Pi 2 or 3 1 $37.99 or $45.97
MCP3008 1 $3.75
Push Buttons (green, black, red, blue) 4 $6.98 (for 10 in one color)
5 way navigation button 1 $2.95
Potentiometer 1 $1.25
LCD 16x2 Char Display 1 $15.95
3 pin polarized connector (Male & Female) 4 $0.50
Optional: 16 Pins Round Hole DIP IC Chip Socket Adaptor 1 $5.16 (for 10)
Optional: PCB Board 16 Pin 1 7.11 (for 20)
(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)
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.
- 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.
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 re-purposed 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.
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.
Materials Needed this Step: Analog Sensors, Wire, 3 Pin ConnectorTools 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:
- a temperature sensor The TMP36 https://www.sparkfun.com/products/10988)
- a soil moisture sensor (https://www.sparkfun.com/products/13322)
- a humidity sensor (HIH4030 https://www.sparkfun.com/products/9569)
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!
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.
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.
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!
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!