Most of us know what it is to be in a rush in the morning and don't have time to wait for the machine to get hot. In this tutorial I will show you how to make automatic coffee with Android and Arduino.
At the end of the tutorial you will have an Android app working in Bluetooth to make a small or large coffee and you can even send commands by voice recognition!
Here we have the most complicated part. I will advise you to check the documentation of your machine. For the one I use, you just need to detach the bottom with something tiny like a screwdriver.
SolderingNow that the machine is open we are going to solder 2 cables under each button and connect it to the relay. If you use an old coffee maker with one button it's the same process just use one channel relay.
Arduino SideThe connections between the relay and Arduino are:
- IN1: None
- IN2: PIN 11 small coffee
- IN3: PIN 10 turn on machine
- IN4: PIN 9 Big coffee
The Bluetooth module and Arduino:
- VCC= 5v
- GND=GND
- TXD=RX
- RXD=TX
The code is simple. It initiates a Bluetooth connection and then if you send value 1 you make small coffee, value 2 is a big coffee.
When you upload the code disconnect the Bluetooth (remove the 5V wire), otherwise you will get an error. For some reason when I put HIGH, it turns off the relay, so if you have problems just try to inverse HIGH and LOW.
Then a button is pressed to make the coffee and the machine turns off. Check the code comment:
char junk;
String inputString="";
void setup() // run once, when the sketch starts
{
Serial.begin(9600); // set the baud rate to 9600, same should be of your Serial Monitor
pinMode(10, OUTPUT);
digitalWrite(10,HIGH);
pinMode(9, OUTPUT);
digitalWrite(9,HIGH);
pinMode(11, OUTPUT);
digitalWrite(11,HIGH);
}
void loop()
{
if(Serial.available()){
while(Serial.available())
{
char inChar = (char)Serial.read(); //read the input
inputString += inChar; //make a string of the characters coming on serial
}
Serial.println(inputString);
while (Serial.available() > 0)
{ junk = Serial.read() ; } // clear the serial buffer
if(inputString == "1"){ //in case of '1'
digitalWrite(10, LOW); //turn on machine
delay(500);
digitalWrite(10, HIGH);
delay(120000); //time to heat up 2mn (milli)
digitalWrite(9, LOW);
delay(500);
digitalWrite(9, HIGH); //big coffee
delay(30000); //coffee comes out
digitalWrite(10, LOW); //turn off machine
delay(500);
digitalWrite(10, HIGH);
}else if(inputString == "2"){ //incase of '2'
digitalWrite(10, LOW); //turn on machine
delay(500);
digitalWrite(10, HIGH);
delay(120000); //time to heat up 2mn (milli)
digitalWrite(11, LOW);
delay(500);
digitalWrite(11, HIGH); //small coffee
delay(30000); //coffee comes out
digitalWrite(10, LOW); //turn off machine
delay(500);
digitalWrite(10, HIGH);
}
inputString = "";
}
}
APP Inventor AndroidIn order to control our coffee machine with our phone, we will create an app with MIT app inventor. The only requirement is a Gmail account. You can upload my app and modify it in the app inventor. It is very easy to use but I will advise you to check some tutorials before.
I added voice recognition so if you say "coffee" it will give you a big coffee. To be able to install the app, you have to go to your phone setting (in security) and allow unknown sources.
Important: To send value from the Bluetooth I used the object "send text
" so it will send the number 1 or 2.
You can also use the "send byte number
" but it uses ASCII so in order to send 1 to the Arduino you need to send the value 49. Pay attention to the difference.
We are done!
We can now control our coffee machine with Bluetooth. I am not very good in design so forgive me my coffee machine looks bad but you can easily make a small box for the Arduino and the relay to fit properly.
In the future I will update the tutorial with a conveyor belt. It could be nice to be sure the cup is not missing!
Let me know if you have any idea on improvements.
Comments