SmartKegerator v2 Installation Guide

This project has been heavily modified to take advantage of the raspberry pi 2’s additional horsepower. If you are looking for the raspberry pi v1 code, look around version 62 in the repository. Version 70 and on are unlikely to work on the original pi, although I have not tried.

[Updated 10/4/2016: These instructions have been updated and now work with a clean raspbianPIXEL image]

Installation:

Install a new copy of raspbian onto an sd card.

On your first boot, configure these:
Expand Filesystem
Boot to Desktop
Enable Camera
Configure keyboard (if not in UK) and timezone
Finish > Reboot

1) Update raspbian

sudo apt-get update
sudo apt-get upgrade
sudo rpi-update

2) Install requisites

sudo apt-get install qtcreator cmake libopencv-dev mplayer subversion qt4-dev-tools libqt4-dev libqt4-dev-bin qt4-qmake

3) Configure QtCreator

Launch QtCreator from start menu > Programming > QT Creator

Once in QT Creator:
Tools > Options > Build & Run > Qt Versions > Add > navigate to or paste: /usr/bin/qmake-qt4
Tools > Options > Build & Run > Compilers > Add > pick GCC
Then set compiler path : /usr/bin/arm-linux-gnueabihf-gcc-4.9
Click OK

Qt Creator seems to think that we are going to deploy on a remote target, to fix this :
Help > About Plugins
Uncheck Device Support > Remote Linux
Click Close and reopen Qt Creator

Tools > Options > Build & Run > Kits > Desktop-Qt4 4.8.6 (qt4)
Compiler: GCC
Debugger : /usr/bin/gdb

4) Compile facial recognition libraries

cd ~
git clone https://github.com/bytefish/libfacerec
cd libfacerec
sudo cmake .
sudo make

5) Compile QWT

cd ~
mkdir qwt
cd qwt
svn co svn://svn.code.sf.net/p/qwt/code/branches/qwt-6.1 ./
qmake qwt.pro
sudo make
sudo make install
cd lib/
sudo cp * /usr/lib/

6) Compile WiringPi

cd ~
git clone git://git.drogon.net/wiringPi
cd wiringPi/
./build

7) Get SmartKegerator source

cd ~
mkdir qt
cd qt/
mkdir SmartKegerator
cd SmartKegerator/
svn co https://subversion.assembla.com/svn/smartkegerator/trunk ./

8) Edit config files

sudo nano ~/qt/SmartKegerator/config.txt

Make sure all of the paths are correct for your system. If you’re using a fresh copy of raspbian and followed each step here, you shouldn’t need to edit anything.

9) Run it!

Open QTCreator and File > Open Project > /home/pi/qt/SmartKegerator/SmartKegerator.pro

Click Yes when it asks about environment settings.

Click the green arrow on the bottom-left to start building. The first build will take a while. If everything worked you should see the application open! If you get errors, try google or come back here and post a comment.

9) Disable the screen saver

sudo nano /etc/lightdm/lightdm.conf

scroll down until you see

[SeatDefaults]
#xserver-command=X

Remove the starting ‘#’ from ‘#xserver-command=X” and add ” -s 0 -dpms” to the end so you have:

[SeatDefaults]
xserver-command=X -s 0 -dpms

ctrl-x, y, enter to save

To use the Mimo-720S

See this post about configuring the touchscreen and kernel

Slic3r to Davnici XYZWare conversion

Converting gcode files generated with slic3r to work with the davinci printer’s native software XYZWare was a little tedious, so I wrote a simple C# app to automate the process. For this app to work you must be using a modified slic3r ini file

Just drag your gcode file onto the app and it will pop out a file of the same name but with a .3w extension, overwriting any conflict.

C# Source code is here if you’d like to compile it yourself as a new console app. You shouldn’t need to make any modifications, but you’re also welcome to.

EXE download for those who can’t compile themselves.

Hope this helps someone!

BMW F3x/F8x Escort radar detector hardwire with OEM mute button and HUD notification

I wanted to hardwire my radar detector, but I wanted a mute button and alert led, something improved upon my last idea.

I decided to use one of the disabled buttons on the BMW F3x/F8x’s headlight module for the mute button. I create my own button contacts using copper tape to put over the top of the original module’s contacts. I also 3D printed an alert symbol that flashes in my HUD, but this is only noticeable at night, currently.

I’ve included links to the materials I used, but there are many cheaper alternatives if you shop around!

Stuff needed:
Radar detector
Hardwire kit (Amazon – $26 or make your own)
soldering equipment
small drill bit + drill

