Skip to main content
Version: FILS English

Ali coffee

Coffee vending machine with drinks selection options, based on ESP-32-C6 chip.

info

Author: Artem Lebedev (group 1221EB, FILS)
GitHub Project Link: Ali coffee

Description

This project is a coffee vending machine capable of creating a variety of coffee drinks using a gravity- and time-based dispenser of hot water and instant coffee. To implement this idea, we'll use a solenoid valve for the water tank, a servo motor with a flap for the coffee container, drink selection buttons, and a host of additional features: an LCD screen displaying the brewing process and water level, a buzzer to notify when the coffee is ready, and a float sensor to indicate when the water level is low. At the core of all these devices will be an ESP32-C6 chip; the enclosure will be a wooden T-shaped structure.

Motivation

My desire to build a coffee machine, rather than any other device, is easy to explain – I'm a big fan of this aromatic drink, and if I'm going to do anything, it's going to be something I personally wouldn't shy away from using. Of course, my design is a far cry from a professional coffee machine, but at the same time, I think it will provide worthy competition to the machines dotted around campus.

Architecture

The system is organized into three functional layers:

Input Layer

  • Three tactile push buttons select the drink mode: Espresso, Double Espresso, or Americano.
  • A float switch liquid level sensor monitors the water tank and signals when it is empty.

Control Layer

  • The ESP32-C6 SuperMini runs the main async task loop via Embassy.
  • On button press, a mode-specific timing profile is selected, and serving coffee and water for the correct duration starts.
  • The water sensor is polled continuously; if the tank is empty, dispensing is blocked and the display shows a warning.

Output Layer

  • A 12V solenoid valve (normally closed) controls water flow from the tank to the cup, driven by an IRF540N MOSFET with a 100Ω gate resistor.
  • A servo motor (SG90) opens and closes a mechanical gate on the coffee powder container.
  • An SSD1306 OLED display (0.96", I2C) shows brewing status and warnings.

All components share a common ground. The 12V rail powers the solenoid valve and is supplied by an external 12V 2A DC adapter. The ESP32-C6 is powered via USB.

Diagram

Ali_coffee_schematics

Log

Week 5 - 11 May

Week 12 - 18 May

Week 19 - 25 May

Hardware

The system is built around the ESP32-C6 SuperMini microcontroller, which manages all inputs and outputs over GPIO, PWM (LEDC), and I2C. Two food-grade plastic containers (1–2L) serve as the water and coffee powder tanks, each mounted above the dispensing point to allow gravity-fed flow.

Water flow is controlled by a 12V normally-closed solenoid valve. When the ESP32-C6 pulls the MOSFET gate high, the valve opens and hot water flows through a silicone tube into the cup. The MOSFET (IRF540N) is connected with a 100Ω resistor on the gate to limit switching transients.

Coffee powder is dispensed through a mechanical gate controlled by the SG90 servo. At rest, the gate is closed. When activated, the servo rotates 90° to open the gate, powder falls by gravity, and the servo returns to close it after the timed duration.

Pin Connections

ESP32-C6 GPIOFunctionConnected To
GPIO2Button – EspressoTactile button → GND
GPIO3Button – Double EspressoTactile button → GND
GPIO4Button – AmericanoTactile button → GND
GPIO5Solenoid valve controlIRF540N Gate (via 100Ω)
GPIO6I2C SCLSSD1306 SCL
GPIO7I2C SDASSD1306 SDA
GPIO8Servo PWM (LEDC)SG90 signal wire
GPIO9Water level sensorFloat switch → GND
3.3VPowerSSD1306 VCC, SG90 VCC, Float switch
GNDCommon groundAll GND rails

Schematics

Bill of Materials

DeviceUsagePrice
ESP32-C6Main microcontroller50 RON
Solenoid Valve 12V N/CWater flow control25 RON
IRF540N MOSFETSolenoid valve driver2.5 RON
Resistor 100ΩGate resistor for MOSFET0.5 RON
Servo SG90Coffee powder gate control13.5 RON
OLED SSD1306 0.96" I2CStatus display10 RON
Float Switch Liquid Level SensorWater tank monitoring25 RON
Food-grade plastic container 1–2L (×2)Water and coffee powder tanks30 RON
Silicone tube (thermoresistant)Water delivery from tank to cup10 RON
Hose barb fittingTank outlet connector5 RON
Tactile push buttons (×3)Mode selection5 RON
Breadboard 830 pointsPrototyping platform10 RON
Dupont jumper wires (M-M, M-F set)Component connections10 RON
DC barrel jack 5.5mmPower supply connector2.5 RON
12V 2A DC power adapterPowers solenoid valve20 RON
TOTAL220 RON

Software

LibraryDescriptionUsage
esp-halHardware Abstraction Layer for ESP32-C6GPIO, LEDC PWM, I2C peripheral control
esp-hal-embassyEmbassy runtime adapter for ESP32Enables async task execution on ESP32-C6
embassy-executorAsync task executorRuns concurrent tasks: buttons, dispensing, display
embassy-timeAsync time utilitiesTimer::after() for precise dispensing durations
embedded-halHardware abstraction traitsStandard interface for GPIO and PWM
embedded-hal-asyncAsync hardware abstraction traitswait_for_falling_edge() for button and sensor input
ssd1306SSD1306 OLED display driverRenders status messages on the 0.96" display
embedded-graphics2D graphics primitivesText rendering on the OLED display
esp-backtracePanic handler with serial outputDebugging — prints panic traces over UART
esp-printlnprintln! macro over UARTLogging timing and sensor values during development