I have been impressed by how Bitcoin technology (Blockchain) works, and how you can easily send/receive funds. And since I am a maker, so I asked myself "What about easily connecting hardware projects to such network making these hardware accepts bitcoins?" Then I started by implementing the first Arduino Bitcoin library called Koyn.
Rapidly wrapping up, Koyn is an Arduino library that helps Arduino makers to build their hardware projects and connect them to the Bitcoin network (currently supporting test network) and accept bitcoins, making it easy for the users to take hardware actions whenever they spend/receive bitcoins. You can check the link for the documentation here.
Step 2: ImplementationTo get my hand dirty, I made my first application using Koyn library "A Bitcoin Candy Vending Machine." And with simple provided API methods, you can easily track your Bitcoin addresses over the network.
To be honest writing the code didn't take any time, as Koyn's API interface provides most of the functionality to control your funds, while connecting the hardware parts is a little bit tricky, and as a maker you may wonder "Why would I use two development boards in one proect?"
The answer is that I already had a Wemos (ESP8266) WiFi board, which doesn't provide plenty I/O pins to control numerous servo motors + LCD screen + Push Buttons. Then I came up with a simple hack! I decided to let all the controls and interfaces handled by an Arduino Mega board, and of course the funds controlled by the WiFi Wemos board.
I wrote two Arduino sketches (codes), one for the Arduino Mega controlling servos, push buttons and LCD, and the other sketch to track my bitcoin address using koyn library.
Then connected both boards over UART to easily communicate, allowing the Mega to update the funds over the LCD and take input from the push buttons to control the servos dispensing goods.
Making both boards communicate was also a little bit tricky, so I used Arduhdlc library as a serial protocol.
Special thanks to "Dejan Nedelkovski" for providing the designs of the machine and a step by step procedure to build your own.
Step 3: ConnectionsNow the most interesting part! connecting hardware together.
I also decided to place all the components on the back of the vending's machine door. "All connections provided in the schematics section."
Step 4: CodeProvided in the code section, you can find both Wemos and Arduino Mega codes.
As I mentioned before, each board is doing its job according to the code provided, so Wemos board is connected to the internet (Bitcoin network) listening to my Bitcoin address sending any funds updates to the Mega.
On the other side the Mega takes the hardware actions by checking the balance and assign each buttons balance, and outputs users messages over the LCD and finally controlling the servos.
Make sure to download ESP8266 core to compile and upload the code over the Wemos board.
Also I have provided Arduhdlc library in the code section, make sure to download the library and place it under your Arduino directory "C:\Users\"name"\Documents\Arduino\libraries"
FinalThat was pretty much how I built my first decentralized Bitcoin vending machine, if you have any comments please leave it bellow in the comments section.
Comments