for mute button:
kapton tape (Amazon – $9)
copper tape (Amazon – $6)
2-pin connector + wire (Amazon 10pack – $6)

for hud notification:
HUD notification housing (Thingiverse)
Notication led (any 5mm led, here’s what I used)
Small piece of paper
2-pin connector + wire (Amazon 10pack – $6)

Instructions:

Hardwire kit modifications: (only if you’re doing a mute button or remote led)
Remove the existing led and mutton button from the circuit board. Use a small drill bit to drill new holes for each lead, and connect a wire and connector to each spot.

I also found that when using the red led hardwire kit, I had to add a resistor once I removed the signal led. The blue led hardwire kit already had this resistor oddly enough.

Remote notification symbol:

1) Print the housing. I used 0.3mm thickness and 20% infill.

2) Place the led of choice into the back plate, bend the leads appropriately to fit, and solder a thin wire onto the leads.

3) Cut a small piece of paper to fit inside the housing, covering the whole left by the alert symbol, This will help diffuse the light, as well as hold the symbol in place.

4) Using some glue (I used 3 dots of superglue) place the symbol on the paper, using tweezers to perfectly align the symbol with even borders all around.

Hud Symbol

5) Snap the cover onto the back plate and use some sticky back tape to affix to the hud. You’ll need to do some testing to position it right.

Mute button instructions:

1) Follow this guide to remove the tabs blocking the OEM button from depressing:
http://f30.bimmerpost.com/forums/showthread.php?t=877278
(Pro-tip, when removing the module, press down on the top of the clips from inside, until it’s about 3/4″ out. Then you should just barely be able to see the clip from the outside. Push down from the outside on the part of the clip you can see and it will come out nice and easy)

2) Next, we’ll make our own button contacts so the radar detector can tell you’ve pushed the button. Start by removing the black silicone/rubber. (Watch out for the clear grease over the radial contacts in the center of the board. Try not to touch it!):

3) Lay kapton tape over the existing contacts. I chose the top button, and to put a contact on both sides, but really one side should be fine.

4) Lay 2 strips of copper tape per contact, using the existing contact as a guide. You want the two strips really close so they’ll join when the button depresses, but not touching!

5) Solder your wire onto the copper strips. If you do both sides, make sure it’s wired so that either side closing would complete the circuit

6) Push the silicone back over our solder job. I found using some jumper wire worked well if I wiggled and rotated it while gently pushing inside each of the 4 nubs as seen below

Hardwire:
1) Take down the panels from the driver and passenger sides by removing the 4 bolts on each side and gently tugging down.
2) Find the cigarette lighter plug on the passenger side and install the taps.

3) I used some heavy gauge wire to feed the power and ground wires from the drivers side to the passenger side through the spot the arrow is pointing at, with the cigarette lighter plug circled.

4) On the driver’s side, run the hardwire module up behind the headlight mode switch (that you modified if you did the mute button) like so (terrible drawing, I know):

5) Pop out the panel on the left of the dash, and pull down the rubber door seal from the frame.
6) Run the cable through the open panel and up to the spot where you mount your detector. Start with the plug where it should be and start tucking the cable into the trim as you go, working back down the a-pillar. To be even safer, you can run the cable behind the airbag by removing the trim pieces altogether.
7) Reinstall the rubber trim, panel on the left of the dash, connect your optional mute button and/or remote led, put the vent back in and you’re done!

Drive safe!

Pi-o-lantern

Recently browsing hack-a-day I came across Michal Janyst’s project where he used an arduino with some cheap (~$3) led matrix displays to animate eyeballs on a jack-o-lantern.

I really liked the idea and decided I wanted to try and drive the pupils using motion detection from the raspberry pi camera module! Unfortunately I only had a day to work on it, and I’ve never done motion detection before, so the learning began!

Today is Halloween and the effective deadline for the project, and while I’m not happy with the framerate I’m getting in python, I’m quite happy with what I was able to do!

I want to move the python to c++ for next year, which should triple the framerate or so.

Items used:

Cheap plastic pumpkin – Target – $3

2x MAX7219 LED matrix boards – eBay – $2.18
(I actually ordered mine from Amazon – $6.58 to make use of prime shipping)

Longer pi camera cable – Ebay $9-$27

Raspberry pi + camera

Source:

https://github.com/philharlow/Pi-o-lantern

Setup:

Coming soon!

Smart Kegerator

Discovery Channel Canada’s “Daily Planet” segment: https://www.youtube.com/watch?v=ENPVkKDqYiE (very similar to the walkthrough above)

