ABS Pi Case with OLED & camera


10 posts
by JPB-HK » Tue Aug 13, 2013 5:15 am
As all of us have been looking for a way to package our products, I came up with a case that I could modify at home. Being a hobbyist, I wanted something I could carry around, would have room for the special electronics I needed, and be sturdy.
So I used the case from Multicomp, MCRH3165, which is 165mm(D) x 100mm(W) x 32mm(H). The nice thing about this case is that it fits the Pi quite nicely across the width. If you turn the Pi sideways, the USB / Ethernet ports are exposed on the one side, with the SD card on the right. It does not allow for access to the RCA Video or audio. But I will add an extension for the audio to a chassis mount connector. I also did not expose the power, but instead use the GPIO port 5V pins to power the board. Here is the HK website for the box at Element 14.

http://hk.element14.com/multicomp/mcrh3165/box-abs-165x100x32mm/dp/1520395

Besides having the Raspberry Pi, I have included the following into the project:
- Switching power supply based on the LM2576 5.0V
- Dallas Maxim Low-cost i2c battery monitor DS2745. Monitors the voltage, current across a sense resistor, and the temperature of the chip.
- OLED from Adafruit. Monochrome 1.3" 128x64 OLED graphic display using in i2c mode.
- Raspberry Pi camera
Inside.jpg
Inside.jpg (47.54 KiB) Viewed 4478 times
Left Ethernet USB.jpg
Left Ethernet USB.jpg (38.23 KiB) Viewed 4478 times
Top OLED on B.jpg
Top OLED on B.jpg (33.71 KiB) Viewed 4478 times

I am going to add a power push button to turn on / off the Pi in a controlled manner. Still working on the exact electronics. Also will change the power LED to be displaying pin 8 (GPIO14 RS232 Tx) instead of just power (via a transistor). This way it will show when the box is really powered up / down. Now the LED is connected to the 5V, and I just display a message on the screen when powering up and down.
I originally had mounted the camera in front with 4 small screws, but it did not mount well, so I just changed to gluing it in. It's ok, but still worried about compressing the flat ribbon when enclosed. Still need to think on that one.

The nice thing about this case is that you can get to 3 of the 4 sides of the Pi. Just have to cut some plastic away to expose the USB, Ethernet, HDMI, and SD card. I have broken 2 of my SD card holders, so I replaced with some push-in push-out ones. The HDMI is a little difficult to insert as it sits a few cm back from the back case. The Pi is pushed all the way against the posts used for screwing the top half of the case to the bottom half.

To cut the holes in the sides, I just used diagonal cutters, and either cut through the upper or lower part of the case, each side, and then just moved the piece back and forth until it came off. Not the best way, but easy. And then cleaned it up with a file. So you will notice in the pictures that basically I either cut a hole in 1/2 the side of the case, or the whole side.

To cut the hole for the LED I marked off an area for the OLED, you can see this in the inside picture. Then just drilled a bunch of holes, cut between the holes with diagonal cutters, and then filed the rest. That took the longest.

I power the whole project by an external 12V 2A adaptor, which seems to be enough to support all the items plugged in, such as keyboard, mouse, external hub, Bluetooth, Wifi.

A lot of fun, and I think I am going to build another one.

John
"Trust me, I know what I'm doing!"-SH
Posts: 46
Joined: Thu Nov 22, 2012 5:00 pm
by JPB-HK » Mon Aug 19, 2013 1:07 am
I have added a N/O push-button on the back of the case that is a sleep / wakeup button. It is connected via 2N4401s to GPIO3 PIN 5, and GPIO17 Pin 11. GPIO3 is used to wake the Raspberry Pi from sleep with a momentary transition from high to low. GPIO17 is monitored during operation for a transistion from high to low to signal a shutdown -h now. Seems to work well
I also moved the power LED to GPIO14 pin 8 (via 2N4401), as this is high during operation, but low when in sleep mode.
Back HDMI Power SW.jpg
Back HDMI Power SW.jpg (27.63 KiB) Viewed 4210 times
John
"Trust me, I know what I'm doing!"-SH
Posts: 46
Joined: Thu Nov 22, 2012 5:00 pm
by JPB-HK » Wed Aug 21, 2013 5:37 am
Update: I have attached the schematic of the interface between the GPIO, button and LED. Simple circuit.
130819 PB Circuit.jpg
130819 PB Circuit.jpg (26.39 KiB) Viewed 4067 times
Here is the code for monitoring the gpio pin. Just borrowed this from some other folks online. I created a file named switchmon, and put this in the ~ directory.
Code: Select all
#! /bin/bash
SHUTDOWN_PIN="0"
gpio export "$SHUTDOWN_PIN" in
gpio mode "$SHUTDOWN_PIN" up
while ( true )
do
    PIN_RESULTS=$(gpio read $SHUTDOWN_PIN)
    if [ $PIN_RESULTS -eq 0 ]
    then
        shutdown -h now "System halted by GPIO"
    fi
    sleep 0.5
done
Not sure if this is the best way, but added to /etc/rc.local and add this before exit 0:
Code: Select all
sudo bash /home/pi/switchmon&
This uses Gordon's gpio function, and it took me awhile to figure out how to take the results of the gpio read into a variable I could compare. Anyway, seems to work good.
Just plug in the power the first time, the Raspberry Pi powers up normally. then when wanting it to go to sleep, press the button for a little longer than 1/2 second, and the Raspberry Pi goes to sleep. after it has completely went to sleep, press the button, and it wakes up.

