Software apps and online services

Hand tools and fabrication machines

Wire Strip

Screw Driver

Story

Wake up, open your phone to snooze your alarm, open up Blynk, press one button and BAM coffee starts brewing. For most Americans its not this easy. They have to walk all the way downstairs in to the kitchen or common room to start their coffee. Normally this happens after they've gotten ready for the day, which makes brewing coffee a tedious and time consuming task in a morning routine. Well not any more! With this set up your coffee will brew while you undertake the other rigorous early morning routines, so when you're ready to head out the door a warm (not scorching, but definitely not cold) cup of joe is ready to go!

If the convenient start up of a coffee pot would speed your morning routine up or be convenient for you at all, use these guidelines and the provided code to create your own Coffee Starter using Blynk.

Set-Up:

Connections made under the bottom of the Coffee Maker

The picture above shows the inner-workings of the MainStays Coffee Maker purchased at Walmart for about $9. We cut the red wire, which supplied energy to the heater in the coffee maker. A separate wire provides energy to the pump, but the circuit connects all the wires together so cutting just the red wire gives control over the whole coffee maker. Both ends of the cut red wire were then stripped, attached to longer wires and sent out of the back of the coffee maker. Then, we put a sealed temperature sensor next to the heating coil, which is connected to the second photon. The temperature sensor is used to log the temperature as well help a photon signal to a second photon to start a timer that will eventually turn off the coffee maker.

The picture above shows the two wires mentioned above attached to our two channel relay (only one channel is necessary) and the circuit used to control the relay.

The picture above shows the temperature sensor wires connected to the second photon.

The temperature probe put in the coffee maker is read using code taken off a tutorial on the particle website and sent from the photon to the cloud under the event name of "coffeetemp". This data is sent from the photon to the cloud live on the particle website, which is pictured above. Then, the data was sent from the proton, through IFTTT to a google doc, which makes the data easily accessible and graph-able. The relevant data was graphed and shown below.

Schematics

Temperature Sensor Schematic (excluding USB connection)

The picture of our actual circuit may look a little different because we extended the temperature sensor to reach under the coffee maker comfortable but this schematic is the one we used to set up our circuit.

Photon, Relay, Coffee Maker Set-up

Code

Blynk App and Photon Response to "coffeetemp2" Event

C/C++

This code connects the Blynk App to the Particle photon that is connected to the coffee maker through the relay. The code allows a button in the Blynk App to turn the D0 pin to HIGH which controls the relay completing the circuit, which supplies power to the coffee maker allowing it to start brewing. This code also allows the particle to read and respond to the cloud. Once the photon reads from the event it is subscribed to (coffetemp2), the function 'stopcoffeemaker' is run, which starts a delay to allow the coffee maker to finish the brewing process, then turns the D0 pin to LOW which flips the switch in the relay cutting off energy to the coffee maker and effectively turning it off.

// This #include statement was automatically added by the Particle IDE.#include<blynk.h>// This #include statement was automatically added by the Particle IDE.#include<blynk.h>// This #include statement was automatically added by the Spark IDE./************************************************************** * Blynk is a platform with iOS and Android apps to control * Arduino, Raspberry Pi and the likes over the Internet. * You can easily build graphic interfaces for all your * projects by simply dragging and dropping widgets. * * Downloads, docs, tutorials: http://www.blynk.cc * Blynk community: http://community.blynk.cc * Social groups: http://www.fb.com/blynkapp * http://twitter.com/blynk_app * * Blynk library is licensed under MIT license * This example code is in public domain. * ************************************************************** * * This example shows how to use Arduino Ethernet shield (W5100) * to connect your project to Blynk. * Feel free to apply it to any other example. It's simple! * **************************************************************///#include <SPI.h>//#include <Ethernet.h>//#include <BlynkSimpleEthernet.h>// You should get Auth Token in the Blynk App.// Go to the Project Settings (nut icon).charauth[]="20f71e6fb1bd426a860b53b2554bcdad";voidsetup(){Serial.begin(9600);Blynk.begin(auth);pinMode(D0,OUTPUT);Particle.subscribe("coffeetemp2",stopcoffeemaker);// You can also specify server.// For more options, see Transports/Advanced/CustomEthernet example//Blynk.begin(auth, "server.org", 8442);//Blynk.begin(auth, IPAddress(192,168,1,100), 8888);}voidloop(){Blynk.run();}voidstopcoffeemaker(constchar*event,constchar*data){if(strcmp(data,"brewing")==1){delay(600000);//delay 10 mindigitalWrite(D0,LOW);// turn pin D0 to LOW which turns off the coffee maker}}

Temperature Reading and Logging

C/C++

This code translates the input from the temperature sensor and when the temperature reading is above 0 degrees Fahrenheit the temperature reading is posted to the cloud through the event named "coffeetemp" and if the temperature reading is above 150 degrees Fahrenheit the string value "brewing" is posted to the cloud through the event named "coldtemp2".