Update 7/31/2015:

New installation guide has been posted here:
https://philsprojects.wordpress.com/2015/07/31/smartkegerator-v2-installation-guide/

 

The purpose of this project was to allow my roommates and friends to be able to drink as much beer from the kegerator as they’d like, without guesstimating who owes what when it comes time to refill the kegs. The system uses two flow meters in the beer lines to detect when beer is poured, and once a pour has started, the raspi camera module turns on to run facial recognition (disabled when I shot this video) and charge the appropriate user for their beer. I wanted the system to be as passive as possible, requiring zero human interaction (no RFID cards, no selecting the user every time) but to record all pours and how much was poured. So far the system is running great, minus that accidental spill because my tap handles are too close together🙂

Eventually I’d like to use weight sensors under each keg to get a better estimation of keg volume, and use a liquid probe thermometer to better estimate the temperature of the beer instead of the air. I’m also moving to a NOIR pi camera module after finding it had much better low light performance, and I’ll probably add some IR lamps to help illuminate the face for recognition when the lights are off. I also need to mount the camera a bit better, ideally higher and a littler further behind the tower, but the flex arm tripod worked great for this first implementation.

I’m also working on a new UI that will probably look something like this:

Mock up UI v2

Mock up UI v2

The source is currently avilable at https://www.assembla.com/code/smartkegerator/subversion/nodes/ but it’s certainly not finished or polished.

The UI is written in QT and C++, using python scripts for the gpio flow interrupts (the c++ interrupts seemed unreliable,but python’s implementation worked perfectly) and the C loldht script found on these forums to read the temp from the temp/humidity sensor.

I’ve made a quick and dirty fritzing image to illustrate the connections, but I’m not very good with frizing so I’ve included text as well.
KegeratorSchematic
On each flow meter, I connected the red to the pi’s 3.3v, black to ground, and the yellow pin to GPIO #23 and GPIO #24 for left and right sides respectively.
The temperature sensor, looking at the front of it (the side with the holes) the pins go left to right 1-4. Pin 1 to GPIO #17, so that I can turn it on/off by writing power out on pin 17. Pin 2 to GPIO #4. Pin 3 to ground. And lastly put a 4.7k ohm resistor between pins 1 and 2.

Parts:
Rasperry pi
http://www.amazon.com/RASPBERRY-MODEL-756-8308-Raspberry-Pi/dp/B009SQQF9C/ref=sr_1_1?ie=UTF8&qid=1394450356&sr=8-1&keywords=raspberry+pi

Mimo 720S display
http://www.amazon.com/Powered-Slide-out-Touch-Screen-Monitor/dp/B002QFP4Z8/ref=sr_1_1?ie=UTF8&qid=1394450430&sr=8-1&keywords=mimo+720s

Powered USB Hub
http://www.amazon.com/gp/product/B005A0B3FG/ref=oh_details_o05_s01_i00?ie=UTF8&psc=1

DHT22 temp/humidity sensor
https://www.adafruit.com/products/385

Flow meters
http://www.adafruit.com/products/828

Pi Camera module (NOIR seems ideal for low light)
http://www.amazon.com/Raspberry-Pi-Camera-Filter-Vision/dp/B00G76YEU8/ref=sr_1_1?ie=UTF8&qid=1394450401&sr=8-1&keywords=raspberry+pi+noir

100cm SPI cable (raspi camera cable)
http://www.ebay.com/itm/141129552486?var=440222309796&ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

Camera housing
http://www.amazon.com/gp/product/B00E1UOXMQ/ref=oh_details_o06_s00_i00?ie=UTF8&psc=1

Wide-angle lens
http://www.amazon.com/gp/product/B009NED5E2/ref=oh_details_o00_s00_i00?ie=UTF8&psc=1

Techflex cable sleeve(I think it makes the raspi camera cable better looking)
http://www.amazon.com/gp/product/B007VT6HSC/ref=oh_details_o02_s00_i00?ie=UTF8&psc=1

For the gpio breakout:
10 pin ribbon cable
http://www.ebay.com/itm/281152427395?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

10 pin connectors
http://www.ebay.com/itm/171047381713?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

protoboard from radioshack
http://www.radioshack.com/product/index.jsp?productId=2104052

References:
Mimo 720S solution – http://www.raspberrypi.org/phpBB3/viewtopic.php?t=27781
Raspberry pi camera to opencv/facial recognition – http://thinkrpi.wordpress.com/opencv-and-pi-camera-board/

