Raspbery Pi based Arcade Machine FTC Payment Proof of concept
-
I started discussing this on my thread on the Pi based FTC ticker but have decided to make a new thread for this one as it will take a while to get it fully completed.
I will build it progressively in stages.
Stage 1) Prove code works that can check a FTC balance via the API and turn on a LED for 30 seconds for each FTC deposited into the account.
Stage 2 ) Integrate a display into the Pi that will display the FTC account QR code, so when the Pi is depowered, or unable to connect to the API the QR code is not available so people won’t try and pay for a credit when it wont work.
I plan on using this display from Adafruit http://www.adafruit.com/products/1601
Stage 3) Replace LED with a relay cct which will work for older Electromechanical Pinball machines. (Why?, because I hope to buy one soon)
Stage4) If all goes well and there is interest look at what is required to make it work with modern machines
Once I get the code to a level I’m happy with I will put it up on GitHub.
All code will be written in Python 2.7.8
-
I like the sound of this lots :)
If your using a Pi you can get the demon to run directly on it, it just take a bit of time for it to compile and then for the wallet to sync. Once you have this if you wanted to you could generate a new address for each transaction and then check the address balance via feathercoind.
If you want to do it via the API without individual addresses you would need to get the current balance and record it, then check again some time later and see if there was a delta, as I can’t see anyway using the current API to see if a new transaction has hit an address hence using the above method on the PoS terminal
Here is a little bit of code that will create your QRCode for you and has been tested on small screens with the android wallet :)
def __createQRCode(self, txid, paddress, ftotal): qrdata = ("feathercoin:%s?amount=%s&label=%s") % (paddress, ftotal, txid) qr = qrcode.QRCode(version=10) qr.add_data(qrdata) qr.make() im = qr.make_image() im.save("images/qrcodes/%s.png" % txid)
I’ll have another think about it and see what else I can offer up to help you along your way
UM
-
I like the sound of this lots :)
If you want to do it via the API without individual addresses you would need to get the current balance and record it, then check again some time later and see if there was a delta, as I can’t see anyway using the current API to see if a new transaction has hit an address hence using the above method on the PoS terminal
I’ll have another think about it and see what else I can offer up to help you along your way
UM
Thanks for the help.
The plan is when the Pi first turns on it checks the balance of the account.
It then checks the balance against the API at set intervals (undecided if to make this every 15 or 30 seconds, dont want to make people wait too long but don’t want to flood the API with unnecessary requests ) and if the balance has incremented an amount equal to or greater than the cost of a credit it records the one credit to the credit variable.
It then raises the previous balance by the amount a credit is set to and checks again, if the new balance is still higher than the updated balance by an amount equal to or greater than one credit it will add another credit to the credit variable and so on.
This way someone can pay for more than one credit at a time.
I’ll try my way first, mainly because I’m a ‘cut and paste’ coder and if my way works I can do it without having to write a lot of code.
What you are talking about is a bit above me skill level at the moment, although its probably a better way to do it.
If all goes well I will have reached stage one by the end of tonight.
-
Stage 1 complete.
I have a video of it working, just waiting for it to upload.
For this test the cost of a credit is 1ftc.
It took about 1 minute 20 seconds for the payment to register.
If have SSH into the Pi on my PC so we can see it checking and the results.
It then shows when it detects the balance has gone up by the value a credit costs, counts up the credits, then ‘spends them’ with the LED and counts the credits back to zero.
I need to prove the code works when you purchase multiple credits at once yet.
It will probably be atleast a couple of weeks before I complete stage 2 as I need to order the screen.
Video to follow shortly with about 50 seconds of the waiting cut out so you don’t all fall asleep.
See if your quick enough to spot the feathercoin ticker running too. :)
Video has uploaded, but I can’t figure out how to embed it on this forum, so here is the link to it
-
Nice work! that was pretty quick to be to this stage. :)
-
AWESOME!
I pretty much wanted to do the same for a year or so, never got to it till about a week ago.
As hacking is kinda my thing, i bought a second hand network router for about $4 and started messing around with it.
Simply put, i started at the other half of your project.
I have a 1994 Corvette pinball machine in mint condition in my living room.
I hacked the router to be a very basic DHCP enbaled linux box with SSH management. I used the GPIO to enable the “WiFi” LED. This will trigger the relay.
A relay is definately the way to go as the original “coin taster” drops a coin on a switch. The switch has two nice big exposed soldering points on the two wires. So my plan was to use some non-destructive clip-on system from the other side of the relay.
Current status:
-
Router rooted and configured
-
FTC balance script untested (bash script using external API)
-
WiFi LED output soldered to a long wire.
-
Router nicely back in it’s casing.
-
Pinball machine configured (I used the old Dutch currency Gulden. This results in the currency “F” on the screen, 1F, 2F, 10F, etc.)
Todo:
-
Solder a small relay on a PCB connected to “coin taster” and hacked router.
-
Test bash script.
-
Find a way to display a “working/not-working” LED under the glass. (i have blinking startup LED i can manually trigger on the router as well)
My pinball payment conversion would be a lot less fancy but only cost me about $5
I love hacking around with hardware. Making it do wonderfull things it was never intended for :)
-alex
-
-
Nice, look forward to your results.
Omce I sat down and wrote the code I was amazed at how simple it was. I think in total I’ve got about 40 or 50 lines of codes and a lot of that is just notes in the code to remind me what each bit does.
I’m assuming you are not going to wire the relay directly to the output, but have it driven by a transistor as I doubt a cct that was made to light up an LED will be able to drive a relay without damaging your router
-
Code for stage one is now available on github
https://github.com/tmuir12/FTC_Arcade_Pay/tree/master
It will be a week or two before I have completed stage 2
-
This is great work :) I have way to much on right now or I would be following your lead and building something up. I can see a FTC powered pinball machine coming on our meetups in the near future ;)
-
I love all this. Who was the guy paying his children’s pocket money in FTC? would be a great way to regulate video game use haha.
-
Its pay day on Tuesday so will order the parts then.
I can see integrating the screen will be my biggest challenge, but there are a lot of great ‘howtos’ around on the web
-
Another Raspberry PI, that can be dedicated to this project has been purchased along with the screen.
I’m guessing I will now have a 1 to 2 week wait for them to arrive from the USA before I can continue my build.
-
I think Raspberry PI’s are made in the UK now (Although the original runs were made in china I believe)
EDIT: yep Wales - http://www.raspberrypi.org/tag/made-in-the-uk/ :)
-
Yes Raspberry Pis have been made in the UK for some time now, but the display I wanted I had to buy from Adafruit and I needed another Pi so bought it from them and a few other parts to spread the cost of the postage.
Tracking says I should get everything mid next week.
-
I think Raspberry PI’s are made in the UK now (Although the original runs were made in china I believe)
EDIT: yep Wales - http://www.raspberrypi.org/tag/made-in-the-uk/ :)
Yes they are, be very careful if you have one of the early ones that was made in china as they are nowhere near as reliable for some reason… I had loads of problems on one of my projects due to this and as soon as I switched it out for a UK built Pi everything started to work out again :-
This is also worth looking into http://www.bbc.co.uk/news/technology-28263659 depending on what interfaces you are after, a little less power consumption would be good for a couple of my devices as they run from batteries
-
This is also worth looking into http://www.bbc.co.uk/news/technology-28263659 depending on what interfaces you are after, a little less power consumption would be good for a couple of my devices as they run from batteries
Thats just so typical.
Just a few hours before I ordered a new Pi, they released a new and improved model and I ordered the older model. >:(
Extra USB ports is definitely nice, makes it much easier to use wireless with a keyboard and mouse
-
Yay! Got it working :)
I am going to use this at a job interview on Monday. It covers a lot of things they need me for:
http://balgehacked.wordpress.com/2014/07/18/10-cryptocurrency-pinball-mod/
All in all a $10 mod to the pinball machine.
@tmuir12, I am looking forward to your version. The LCD screen will be a must have i guess. If there is anything i can help you with, please drop me a line ;)
Happy hacking!
-
Wow that’s great work well done. And what a great blog too. :)
-
Cool!
I found it took about 1 minute 20 seconds for the credit to reach my Pi, so about the same time as yours.
Your solution is definitely cheaper than mine, well done!
I hope to have the screen and my new Pi some time next week, so by next weekend I might of made some more progress.
I have been thinking that being able to prepay for credits would also be useful ut I’m not sure whether this would be within my coding skill.
The idea they pay in advance and get a QR code that could be printed out, or displayed on a phone and using a Raspbery Pi camera in theory it should be able to scan it and then add the credits straight away, but that is just an idea at the moment, not completely sure how to implement it
-
Wow that’s great work well done. And what a great blog too. :)
+1