Introduction: Clickity-Clank Your Smart Piggy Bank *updated*

"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

Hardware:

  1. Raspberry Pi mod.B+
  2. GrovePi+
  3. WIFI dongle
  4. PS 5V
  5. PS 3V
  6. GrovePi LCD RGB
  7. Grove button
  8. Grove Led Red
  9. Grove Led Green
  10. Grove rotary sensor
  11. Grove buzzer
  12. n.2 generic relay NC/NO - 5V PIC ARM AVR DSP
  13. n.1 1kohm resistor
  14. n.1 10 kohm resistor
  15. some jumpers
  16. DVD player len mechanism
  17. Lego Duplo blocks and base (Zoo)
  18. small screws for relay and Grove sensor
  19. medium screw with washer for DVD len mechanism
  20. knob

Tools:

  • screwdriver
  • drill
  • file
  • cutter
  • welder

Step 2: The Enclosure

The casing is divided in two sections containing:

  1. Raspberry, GrovePi+, leds, buzzer, rotary sensor and two relay
  2. 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

SendEmail (OBSOLETE):

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>>>>>

extract it:

$ 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:

m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?))$}i

and change it to:

m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?))}i

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


Install SSMTP

$ 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

root=postmaster
mailhub=smtp.gmail.com:587
hostname=raspberrypi
AuthUser=YOUREMAIL1@gmail.com # you can use one of two accounts created to send email

AuthPass=TheGmailPassword
FromLineOverride=YES
UseSTARTTLS=YES

Save and exit

$ sudo apt-get install mpack

GnuPlot

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:

  • /home/pi/clickity.py
  • /home/pi/te.txt
  • /home/pi/te1.txt
  • /home/pi/stat.txt

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.

http://sourceforge.net/projects/dexterindustriesra...

http://www.dexterindustries.com/site/?product=grov...

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.

  1. after selected you coin target you can choose yes to confirm, no to repeat dates entering
  2. pushing the button and turning knob in fully clockwise position until len mechanism stop moving

That's all.

I hope you enjoyed it.

Bye

Comments

author
dmartin dorak (author)2015-06-26

What a fun way to use those DUPLOs hanging around and to introduce electronics to the kids.

author
THEJJRAT (author)2015-06-18

Or just buy a jar and an alarm clock.

author
braytonlarson (author)2015-06-17

This would be really much more functional with a coin reader. They come pretty cheap on ebay, it's just a matter of interfacing it with the Pi. Cool instructable though, nice work!

author

(adding on to my previous comment). Adafruit also sells a much more compatible, albeit more expensive, coin acceptor that could work for this project. https://www.adafruit.com/products/787