An ESP32 can turn an ordinary drip or pod brewer into a smart coffee machine by adding relay-switched power control, a temperature sensor, a water-level sensor, and a local web interface or MQTT connection to Home Assistant. The realistic goal is not espresso-grade pressure profiling, but reliable scheduled brewing, remote start, preheat control, and status feedback on a machine whose physical buttons and safety systems stay intact.

This guide covers the architecture, the parts that matter, the firmware decisions, and the failure modes that separate a working build from a fire risk.

What "Smart" Should Mean Before You Buy Anything

The most common mistake in ESP32 coffee projects is starting with the microcontroller and only later asking what the machine should actually do. That order produces a tangle of sensors and half-finished firmware. Start from three concrete capabilities, because almost every useful build needs them: switching the heating element on and off, knowing when the water is hot enough, and knowing there is water in the reservoir.

Everything else — scheduling, voice control, notifications — sits on top of those three.

A practical target list for a first build looks like this: remote start with a warm-up delay, a schedule for weekday mornings, an alert when the reservoir runs low, and a hard physical shutoff that works whether or not the firmware is running. Notice that "brew the perfect cup" is absent. The ESP32 does not make coffee better; it makes a machine you already own more convenient.

That distinction keeps the project honest and the budget small.

Know which machine type you are modifying, because the electronics differ sharply. A drip brewer with a mechanical power switch is the easiest target: the switch simply completes mains power to a heating element and a pump. A pod machine adds a pump and often a thermoblock, but the same switching approach works if the machine has a physical on/off button rather than a capacitive touch panel.

Espresso machines with solenoid valves, pressure gauges, and electronic control boards are the hardest, and they are the ones where a relay hack most often damages something. If your machine has a digital display and membrane buttons, plan on interfacing with its existing control board or pick a different machine.

The Control Architecture: Relay, Sensors, and a Local Brain

An ESP32 DevKit board sits at the center, but it never touches mains voltage directly. The standard safe pattern is an opto-isolated relay module rated for the machine's load, with the ESP32 switching only the low-voltage coil side. The relay contacts interrupt the live conductor feeding the brewer's heating circuit, exactly where the original mechanical switch sits. That way the machine's own thermal fuse and thermostat remain in the circuit, which matters enormously for safety.

Load sizing is the first real engineering decision. A typical drip brewer draws somewhere between 600 and 1,500 watts, and a thermoblock pod machine can pull similar figures during heat-up. At 120 volts, 1,500 watts is 12.5 amps; at 230 volts it is about 6.5 amps. A common 10-amp relay module is marginal for the 120-volt case and should not be used.

Choose a relay whose contact rating exceeds the machine's nameplate current with margin, and prefer a mechanically latching or heavy-duty module over the cheapest blue board. The machine's nameplate — usually on the bottom — states volts, watts, and sometimes amps; read it rather than guessing.

Sensing splits into two jobs. Temperature is best measured with a waterproof DS18B20 probe or a K-type thermocouple plus MAX6675/MAX31855 amplifier, depending on whether you need cheap and adequate or fast and accurate. A DS18B20 is slow — roughly a second per conversion at 12-bit resolution — but fine for a reservoir or carafe reading.

For thermoblock outlet temperature, where the water can swing hundreds of degrees in seconds, a thermocouple is the better instrument and the ESP32's ADC is not.

Water level can be as simple as a float switch in the reservoir, which gives a clean digital signal and needs no calibration. Capacitive or conductive probes are fussier: conductive probes corrode in mineral water, and capacitive sensors drift with buildup. A float switch, an ultrasonic sensor aimed at the surface, or a load cell under the reservoir all work; the float switch is the most reliable for the money.

Do not put electronics inside the water tank unless they are genuinely waterproof.

Choosing the ESP32 Board and Power Path

Any ESP32 variant will run this project, but board choice affects the power supply. A DevKitC or NodeMCU-style board has a 5-volt input and an onboard regulator; feed it from a small 5-volt USB supply that is independent of the coffee machine's mains circuit. Never derive the ESP32's power from the heating element's switched side, because the board would reboot every time the brewer cycles.

