The new 21UP vending machine displays a Bolt11 invoice on the e-ink display when a button on the machine is pressed. When the invoice is paid it dispenses the requested can.
Currently being implemented:
- Create a spreadsheet of items sold, their price and time it took to pay the invoice
- Log the past screens as they were shown
To be implemented:
- Keep listening for the button even when an invoice is currently pending.
- Cancel the current invoice when a button is pressed
- Make use of LCD screen
Bugs:
- Occasionally the device would pick up a tray as full when it isnt
This guide and the code are optimized for Rasperry Pi OS (Bookworm).
Enable the SPI interface:
sudo raspi-config
Then select Interfacing Options -> SPI -> Yes to enable the SPI interface
git clone https://github.com/Liongrass/21UP.git
cd 21UP
python -m venv env
source env/bin/activate
pip install -r requirements.txt
To install and configure the DHT11 barometer, some extra configuration is necessary.
First, edit the firmware configuration:
sudo nano /boot/firmware/config.txt
At the very end, amend the following line. Don't forget to replace the GPIO with your own:
dtoverlay=dht11,gpiopin=4
Finally, reboot the device to activate the changes.
More information can be found in DHT11.md
To run the machine, first copy the example configuration file.
cp .env.example .env
Most importantly, a valid LNbits URL and invoice key need to be set.
Variables pre-fixed with a # sign have defaults and do not need to be set.
nano .env
Run the machine:
python main.py
To make the code run on startup and restart after a crash, we are using the PM2 utility.
Prerequisites:
sudo apt install git make build-essential
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
\. "$HOME/.nvm/nvm.sh"
nvm install 24
npm install -g pm2
pm2 start /home/user/21UP/main.py --interpreter /home/user/21UP/env/bin/python --name 21UP --exp-backoff-restart-delay=100
pm2 startup
This will give you a short command. Execute it to make 21UP run on startup.
Useful commands:
pm2 logs 21UP
pm2 list
pm2 monit
pm2 restart 21UP