With some initial ideas about the UI and the functionality that I want to have in my espresso machine, it’s time to decide on an architecture. The Mac Digital won’t be a single device. It will rely on several devices to function, some of which might not even be on the machine. Before we dive into the architectural details, let me add a few requirements to my ever growing wish list for the machine:
- I’d like to be able to control my espresso machine from my home automation system. It needs to be able to turn on and turn off remotely (I use a Z-Wave wall plug for this now, that I want to free up for future use).
- I’d like to control my espresso machine from my phone in addition to the tablet.
- I want the recipes to sync somehow so that every app has all the recipes, whenever they are connected to the home network.
- Ideally the device would work without my home network as well.
- The firmware should be remotely upgradable, so that I can fix bugs away from the machine.
As mentioned in my hardware post I’ve bought an Arduino Mega and an esp8266 board. The Arduino will handle all low level functions of the espresso machine and the esp8266 will provide it with modern connectivity over WiFi. To make use of both devices and to try and satisfy the requirements above, I’ve come to the following structural diagram:
The tablet will use the MQTT protocol to communicate with the ESP8266. Both connect to an MQTT broker (Mosquitto) that lives on my home server. My home automation system (OpenHAB) can connect to the MQTT broker. This is vital as my espresso machine is set to turn on (and preheat) when I go into the shower in the morning (it’s connected to the light switch). By the time I’m done with my morning routine the machine is ready to use. I want to preserve this functionality.
The Arduino uses a serial connection to talk to the ESP8266 and exchanges AT commands with it. I’ll need to devise an AT command set for this. I’ll also have to come up with a set of topics and messages for MQTT.
Whenever MQTT or Wifi is unavailable, I’ll have a backup serial line between the Arduino and the tablet to communicate the AT commands directly. This provides a fallback in case the WiFi is out. It might provide a challenge to find a tablet + cable that will allow charging and serial communication to the tablet at the same time. In that case it might be replaced with a Bluetooth shield or something.
Extra phones can connect to the MQTT broker as well to control the espresso machine. I’ll have to find a way to make sure that only one app is controlling the machine at a time.
For the coffee recipes and photos I’ll use an HTTP Server. I’ll implement some sort of synchronization mechanism and use local storage on the tablet so that the machine can make coffee standalone without any internet connection.
All in all a lot of moving parts and a lot of work to get it working together. I’ll end up with four pieces of software:
- The tablet / smartphone app.
- The firmware for the ESP8266. I might get away with using esp-link as it seems to support all the functionality that I need.
- The firmware for the Arduino.
- The web server for the recipes.
As I’m one of the contributors to Mobile Blazor Bindings I’ll be using Blazor, C#, HTML and CSS for the tablet app. The web server will run asp.net core and I’ll be using C# to program it. The Arduino firmware will be written using the C programming language.
The next post will probably describe the architecture of the tablet app in more detail. Stay tuned.