Tapping the machine's internal low-voltage rail is possible on some models but invites ground-loop and isolation problems; a separate wall adapter is simpler and safer.

If you want battery backup for schedule retention, the ESP32's deep-sleep RTC keeps time but not Wi-Fi state, and a plain ESP32 has no battery-backed RTC domain in the way a dedicated clock chip does. For schedules, either keep the board powered continuously or add an I2C RTC module such as a DS3231, which holds time across outages with a coin cell.

That module is cheap and removes an entire class of "why did it brew at 3 a.m. after the power flickered" bugs.

GPIO allocation deserves a moment. Use input-only-capable pins carefully, avoid the strapping pins (GPIO 0, 2, 15 on many boards) for relays or sensors that could interfere at boot, and keep the relay's control pin in a defined state during reset. A relay that clicks on for 200 milliseconds during every boot is annoying; one that does it on a heating element is a hazard.

Drive the relay through a transistor or use an active-low module, and add a pull-down or pull-up so the element stays off until firmware explicitly enables it.

Firmware: ESPHome Versus Custom Arduino Code

For most builders, ESPHome is the right starting point because it handles Wi-Fi, over-the-air updates, Home Assistant integration, and sensor abstractions without writing a networking stack. A typical ESPHome configuration exposes a switch for the relay, a sensor for temperature, a binary sensor for the float switch, and a time-based automation for the schedule. The whole thing fits in a few dozen lines and updates over the air.

Custom Arduino or ESP-IDF code makes sense when you need behavior ESPHome does not express well: multi-stage brewing profiles, local-only operation with no Home Assistant, or a custom web UI. In that case, use the Arduino core with a web server library and MQTT, and structure the code around a small state machine — idle, heating, brewing, fault — rather than a loop full of delays.

Non-blocking timing with millis() keeps the web interface responsive while the heater runs.

Whichever route you take, build these protections into firmware from day one. Enforce a maximum continuous heater-on time (for example, 20 minutes) and latch off until manually reset. Refuse to start a brew if the float switch reports empty. Require a minimum temperature reading before enabling the heater, and treat a disconnected or implausible sensor as a fault, not as "cold." Log the last state before any reset.

These are cheap lines of code that prevent the two failure modes that actually hurt: dry-firing a heating element and leaving it on unattended.

A Concrete Build: Drip Brewer With Remote Start

Consider a 1,000-watt drip brewer with a mechanical rocker switch, a 1.5-liter reservoir, and a glass carafe. The nameplate reads 120 volts, 1,000 watts — about 8.3 amps — so a 15-amp opto-isolated relay module has comfortable margin. The ESP32 DevKit sits in a small project box zip-tied to the machine's back, powered by a 5-volt USB adapter plugged into the same wall outlet.

A DS18B20 probe is taped to the carafe's exterior near the hot plate, a float switch hangs into the reservoir, and the relay's contacts are wired across the original switch after removing it from the mains path.

The wiring sequence matters. Unplug the machine. Open the case and identify the live conductor from the cord to the switch, and the switch to the heating element and pump. Mark the wires with tape before cutting anything. Solder the relay's normally-open contacts in place of the switch, keep the machine's thermal fuse and thermostat untouched, and use heat-shrink on every mains joint.

Route the low-voltage sensor and relay-control wires through a separate grommet from the mains wires, and keep at least a few millimeters of creepage between them. Reassemble and test the relay coil with a bench supply before ever plugging the machine in.

In ESPHome, the switch entity controls the relay; an automation turns it on at 06:30 on weekdays only if the float switch reads full and the carafe temperature is below a threshold.

A second automation turns the relay off when the temperature sensor reports above 95 °C for more than a minute, treating that as "brew cycle likely finished." The Home Assistant dashboard shows reservoir status, last brew time, and a manual override. The physical rocker switch is gone, but a hardware kill switch in the form of the wall outlet remains — and that is the point.

Safety Limits the ESP32 Cannot Replace

The ESP32 adds convenience; it does not add safety certification. Mains-voltage work on an appliance voids its warranty, may violate local electrical codes, and can create shock and fire hazards if done poorly. The machine's own thermal fuse is a one-shot device that protects against runaway heating; if your relay bypasses it, you have removed the last line of defense. Keep it in the circuit.

