loading

What is it .. a ATM that can pay your children their pocket money - Why .. Because I can ... no, seriously .. In our home we aren't very good at remembering to give our children their pocket money, so what better solution than to make a web service and a machine to handle this.

It is based on a stack of coins, a servo to push out one coin at the time, a RFID module to read the identity of the current user, a OLED display to provide feedback and a ESP8266 to run some arduino code. It connects over WIFI to the internet and communicates with a webserver running a PHP application managing the accounts.

The inner frame is made out of plexiglas, and the outer box birch veneer.

Step 1: Coin Stack and Servo

The main component is the coin stack, with the stack of coins, the servo that moves the coin pusher, which pushes out the coins, one at the time.

The first couple of models was designed free hand and cut in plain cardboard and later in foam-board. But these were to inaccurate and could not withstand the weight of the coins. So with help from my friends at Fablab Nordvest, I redraw the design using Fusion 360 and then cut it in 3 mm plexiglas.

The design may lack in some places, but in my defence, then this is my first time using Fusion 360.

The servo is just a regular servo, something like this should do the trick. I thought of making a proper mount for the servo, but just never got around to it, so now it's held in place with double sided tape.

The coin pusher is cut from at sheet of PVC (i think). The link connecting it to the servo is just a paper clip that bend so it fits and then hot glued to the PVC. It is important to use a flexible material for the coin pusher to compensate for the rotation of the servo.

Step 2: Electronics

Hardware

The servo that pushes out the coins is controlled by a ESP8266, in this case I'm using a Wemos D1 mini. Connected to this is a OLED display. I chose one thats using I2C for communication to preserve IO pins on the Wemos.

The other component connected to the Wemos is a Mifare RC522 RFID module.

And finally there is a pushbutton. This button has no function in the current setup, but you can never have to many pushbuttons.

Wirering

  • D0 => Pushbutton
  • D1 => MFRC522: SDA
  • D2 => MFRC522: RST
  • D3 => OLED: SDA
  • D4 => OLED: SCL
  • D5 => MFRC522: SCK
  • D6 => MFRC522: MISO
  • D7 => MFRC522: MOSI
  • D8 => Servo

Step 3: Firmware

The code running on the ESP8266 is based on arduino. There is not much to it..

I'm using WiFiManager, which is a library for managing network credentials and other configuration such as the endpoint for the web service. This library will store network credentials and other settings, when the microcontroller starts up, it will try to connect to the wireless network. If it for some reason is not able to connect, it will switch to configuration mode, where it becomes an access point itself. After you connected your computer to the access point, a configuration prompt will appear automatically.

The display is driven with Adafruit's Adafruit_SSD1306 and Adafruit_GFX. And the graphics used was created in Photoshop and then converted to code using an online service.

For the RFID module I'm using Miki Balboa Library for MFRC522.

On startup the microcontroller runs through the setup function. I've tried to keep this function as small as possible by moving the actual initialisation to other functions. At some point I plan to move these into separate files.

The main loop needs some refactoring, but what it does now is basically waiting, in a while loop, for the RFID module to read a card ID. To prevent the ESP8266 from crashing it calls the yield() function every 500 milliseconds. This is needed to handle WIFI communication and other internal stuff.

When a card ID is read, the display is updated and the web service is called. This is done with a HTTP POST-request, where the body is the card ID wrapped as a JSON object.

POST http://payout.localhost/api/withdraw.json
{
"card": "12c02d3b"
}

The response will look something like this:

{
"message": "Here is your money, you got 4 remaining.", "status": 200, "balance": 4, "amount": 1 }

If there is no valid response from the web service, it will either display an error message, or if there is any credit available on the account it will payout the amount specified in the response.

JSON encodeing and decodeing is done with the ArduinoJson library.

Source code

The full source code is available at GutHub

https://github.com/langeland/Arduino-Payout

Step 4: Outer Box

The outer box for the coin stack was cut from 4mm birch veneer on a laser cutter. The sides and back was glued and sanded.

On the inside of the front panel, I removed roughly 2mm of the veneer around the display. I did this using a Dremel and a endmill.

The front panel is held in place with magnets.

Step 5: Web Service

The web service is implemented in php and is based on the Flow Framework.

Source code

The full source code is available at GutHub

https://github.com/langeland/Distributions-Payout

<p>This looks awesome! You definitely have my vote.</p>

About This Instructable

2,579views

37favorites

License:

More by jon langeland:Payout - A web enabled ATM for pocket money 
Add instructable to: