Vending Machine With Scale to Confirm Itemdrop (Raspberry Pi)
by TajMahaladeen in Circuits > Raspberry Pi
2918 Views, 14 Favorites, 0 Comments
Vending Machine With Scale to Confirm Itemdrop (Raspberry Pi)
Welcome fellow maker,
for a school project I decided to make a snack vending machine. Our assignment was to create a recreatable device that used at least 3 sensors and 1 actuator. I went to make a vending machine partly because I had access to some essential parts (i.e. the motors) via my local makerslab. First off the idea was to create a beverage vending machine, but that wouldn't have been feasible because of the need of isolation, cooling element and softer release mechanism for sparkling beverages.
This project was a first for me in some ways; I had never worked with wood and electronics before on such a scale. My experience was primarily in software, so I decided to challenge myself by creating a project that would be a real learning experience.
I will try to explain to you guys, in the best way possible, how to create this vending machine. Bear in mind all this was a first for me, so I made some rookie mistakes with woodcutting etc.
All code can be found in the Github repository: https://github.com/ParmentierGil/SmartVendorPublic
Supplies
- Wood
- Hinges
- 2 harder ones for the main door
- 2 soft ones for the product hatch
- Plexiglass
- 4 vending machine DC motors (with a button for rotation managment)
- 4 spirals (I used 6 mm² copper electrical wire)
- 4 connectors to connect the motors the spiral (I 3D printed them)
- Raspberry Pi
- 4x4 Keypad
- Coin acceptor
- LCD
- Jumper wires
- Breadboards
- 4 TIP 120 transistors
- Resistors
- One wire thermometer
- LED strip
Programming the Sensors
Since I had the most experience in software I decided to start with the programming of the sensors first.
The sensors include:
- One wire thermometer
- Load cell sensor
- 4x4 keypad
- Coin acceptor
The one wire thermometer is pretty straight forward and just involves connecting the one wire to GPIO PIN 4 of the Raspberry Pi (with some resistors) and reading the file associated with it.
The load cell was somewhat more complicated but still quiet easy. The 4 wires had to be connected to the HX711 amplifier and in turn the HX711 amplifier had to be connected to the Raspberry Pi. Once this has been done, I used the HX711 python library to read out values. Reading out the load cell without load defined the tare value. After that I placed some pre-known weights on the scale and with the rule of three I calculated the constant that the read value had to be divided by to be presented by a value in grams.
The 4x4 keypad is as intuitive as it can be. With the 8 wires connected to the keypad representing the 4 columns and 4 rows of the keypad. Some caution has be had with the ordering of these wires, since the 2 4x4 keypads I used had 2 totally different wire orders. With an easy to use keypad library the pressed key can easily be registered when wired correctly to the Raspberry Pi.
The hardest of the sensors is definitely the coin acceptor. Setting up the coins on the device is pretty straight forward due to some good documentation. I had a device which was capable of differentiating 4 different coins. You have to specify the associated amount of pulses for a coin the device sends to the Raspberry Pi. The coin registration on the device end is almost flawless which can be seen by the display on the side. The problem lays in registering these pulses on the Raspberry Pi. A powerful enough adapter (12V, 1A) has to be used to be able to distinctively register the different coins, as well as some careful programming to not stop counting pulses too early.
Connecting and Programming the Motors
I scavenged some vending machine motors from my local makerslab, but I still needed to figure out how to connect and program them.
The motors had 4 wires connected to them and after some figuring out 2 were for power (at least 12V) and 2 were for the button which is pressed every half a turn. I connected each of these motors to a TIP 120 transistor to be able to control them via the Raspberry Pi. One of the other 2 wires I connected to a input of the Pi (with pullup resistor) and one to ground.
After that I made some spirals from 2.2mm steel wire, which turned out to be spiraling the wrong way; so that my items went backwards instead. So I used 6mm² copper electrical wire which was way easier to work with.
After making 4 spiral it was time to make the connectors necessary to connect to spiral to the motors. I decided to 3D print them (file attached) and glue them to the motors and bend the wire around them.
Creating the Housing of the Machine
For the housing I used wood that was present in the makerslab. Since there wasn't plenty of one type and the front panel had to be slimmer to fit the electronics, the housing consisted of at least 6 types of wood.
First off I sawed 2 planks of 168 x 58 cm in half for the backpanel, the 2 side panels and the middle divider panel.
For the bottom panel I used a convenient (or so I thought) piece of wood of 58 x 58 cm. This turned to out to be a mistake since I didn't account for the thickness of the wood, so the backpanel had to be screwed in on top of the bottom panel and the side panels had to be screwed in from the side. This left an extra 2 cm piece sticking out of the top.
After that I screwed the 2 horizontal product planks to the middle divider panel. Aswell as the top of the product compartment. Then I started breaking up the plexi glass for the hatch which I connected with 2 soft hinges on to a bar of wood connected to the middel divider panel. Once that was completed the hole middle compartment had to be screwed in to the left side panel.
Then I made the wooden parts of the scale and glued them to the bottom of the housing. This left a bit of a gap on the bottom of the housing which I solved with placing a thin plank in front. (Not on picture)
Assembling the Sensors and Motors to the Housing
Once the skeleton of the housing was done it was time to insert the guts.
First I cut some holes in a plank for the LCD, the keypad and the coin acceptor. Then I nailed these electronics to the plank and wired them to the Raspberry Pi. Some careful planning had to be done to not cross the wires to much. The one wire thermometer I connected to a breadboard glued on the inside of the electronics plank. Then I sawed a plank for the Raspberry Pi, the breadboard for the motor transistors and the arduino which I used to supply the 12V for the coin acceptor and the motors.
The motors I glued to the horizontal product planks and I added some vertical planks to divide the item compartments.
Finished Up the Vending Machine
For the finish I painted the whole machine black and added a LED strip to the inside. Under the coin acceptor I made a little compartment for the coins to fall in, so they wouldn't slide all over the left compartment. I also added in the plexiglass door with the harder hinges.