// This #include statement was automatically added by the Particle IDE.#include<OneWire.h>OneWireds=OneWire(D4);unsignedlonglastUpdate=0;floatlastTemp;voidsetup(){Serial.begin(9600);// Set up 'power' pins, comment out if not used!pinMode(D3,OUTPUT);pinMode(D5,OUTPUT);digitalWrite(D3,LOW);digitalWrite(D5,HIGH);}// up to here, it is the same as the address acanner// we need a few more variables for this examplevoidloop(void){bytei;bytepresent=0;bytetype_s;bytedata[12];byteaddr[8];floatcelsius,fahrenheit;if(!ds.search(addr)){Serial.println("No more addresses.");Serial.println();ds.reset_search();delay(250);return;}// The order is changed a bit in this example // first the retruned address is printedSerial.print("ROM =");for(i=0;i<8;i++){Serial.write(' ');Serial.print(addr[i],HEX);}if(OneWire::crc8(addr,7)!=addr[7]){Serial.println("CRC is not valid!");return;}Serial.println();// we have a good address at this point// what kind of chip do we have?// we will set a type_s value for known types or just return// the first ROM byte indicates which chipswitch(addr[0]){case0x10:Serial.println(" Chip = DS1820/DS18S20");type_s=1;break;case0x28:Serial.println(" Chip = DS18B20");type_s=0;break;case0x22:Serial.println(" Chip = DS1822");type_s=0;break;case0x26:Serial.println(" Chip = DS2438");type_s=2;break;default:Serial.println("Unknown device type.");return;}ds.reset();// first clear the 1-wire busds.select(addr);// now select the device we just found// ds.write(0x44, 1); // tell it to start a conversion, with parasite power on at the endds.write(0x44,0);// or start conversion in powered mode (bus finishes low)// just wait a second while the conversion takes place// different chips have different conversion times, check the specs, 1 sec is worse case + 250ms// you could also communicate with other devices if you like but you would need// to already know their address to select them.delay(1000);// maybe 750ms is enough, maybe not, wait 1 sec for conversion// we might do a ds.depower() (parasite) here, but the reset will take care of it.// first make sure current values are in the scratch padpresent=ds.reset();ds.select(addr);ds.write(0xB8,0);// Recall Memory 0ds.write(0x00,0);// Recall Memory 0// now read the scratch padpresent=ds.reset();ds.select(addr);ds.write(0xBE,0);// Read Scratchpadif(type_s==2){ds.write(0x00,0);// The DS2438 needs a page# to read}Serial.print(" Data = ");Serial.print(present,HEX);Serial.print(" ");for(i=0;i<9;i++){// we need 9 bytesdata[i]=ds.read();Serial.print(data[i],HEX);Serial.print(" ");}Serial.print(" CRC=");Serial.print(OneWire::crc8(data,8),HEX);Serial.println();// Convert the data to actual temperature// because the result is a 16 bit signed integer, it should// be stored to an "int16_t" type, which is always 16 bits// even when compiled on a 32 bit processor.int16_traw=(data[1]<<8)|data[0];if(type_s==2)raw=(data[2]<<8)|data[1];bytecfg=(data[4]&0x60);switch(type_s){case1:raw=raw<<3;// 9 bit resolution defaultif(data[7]==0x10){// "count remain" gives full 12 bit resolutionraw=(raw&0xFFF0)+12-data[6];}celsius=(float)raw*0.0625;break;case0:// at lower res, the low bits are undefined, so let's zero themif(cfg==0x00)raw=raw&~7;// 9 bit resolution, 93.75 msif(cfg==0x20)raw=raw&~3;// 10 bit res, 187.5 msif(cfg==0x40)raw=raw&~1;// 11 bit res, 375 ms// default is 12 bit resolution, 750 ms conversion timecelsius=(float)raw*0.0625;break;case2:data[1]=(data[1]>>3)&0x1f;if(data[2]>127){celsius=(float)data[2]-((float)data[1]*.03125);}else{celsius=(float)data[2]+((float)data[1]*.03125);}}// remove random errorsif((((celsius<=0&&celsius>-1)&&lastTemp>5))||celsius>125){celsius=lastTemp;}fahrenheit=celsius*1.8+32.0;lastTemp=celsius;Serial.print(" Temperature = ");Serial.print(celsius);Serial.print(" Celsius, ");Serial.print(fahrenheit);Serial.println(" Fahrenheit");if(fahrenheit>0){// now that we have the readings, we can publish them to the cloudStringtemperature=String(fahrenheit);// store temp in "temperature" stringParticle.publish("coffeetemp",temperature);if(fahrenheit>150){Particle.publish("coffeetemp2","brewing");// publish to cloud}delay(10000);}}