Tip
If you are searching for information or a guide to help build your rig, read the README in the ArduinoTemplate directory :).
CoffeeAlarm is a DIY alarm app for a coffee machine equipped with an ESP32 and a servo motor. Set an alarm on your Android phone, let the app discover the ESP32 over your local Wi-Fi network, and trigger your coffee machine button remotely at your scheduled time.
Safety first: This project physically operates an appliance. Use a low-voltage, mechanically isolated button pusher, keep electronics away from water and heat, and test the servo with the coffee machine powered off. Never leave the rig unattended during commissioning.
- CoffeeAlarm stores alarms locally on the phone with AsyncStorage.
- The app schedules the alarm using Android alarm/notification services and can play an alarm sound in the background.
- On the local network, the app scans for an HTTP service advertised through mDNS/Zeroconf. The ESP32 should advertise itself as
alarm-esp32oralarm-espresso. - After discovery, the app communicates with the ESP32 using its resolved local address:
GET /statuschecks connectivity.POST /alarmssends or updates an alarm as JSON.DELETE /alarms/:idremoves an alarm from the ESP32.
- At the configured time, the ESP32 activates the servo long enough to press the coffee machine button, then returns it to its resting position.
The ESP32 firmware is a separate part of the rig. It must provide the HTTP endpoints above, advertise one of the expected mDNS names, and implement the servo motion and alarm timing. This repository contains only the mobile application.
Typical parts:
- ESP32 development board
- Small positional servo (for example, an SG90 or equivalent)
- Servo bracket, arm, or 3D-printed mount aligned with the coffee machine button
- Separate regulated 5 V supply suitable for the servo current
- Jumper wires, breadboard or terminal block, and a common ground
- Coffee machine with a physical button that can be pressed mechanically
- Connect the servo signal wire to a PWM-capable ESP32 GPIO selected by your firmware.
- Power the servo from an appropriate external 5 V supply; do not assume the ESP32 3.3 V pin can supply the servo.
- Connect the external supply ground to ESP32 ground.
- Keep the servo power wiring short and provide adequate current capacity. A servo can cause voltage dips and ESP32 resets when it starts moving.
- Start with conservative servo angles and travel. Adjust the mount and software limits so the arm cannot jam or continuously press the button.
Your firmware should:
- Connect the ESP32 to the same Wi-Fi network as the Android phone.
- Start an HTTP server on the advertised service port.
- Advertise
_http._tcpover mDNS with the instance namealarm-esp32oralarm-espresso. - Return a successful response from
GET /status. - Accept the alarm object from
POST /alarmsand retain enabled schedules. - Remove an alarm on
DELETE /alarms/:id. - Trigger the servo only once for each due alarm, with a configurable press and release position.
- Handle Wi-Fi loss, invalid JSON, duplicate alarm IDs, and reboot persistence gracefully.
The app sends alarm data in this shape:
{
"id": "1712345678901",
"time": "07:30",
"label": "Weekday coffee",
"enabled": true,
"days": ["Monday", "Tuesday"],
"soundId": "beep"
}The ESP32 firmware includes configurable settings for Wi-Fi, mDNS service advertising, GPIO pin selection, and servo timing. Modify these settings in your firmware code to match your hardware setup:
- Wi-Fi SSID and password: Configure your network credentials.
- mDNS service name: Choose between
alarm-esp32oralarm-espresso, or define a custom name (ensure the app recognizes it). - GPIO pin: Select the PWM-capable pin connected to your servo signal wire.
- Servo angles: Customize the press (activate) and release (rest) positions for your button.
- Activation duration: Set how long the servo holds the pressed position (typically 200–500 ms).
The firmware repository includes example template implementations for different actuator types.
motor_actuator.cpp(safest, easiest): Uses a standard servo motor (e.g., SG90) to physically press the button. This is the recommended and safest approach for most coffee machines.electrical_actuator.cpp: Uses a relay or solenoid to trigger an electrical pulse on the coffee machine button circuit.⚠️ More dangerous: requires knowledge of your machine's electrical schematic, isolation from high voltage, and proper relay sizing. Use only if you fully understand the electrical circuit and can ensure safe isolation.⚠️ Untested
Choose the template that matches your hardware, review the implementation, and test thoroughly before deploying to your coffee machine.
This is an Expo React Native project. The current project uses Expo SDK 57 and React Native 0.86.
- Node.js and npm
- Android Studio/Android SDK for a local Android build, or an Expo/EAS build environment
- Android phone and ESP32 on the same Wi-Fi network
Install dependencies and start the development server:
npm install
npx expo startFor a local Android development build:
npx expo run:androidThe app requests network discovery/network access, notifications, wake-lock, and exact-alarm capabilities needed for discovery and reliable alarms. Android may still require you to grant notification and nearby-device permissions at runtime.
A prebuilt APK is available from the repository's configured Expo artifact link:
To install it on an Android phone:
- Download the
.apkon the phone, or download it to a computer and transfer it to the phone. - Open the APK with the Files/Downloads app.
- If Android blocks the installation, open the prompt or go to Settings → Install unknown apps and allow the app you used to open the APK (for example, Files or Chrome).
- Confirm Install, then open CoffeeAlarm.
- Grant notification, nearby/local-network, and alarm-related permissions when prompted. If exact alarms are not enabled automatically, enable CoffeeAlarm under the Android alarm/reminder or exact-alarm settings.
- Put the phone and ESP32 on the same 2.4 GHz Wi-Fi network if your access point separates bands.
Only install APKs you built yourself or obtained from a source you trust. An APK distributed outside Google Play is not automatically verified by Google Play Protect; review the build source and commit history before installing.
For a reproducible release build, configure EAS for this Expo project and build an installable Android APK. An EAS profile must produce an APK rather than an AAB for direct sideloading. For example:
npm install
npx eas build:configure
npx eas build --platform android --profile previewDownload the resulting APK from the EAS build page, then follow the sideload steps above. The exact EAS profile and credentials are intentionally left to the maintainer; do not commit signing keys or secrets to the repository.
- Mount the servo so its arm lines up with the coffee machine button.
- Test the servo at low force and confirm it returns without holding the button down.
- Flash and configure the ESP32 firmware, then verify
GET /statusresponds. - Install and launch CoffeeAlarm.
- Tap Find ESP32, select/verify the discovered device, and tap Test Connection.
- Create an alarm for a few minutes in the future and select at least one day.
- Confirm the alarm appears on both the phone and ESP32, then supervise the first activation.
- ESP32 is not found: confirm both devices are on the same LAN, Android local-network/Wi-Fi permissions are enabled, mDNS is running, and the service name is exactly
alarm-esp32oralarm-espresso. - Connection test fails: browse to
http://<esp32-ip>:<port>/statusfrom a device on the same network and check the ESP32 server logs. - Alarm is saved but not synchronized: the app keeps the alarm locally when no ESP32 is connected. Reconnect, then update or recreate the alarm.
- Alarm does not fire: disable battery optimization for CoffeeAlarm, allow notifications and exact alarms, and check that the alarm is enabled and has selected days.
- ESP32 resets when the servo moves: use a separate regulated servo supply, share grounds, and add suitable bulk capacitance near the servo supply.
- Button is not pressed reliably: reduce the servo angle, reposition the bracket, and use a slower or staged motion rather than increasing force.
This project is licensed under the MIT License.