---
title: "A coin-operated liquid dispenser on a Raspberry Pi"
description: "Controller software for a self-service windscreen-fluid dispenser with coins, a card terminal, a flow meter, two pumps and a touchscreen."
date: 2021-08-26T12:45:13+02:00
lastmod: 2026-10-16T18:58:52+02:00
url: https://klimek.link/projects/vending-dispenser/
author: "Marcin Klimek"
source: https://klimek.link/projects/vending-dispenser/
---

# A coin-operated liquid dispenser on a Raspberry Pi

This is the software for a self-service dispenser of windscreen-washer fluid, in a summer and a winter version, where customers pay with coins or a payment terminal, press start, and the machine pumps the amount they paid for. It runs on a **Raspberry Pi** with a 1024×600 touchscreen and is the successor of my [ATmega-based avr_flow](/projects/avr-flow/).

## How it works

Everything goes through GPIO: three coin acceptors, a card-terminal input, a flow-meter input counted on rising edges, two pump outputs, a status LED and the service buttons (enter, up, down, cancel, start). Because the flow meter gives a fixed number of pulses per litre, the controller is able to tell exactly how many litres have been pumped and to stop at the paid amount.

*Diagram: GPIO inputs and outputs around the Raspberry Pi controller*

In the service menu you set pulses per litre (for calibration), price per litre and product type with the buttons, and reset the counters there too. Money taken and litres dispensed are saved to disk, in total and since the last reset, to survive restarts. Customers see a full-screen tkinter interface with the credit and the dispensed amount, and the controller also publishes its state over a local WebSocket.

The machine has to be able to run unattended: `supervisord` keeps the program alive, the Pi boots into a read-only kiosk mode, and the GPIO pins get their initial states already at boot through the device tree, before the program starts.

[Source on GitHub](https://github.com/marcinklimek/vending).

Source: https://klimek.link/projects/vending-dispenser/
