Skip to content

v1.0

Choose a tag to compare

@Liongrass Liongrass released this 12 Sep 04:28
· 11 commits to main since this release

This is the first major release of the 21UP. The 21UP now acts as a full-functioning vending machine. You pay once and can expect exactly one pop. There no longer is a time limit to how quickly you have to press a button, meaning it's now also possible to "pay it forward," although the machine still lacks a mechanism to indicate whether it is currently "hot" or "not."

There is an LNURL-pay QR code displayed on the front of the machine. The raspberry pi listens to the LNbits websockets for incoming payments.

As a user scans and pays the QR code, the machine becomes "hot," meaning it is ready to dispense pops. The machine will then listen on six separate pins, one for each button. The buttons are wired into an Optocoupler, which does not interrupt the flow of electricity to the motors, but feeds off them to give a 3.3V signal to the Raspberry Pi.

This allows the Raspberry Pi to detect when a button is pressed. The machine dispenses the pop, and the relay is closed to prevent further button presses. The machine logs which button was pressed and what item the tray belongs to.

Each tray contains a sensor that is triggered when the machine is running low on pop. The machine can show this information by turning on a little red light behind the pop labels on the front of the machine. When the light is on the machine also refuses to release the pop. In this iteration, this sensor is wired to also trigger the Pi at the same pin as the button, which prevents the Pi from picking up a pressed button when the tray is running low.

In effect, when a tray is running low, a button press no longer triggers the release of a pop, and also no longer closes the relay. Instead, the user can make a second choice.

Regardless of whether the tray is low or not, the red light will also flash when the user presses a button after a payment was made.

The entire logic lies in three different parts of the machine:

  • The Machine itself carries the logic for how to dispense a pop, and which tray to dispense.
  • The Raspberry Pi carries the bulk of the logic, mainly detecting incoming payments and which button is pressed. It uses that information to "open" and "close" the relay, which allows the buttons to be pressed. It currently uses a fork of the DCTRL Bepsi code, written in NodeJS.
  • The LNbits backend (v1.2.1) is used to generate the LNURLp code printed on the front of the machine. Using the bitcoinswitch extension (v1.0.1), we define the price and the outgoing pin that is triggered when a payment comes in.

In future iterations, we expect more logic to move to the Raspberry Pi, such as which tray to dispense or which price to set.

Current issues and limitations:

  • The code needs improvements around the button listener logic.
  • The machine only allows for uniform pricing, as it would have when it was running fifty years ago.
  • There is no indication that an invoice was paid and that the machine is ready to dispense