Coin-operated machines have a long and illustrious history. The earliest known vending machine was in ancient Rome where a machine was created that would dispense holy water when a coin was deposited. Coin-op machines have been created for almost every aspect of life from food and drink, drugs (nicotine), entertainment (pinball and video games) to doing your laundry or washing your car.
With the advent of cryptocurrency, an opportunity may be arising for crypto-coin-op machines of even greater variety. I was intrigued by a couple of examples here on hackster.io - a Bitcoin Powered Electrical Outlet and had to make my own version. Original idea was a Bitcoin Operated Car Wash (using a solenoid water valve) but it is so easy to generalize to "just turn on power to something" when a payment is received. The Electrical Outlet above uses an Arduino library called Koyn which is actively being developed (as of 8/29/2018) and required an SDCard for the Wemos. While waiting for an SDCard shield to be delivered I created another version similar to the Bitcoin Powered Coffee Machine using the Wemos (esp8266) and some libraries for WebSockets to connect to a test bitcoin service and subscribe to an address, a json parsing library and a timer to control a pin that actuates the solid state relay depending on amount of payment received.
Here is my video demo of the device turning on a fan for payment in testnet3 BTC, at a rate of 1 minutes per.1mBTC (.0001 BTC). testnet3 coin are freely obtained from many faucets that only ask you return them to the same source when done. I have the testnet3 Bitcoin app (they are gray color instead of orange to differentiate) installed on a Galaxy phone and a Lenova tablet, and the target wallet is a Electrum application running on a Ubuntu notebook. The address of the Electrum wallet is coded into the Wemos sketch which turns on the relay power when payment is received.
One issue with this method is the payments are UNCONFIRMED and could be reversed or refunded I guess. I will have to research how Koyn handles that. At any rate, a coin-op machine will need to have rather quick response and may not have enough time to confirm payments and just have to trust if that does not lead to abuse, or the equivalent of making worthless lead slugs for actual coin-op machines. In fact, for real life deployment security and hack-proofing will be a huge concern.
Installing Electrum for testnet3 on any available Ubuntu os is described here and involves something like this - check in https://download.electrum.org/ for the latest version posted:
sudo apt-get install python3-setuptools python3-pyqt5 python3-pip
sudo pip3 install https://download.electrum.org/3.2.2/Electrum-3.2.2.tar.gz
electrum --testnet
Click on the "Receive" tab and note the wallet address:
And enter that in the Arduino sketch for:
/**** Custom configuration items ****/
// Put YOUR BTC testnet3 wallet address here
char waddr[] = "n3EdCJtov8rMR3BCJWtpQCtamYnu7faiKw";
Also set your own WiFi connection parameters for SSID and passphrase.
Note - programming may cause power to turn ON, so disconnect power input to the Solid State Relay if you do not want a device actuated, like a water valve, at unexpected times.
Then you can send testnet3 BTC to your wallet and the Wemos will notice payment and turn on D0 / SSR for the time purchased.
Comments