Introduction: Clickity-Clank Your Smart Piggy Bank *updated*
I'm very proud to announce that the project has been selected to be illustrated on the book:
"clickity-clank, the money goes into my piggy bank." (50 Cent)
Clickity-Clank is a smart piggy bank made, as usually, with Raspberry Pi, GrovePi and reused things.
Have you to finance your project, travel or other ? With Clickty-Clank you can set your money target and numbers of days needed and it'll inform you once your goal has been reached. Every time you or someone else insert a coin into Clickity-Clank, you'll be informed by email message with a finance statistic graph.
This version support only one kind of coins (1 euro or 1 dollar or etc)
For the enclosure i've used Lego Duplo blocks and the mechanism is provided by a DVD Player part.
All these are assembled together a Raspberry Pi, GrovePi+, GrovePi sensors and few things.
Watch video on YouTube:
*** UPDATED 2016 ***
due to sendEmail support ending, install SSMTP as described below.
Step 1: What You Need
- Raspberry Pi mod.B+
- WIFI dongle
- PS 5V
- PS 3V
- GrovePi LCD RGB
- Grove button
- Grove Led Red
- Grove Led Green
- Grove rotary sensor
- Grove buzzer
- n.2 generic relay NC/NO - 5V PIC ARM AVR DSP
- n.1 1kohm resistor
- n.1 10 kohm resistor
- some jumpers
- DVD player len mechanism
- Lego Duplo blocks and base (Zoo)
- small screws for relay and Grove sensor
- medium screw with washer for DVD len mechanism
Step 2: The Enclosure
The casing is divided in two sections containing:
- Raspberry, GrovePi+, leds, buzzer, rotary sensor and two relay
- coin storage, DVD player carriage, GrovePi LCD RGB, GrovePi button
Build the front side with two empty spaces for LCD and button. Mould and drill blocks so the display fits without glue. Button is screwed on the upside of a block that was previously shaped.
Raspberry Pi has been screwed to a blocks column.
On the top platform create a slot corresponding to laser len when it is on the position n.1(see next step).
Drill the front side of section one where you have to insert two leds and rotary sensor.
Put DVD len mechanism on the upside of the coin storage (section 2) screwing it on the blocks.
Buzzer has been placed on the top side covered by blocks.
Rear side must be opened and closed to collect coins once you have reached your goal.
Step 3: GrovePi+ Connections
You can easly connect Grove accessories as following explained:
Grove Button to D3
Grove Buzzer to D8
Grove Rotary sensor to A1
Grove Red Led to D5
Grove Green Led to D6
Grove LCD RGB Backlight to I2C1
Note that i'm using Raspberry GPIO extensions on GrovePi+ board.
Step 4: DVD Player Len Mechanism Hacking
Coin slot is controlled by a DVD player laser len mechanism. It works like this:
position 1: when inserting the coin in the slot, it will be blocked by laser len pcb. When you give power to DVD motor with correct polarity, carriage will move to position 2 so the slot is free and the coin fall into storage area. A small pin button inside carriage mechanism check the finish line. Then, inverting polarity to the motor, laser len mechanism will go back to position n.1 . Schematically we have a motor controlled by relay and a button.
There are two motors inside mechanism, one for dvd turning and one for the carriage moving. Identify connection for the second one. Test it with a 9V battery, check and remember polarity. Now weld two cables that will be connected to relays.
Identify on pcb two connections for pin button. Now weld two resistors to one pin button connection, then weld a jumper to the other connection. Afther that you'll have a pin button with three outputs. Jumpers will be connect directly to Raspberry 3.3V pin. 1Kohm restistor output will be connected to GPIO 17 and 10Kohm resistor output to Raspberry GND pin.
Step 5: Inverting Polarity to Len Mechanism
To make this i've used n.2 two channels relays. As you can see on photo, normally close position for both must be connect to PS positive output. Normally open position to PS negative output. Then you can see that, without signal fm Raspberry, both relays are NC. If you alternate signal to relays, you'll have inversion of polarity on laser machanism motor.
connect relays to Raspberry as follow:
Relay A - sig>GPIO 22 , vcc>3.3V, gnd>GND
Relay B - sig>GPIO 27, vcc>3.3V, gnd>GND
To drive dvd motor i'm using 3V PS. You can use 5V PS too.
Step 6: Coding
For first all you need to insall two programs: sendEmail and Gnuplot
Download sendEmail tar file:
$ wget <a href="http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz" rel="nofollow"> <a> <a> <a> <a href="http://caspian.dotconf.net/menu/Software/SendEmai...</a"> http://caspian.dotconf.net/menu/Software/SendEmai...</a>>>>>
$ tar -zxvf sendEmail-v1.56.tar.gz
copy to correct path:
$ sudo cp -a sendEmail-v1.56/sendEmail /usr/local/bin
make it executable
$ chmod +x /usr/local/bin/sendEmail
Install TLS support for Gmail
$ sudo apt-get install libnet-ssleay-perl libio-socket-ssl-perl
after installing, change it as follow:
$ sudo nano /usr/share/perl5/IO/Socket/SSL.pm
with CTRL-W find the line with this argument:
and change it to:
save and exit
try to send an email with the command line:
$ sendEmail -f YOUREMAIL@gmail.com -t YOUREMAIL@gmail.com -u "OBJECT" -m "MESSAGE TEXT" -xu YOUREMAIL@gmail.com -xp YOURPASSWORD -o tls=yes -s smtp.gmail.com:587
$ sudo apt-get update $ sudo apt-get install ssmtp $ sudo apt-get install mailutils
$ sudo nano /etc/ssmtp/ssmtp.conf
add and modify extistings lines
AuthUser=YOUREMAIL1@gmail.com # you can use one of two accounts created to send email
Save and exit
$ sudo apt-get install mpack
into your home directory write:
$ sudo apt-get install gnuplot-x11
Clickity.py and Plot.sh scripts
copy in your home/pi directory two scripts attached.
Probably you'll have to set correct time needed when DVD player len go from position 2 to position 1. This depend by voltage that you give to len motor. Change line 178 setting different time if movement to position 1 is not correct (for the one i've made, time needed fm position 2 to position 1 is 0.2 sec.)
At the line 216, insert your Gmail address
Make all files executable with
sudo chmod +x "see following list"
this is files list that will be created at the first run of the script:
to run script as daemon, make this:
$ sudo crontab -e
at the end add:
@reboot sudo python /home/pi/clickity.py
This project is based on Raspberry Pi platform with Dexter Ind.
modified "wheezy" image Linux raspberrypi 3.18.7+ #755 and GrovePi+ sensors.
please note that, starting the script, there is an error message regarding Grove Lcd library, you have to move the script clinckity,py inside /home/pi/GrovePi/Python/grove_rgb_lcd folder. Conseguently change clickity.py path inside crontab.
Step 7: Final Considerations
If everything has been setted right, you can launch script with:
$ sudo python clickity.py
or, rebooting, it'll start automatically.
The first time you have to select days and target then script create data files.
When you have selected your target, confirm all turning knob in fully anti-clockwise position and leave it in this position until you have to set new parameters.
Display shows at first line:
Target : your coin target
D/L:days left to reach target
Cash: number of coins stored
As explained with first image of previous step, there are two ways to reset dates if something goes wrong.
- after selected you coin target you can choose yes to confirm, no to repeat dates entering
- pushing the button and turning knob in fully clockwise position until len mechanism stop moving
I hope you enjoyed it.