John
"Trust me, I know what I'm doing!"-SH
Posts: 46
Joined: Thu Nov 22, 2012 5:00 pm
by thegnnu » Mon Sep 09, 2013 8:52 pm
Hi I was looking for cases that held the PI and camera as well and came across your article on the forum
I then spotted your schematic for the the push button for off and on approach which I would like to incorporate into a portable camera system. Looking at the code it only shows press to close down to halt and no start up option. is this correct or should it be a different set of code.
I have a press to halt only working at the moment.

Terry Rowe
Posts: 25
Joined: Thu Oct 18, 2012 7:07 pm
Location: Bristol
by JPB-HK » Tue Sep 10, 2013 12:28 am
Terry:

Good question. In December last year, I ran across this little bit of wisdom in the forum:

http://www.raspberrypi.org/phpBB3/viewtopic.php?p=227308#p227308

Stored this away for future use. When I started this project, I remembered this, and incorporated it in my project.
So simply put, the code to run this for power-up is already embedded in the Raspberry Pi. So no need for any extra code. SDA1 and SCL1 (Pins 3 & 5 of GPIO) already have pull-up resistors attached, so they will always maintain the ports at a logic 1 even in sleep mode. When either pin is brought low, 0, for a moment, the Raspberry Pi will re-start. It is nice to see such niceties incorporated into the Raspberry Pi.

Hope this helps.
John
"Trust me, I know what I'm doing!"-SH
Posts: 46
Joined: Thu Nov 22, 2012 5:00 pm
by thegnnu » Tue Sep 10, 2013 12:33 pm
John Thank you for the reply I now under stand how it works and I am going to try something out which will leave out the transistors and 4 resistors. Will let you know if it works. As I allready using pin 11 for the halt should be a easy convert.

Terry thegnnu
Posts: 25
Joined: Thu Oct 18, 2012 7:07 pm
Location: Bristol
by JPB-HK » Wed Sep 11, 2013 12:35 am
Terry:

You could possibly use diodes instead of the transistor circuit. It is just important not to have the two GPIO pins connected, as they would interfere with each other.

I used transistors because I was originally going to use 5V to the switch instead of 3.3V. That would give me a level of isolation from the 5V to the GPIO pins. There was concern also about the voltage drop across the diodes, and would that be enough to represent a '0' to the GPIO pins.

And most important of all, I had the transistors / resistors, but no diodes.

John
"Trust me, I know what I'm doing!"-SH
Posts: 46
Joined: Thu Nov 22, 2012 5:00 pm
by JPB-HK » Tue Oct 08, 2013 1:21 am
** Update **
I added a 12 key keypad to the project. Actually I built another one, as I did a poor job in planning the first one. There was no room to add the keypad. With the new one, it is very similar to the original, except these changes:
1) I did not add the volt / amp / temp chip
2) Added the keypad
3) Used a board with a 26 pin connector to add parts directly to Raspberry Pi
4) No camera installed.
Top OLED keypad.jpg
Top OLED keypad.jpg (28.99 KiB) Viewed 2934 times

I used the Wicker25 Rpi-hw library to communicate with the keypad, and it seems to work pretty well.
https://github.com/Wicker25/Rpi-hw/wiki/Download%20and%20install

There are great instructions on installation / build / examples in using this library. I have integrated this into one project, and working on trying to have a good interface for this.

John
"Trust me, I know what I'm doing!"-SH
Posts: 46
Joined: Thu Nov 22, 2012 5:00 pm
by JPB-HK » Tue Oct 08, 2013 5:15 am
I have also been working on the Raspberry Pi to automatically display the IP address when it boots up. This has been a real challenge to have it reliably and consistently do this. And to do it for either cable or wifi.
I am new to BASH programming, so this has been an exicting experiment. so far here is what I have working:
Code: Select all
#!/bin/bash
# Read then write IP Address
#  Erase file if already exists
#

FILE="/home/pi/ipaddr.txt"

if [ -e "$FILE" ]; then
  sudo rm "$FILE"
fi

for count in {1..20}
do
  sudo hostname -I > "$FILE"

  if [ -s "$FILE" ]; then
    SIZE=$( stat -c %s "$FILE" )
    if (( "$SIZE" > "6" )); then
       sudo /home/pi/source/oled/bin/Release/oled -q
       exit 0
    else
      sudo rm "$FILE"
    fi
  fi
  sudo /home/pi/source/oled/bin/Release/oled " " "$count"
  sleep 0.5
done
exit 1
I run this from /etc/rc.local:
Code: Select all
sudo bash /home/pi/ipaddr&
I added the run in background '&' so it will display the IP address on my oled display even if not logged in. oled is a cmd line program for the 128x64 oled display.

John
"Trust me, I know what I'm doing!"-SH
Posts: 46
Joined: Thu Nov 22, 2012 5:00 pm
by itsisme » Sun Jun 29, 2014 3:59 pm
Hello John,

In your post you mention :

sudo /home/pi/source/oled/bin/Release/oled " " "$count"

I am looking for a tool to display text on my OLED display 128x64 or to be used in a bash script and it looks like this one might be usable. Could you share your code ?

Rgds ...
Posts: 17
Joined: Sat Mar 09, 2013 2:16 am