Use a relay rated for the load, enclose all mains connections, and strain-relieve the cord.

Unattended operation deserves special caution. Remote-start brewing means the machine can run when no one is watching, and a failed float switch or a blocked outlet line can lead to overflow or dry-firing. The firmware protections above reduce the risk; a water leak sensor under the machine and a smart plug that cuts power on fault reduce it further.

If you are not comfortable working inside a mains appliance, a safer alternative is a smart plug on an unmodified brewer — it loses temperature sensing and water-level alerts but keeps every safety system the manufacturer built in.

Heat is the other limit. The ESP32 and relay module should not sit directly above the heating element or inside a sealed compartment that reaches 60 °C. Mount electronics where air moves, and keep the DS18B20's cable away from the heating element's own wiring to avoid electrical noise. If the board reboots randomly during brewing, suspect supply droop or EMI from the heater, not the firmware.

Where This Approach Fits and Where It Doesn't

Machine type ESP32 retrofit difficulty Main constraint Sensible goal
Drip brewer, mechanical switch Low Load sizing, mains safety Schedule, remote start, reservoir alert
Pod machine, physical button Moderate Pump and thermoblock timing Remote start with warm-up delay
Espresso machine, electronic board High Existing control logic, pressure Interface with board or skip
Any machine, no modifications None No sensing Smart plug scheduling only

The table reflects difficulty, not desirability. A smart plug build takes ten minutes and keeps the warranty; the ESP32 build takes a weekend and adds real sensing. Pick based on how much you value reservoir and temperature feedback versus how much risk you are willing to take with mains wiring.

For builders who want the sensing without the soldering, a middle path exists: keep the brewer stock and add an ESP32-based temperature probe and water-level sensor that report to Home Assistant, with a smart plug doing the switching. You lose direct relay control but keep full safety and gain most of the useful data. That hybrid is often the better first project, and it makes the full retrofit a second step rather than a leap.

If you do build the full version, the payoff is real: a machine that has hot water waiting when you wake up, tells you the reservoir is low before you stumble to it, and never brews into an empty carafe. The ESP32 is capable of far more processing than this needs, which is exactly why the project succeeds when the design stays simple and the safety systems stay intact.

Frequently Asked Questions

Can an ESP32 control an espresso machine's pump and pressure?

Not directly in any reliable way. Espresso pumps are usually mains-powered vibration or rotary pumps, and pressure profiling requires fast valve control and pressure feedback that a basic relay-and-sensor build cannot provide. The ESP32 can switch the pump on and off and read a pressure transducer, but the machine's own OPV and control board remain responsible for safe pressure.

Treat espresso as an advanced project and expect to interface with the existing electronics rather than replace them.

Is it safe to leave an ESP32-modified brewer unattended?

Only with layered protections: a correctly rated relay, the machine's thermal fuse left in circuit, firmware timeouts, a float switch that blocks dry starts, and ideally a leak sensor and a smart plug that can cut power. No firmware makes an unsafe wiring job safe. If you cannot verify each of those layers, do not run the machine unattended.

Do I need Home Assistant to use an ESP32 coffee machine?

No. ESPHome can run local automations and a built-in web server, and custom Arduino firmware can host its own interface. Home Assistant adds dashboards, notifications, and cross-device automation, which is convenient but optional. A standalone build with a physical button and a schedule stored on an RTC works without any hub.

What relay should I use for a 1,500-watt brewer?

At 120 volts, 1,500 watts is 12.5 amps, so a 10-amp module is undersized. Use an opto-isolated relay rated at least 15 amps at the machine's voltage, ideally with a mechanical contactor or a heavy-duty module rather than a bare blue board. At 230 volts the same wattage is about 6.5 amps, but derating and enclosure quality still matter. Always confirm against the nameplate rather than a typical figure.

Can the ESP32 read the machine's existing temperature display?

Usually not without reverse-engineering. Most brewers use a simple thermistor or bimetallic thermostat with no digital output. A DS18B20 or thermocouple added by you is more reliable than trying to tap an unknown sensor circuit, and it avoids putting the ESP32's ground reference in contact with mains-referenced circuitry.