More info coming soon!

Pandora controlling Google chrome plugin

I recently moved away from the OCR method of reading data from pandora, and moved to a google chrome plugin. This has the downside of requiring chrome to be running, but it allows infinitely more control.

I’ll do a better writeup soon, but following files make up the plugin:

manifest.json
http://snipt.org/MaPj4

background.js
http://snipt.org/MaQf9

pandoraController.js
http://snipt.org/MaOc8

Mimo 720-S on the Raspberry Pi

1) Drop the USB speed to v1.1 speeds (necessary for this touchscreen to work unfortunately, although online people have reported theirs working without this step recently)

sudo nano /boot/cmdline.txt

Modify from:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

To: (changes in bold)

dwc_otg.lpm_enable=0 dwc_otg.speed=1 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

ctrl-x, y, enter to save.

2) Disable the screen saver

sudo nano /etc/lightdm/lightdm.conf

scroll down until you see

[SeatDefaults]
#xserver-command=X

Remove the starting ‘#’ from ‘#xserver-command=X” and add ” -s 0 -dpms” to the end so you have “xserver-command=X -s 0 -dpms” on that line.

ctrl-x, y, enter to save.

3) Create kernel with Displaylink/touchscreen support

Update first:
sudo apt-get update
sudo apt-get upgrade

Install requisites:
sudo apt-get install bc libncurses5-dev

cd ~
mkdir raspbian
cd raspbian
sudo git clone https://github.com/raspberrypi/linux –depth=1
sudo git clone https://github.com/raspberrypi/tools –depth=1
cd linux/
sudo make bcm2709_defcong (bcmrpi_defconfig for rpi v1)
sudo make menuconfig

Navigate to:
Device Drivers>Input Device Support>Touchscreens>USB Touchscreen Driver (hit Y to include. You may need to hit space while on Touchscreens to include the feature and it’s subcomponents – Thanks Richard!)
Hit esc until you’re back at Device Drivers.
Device Drivers>Graphics Support>Frame Buffer Devices>Displaylink USB Framebuffer support (hit Y to include)
Hit esc until prompted to save and select Yes.

Start kernel build:

sudo make -j 6 (takes a looong time)
sudo make -j 6 modules
sudo make modules_install
sudo cp /boot/kernel7.img /boot/kernel7-orig.img
sudo cp arch/arm/boot/Image /boot/kernel7.img
sudo reboot

Now you can run dmesg to make sure the touchscreen shows up properly.

4) Configure X11 to use the new display

sudo nano /etc/X11/xorg.conf

Right click and paste the following in and save:

Section "Device"
Identifier "uga"
driver "fbdev"
Option "fbdev" "/dev/fb1"
Option "ShadowFB" "off"
EndSection

Section “Monitor”
Identifier “monitor”
EndSection

Section “Screen”
Identifier “screen”
Device “uga”
Monitor “monitor”
EndSection

Section “ServerLayout”
Identifier “default”
Screen 0 “screen” 0 0
InputDevice “touchscreen” “CorePointer”
Option “Xinerama” “Off”
EndSection

Section “InputDevice”
Identifier “touchscreen”
Driver “evdev”
Option “Device” “/dev/input/by-id/usb-e2i_Technology__Inc._USB_Touchpanel_L000000000-event-if00”
Option “DeviceName” “touchscreen”
Option “ReportingMode” “Raw”
Option “SendCoreEvents” “On”
Option “Calibrate” “1”
Option “Calibration” “630 32000 1100 31800”
Option “InvertY” “true”
Option “InvertX” “true”
Option “SwapAxes” “false”
EndSection

5) Configure the xorg.conf file with your particular settings

If you’re lucky your display will be named the same as mine and you wont need to make any change. Type:

ls /dev/input/by-id/

and look through the output for the one that is your touchscreen. Now copy that long name and type

sudo nano /etc/X11/xorg.conf

and replace ‘usb-e2i_Technology__Inc._USB_Touchpanel_L000000000-event-if00’ with your display name.

6) Calibrate the screen (if my calibration settings didn’t work for you)

sudo apt-get install evtest
sudo evtest /dev/input/usb-e2i_Technology__Inc._USB_Touchpanel_L000000000-event-if00

again replacing ‘usb-e2i_Technology__Inc._USB_Touchpanel_L000000000-event-if00’ with your display name. Now follow Dane’s post to get the calibration values, and use

sudo nano /etc/X11/xorg.conf

to change the values.

Now if you reboot you should boot up on your mimo display with a working touchscreen!

Enjoy!