I'm having a but of trouble making sure my project really is feasible.
What I want to archive: Control my Senseo coffee machine via internet. It boils down to simply controlling 2 buttons.
First easy solution:
- Setup a NodeJS server on my Raspberry Pi.
- I plug my Raspberry GPIOs to 2 transistors, to control the coffee machine buttons
- I can control the Raspberry GPIO directly in Javascript. For example calling http://myraspberrypi.com/makemeacoffee activates the GPIO, activates the buttons, and the coffee flows
But: I don't want to plug my raspberry to my coffee machine (I need the Pi for other purposes), and I think that decoupling the web server and the controller itself is a good idea. If tomorrow I want to monitor the temperature of my bathroom, or control a second coffee machine (using another ESP8266) I want be able to do it without rethinking the whole thing.
What I need to archive that is an ESP8266 with NodeMCU to use it as a Wi-Fi headless controller (see this link). Raspberry GPIO are no longer used (that's the point). There is only a NodeJS web server on the Pi.
Here is a quick sketch of the architecture:
Let me clarify the role of the main components:
- Raspberry Pi: Hosts the NodeJS web server
- NodeJS web server: Serves the web pages to the end user. Basically a page with a button "Make me a coffee". Behind the scene, we need to "push" the heat up the water button, wait 30 sec, then "push" the coffee button. The web server does so by sending HTTP requests to the ESP8266 (over Wi-Fi). The NodeJS server also does logging and data analysis (how many coffee did you drink this year ?)
- ESP8266: Uses NodeMCU. Its GPIOs are plugged to a transistor controlling the coffee machine buttons. I don't care about how to power the ESP8266. It runs a web server to listen to the Raspberry Pi requests and do actions on GPIOs accordingly.
Is this architecture feasible? Is this architecture flexible?
EDIT, to answer Sean Houlihane (spoiler to keep the post relatively short):
I'm not 100% sure about this, but a transistor is seems to be enough. The coffee machine switch is working on low voltage (3,3V) and the ESP8266 won't share the ground with the coffee machine.
About the temperature sensing, and the water level control, the Senseo coffee machine has this built-in. Typical use : Press the center button to launch the heat up process, choose your coffee size by pressing the "single" or "double" button. Once the heat up process ends, the coffee starts flowing. If there is not enough water, it ends and a LED blinks.
The progress I expect :
- Version 1.0 will be "Just run the coffee machine, I am sure it's ready". I control the single cup button and the heat up button.
Version 2.0 will be "Run the machine and give me feedback" I had another ESP8266, plugged to the feedback LED (So that I can know when it's heating up and when it's out of water) and another one to a scale to make sure the cup is there before running the coffee machine. I might also add an alert when the coffee machine is ran to tell the user to change the pod.
Version 3.0 will be to find a way to tell if the pod has been changed, by tracking the opening of the mechanism with some kind of switch. But this is out of the scope of my project at the moment.