Keep your coffee at the best codition

Made by Wei-Hsun Chen

Created: January 28th, 2015



I am a coffeeholic who really cannot live without coffee for a day and care about keeping my coffee jar in the right temperature in order to keep my coffee bean in the best condition. COFFEHOLIC provides you to track your coffee in real time, and alarms you when you should add coffee beam. So COFFEEHOLIC updates the temperature every few seconds and show the specific temperature in the cloud variables. Also the "coffeealarm" tells you "add" and "good" so that you don't have to worry you don't have coffee to drink today!


The logic process is like: define whether the coffee jar has coffee(force sensor) for 3 seconds --> if yes then turn off the red light --> keep updating data every 3seconds (when data is updated the green light will blink) --> temperature shows "number" and coffeestatus shows "add" or "good" -->repeat

Firstly I drew a rough sketch to clarify the logic and the big structure of my code. I tweaked a little bit from temperature sensor code in the github and added some for loops and if statements for LEDs. The problem I met is how to rewrite the word characters into variables because I found out that the status always showed "add" no matter what, so I spent some time to figure out to use array (thanks to the help from my classmate).

Material Used

* Spark

* breadboard x1

* Temperature sensor x1

* Force sensor x1

* 10nF capacitor x1

* 1k resistor x2

* 10k resistor x1

* jumper x alot

Next Steps

I am planning to add photosensor to track how many times you drink coffee today. Also can combined with special sensor to track humidity is available. In the future I also can make Coffeeholic send picture to you when you are run out of coffee!

int redPin = D0;
int greenPin = D1;
// Define a pin that we'll place the FSR on
// Remember to add a 10K Ohm pull-down resistor too.
int fsrPin = A0;
// Create a variable to hold the FSR reading
int fsrReading = 0;
// Create a variable to store the force number.
int force = 0;
// Define the Pin the Temperature sensor is on
int tempPin = A1;

char coffee[4];
// Create a variable that will store the temperature value
double temperature = 0.0;

void setup()

   Spark.variable("temperature", &temperature, DOUBLE);
   Spark.variable("coffeealarm", coffee, STRING);
   // Configure the pins to be outputs
   pinMode(redPin, OUTPUT);
   pinMode(greenPin, OUTPUT);
   // configure A1 to be temp input
   pinMode(tempPin, INPUT);
   // Initialize both the LEDs to be OFF
   digitalWrite(redPin, LOW);
   digitalWrite(greenPin, LOW);

void loop()
   //hold FSR for 3 seconds first then blink red LED for 3 seconds

  fsrReading = analogRead(fsrPin);

  // Map this value into the PWM range (0-255)
  // and store as the led brightness
  force = map(fsrReading, 0, 4095, 0, 255);

  //wait 3 seconds
  delay( 3000 );
  //check force
  if(force > 5 )
    strcpy(coffee, "good");
    turnoffLED( D0 );
    turnonLED( D1 );

    strcpy(coffee, "add ");
    turnoffLED( D1 );
    turnonLED( D0 );

  // read temp value and store it as reading
  int reading = analogRead(tempPin);
  // The returned value from the Core is going to be in the range from 0 to 4095
  // Calculate the voltage from the sensor reading
  double voltage = (reading * 3.3) / 4095.0;
  // Calculate the temperature and update our static variable
  temperature = (voltage - 0.5) * 100;

  blinkLED(D1,3); //blick 3 times to show the data is updated


//turnon LED
void turnonLED(int pinNumber)

 digitalWrite( pinNumber, HIGH );


//turnoff LED
void turnoffLED(int pinNumber)

  digitalWrite(pinNumber, LOW);


//blink LED for specific times

void blinkLED( int pinNumber, int times )


 for( int i = 0 ; i < times ; i++ )


 digitalWrite( pinNumber, HIGH );

 delay( 500 );

 digitalWrite( pinNumber, LOW );

 delay( 500 );



void checkFSR()
  fsrReading = analogRead(fsrPin);

  // Map this value into the PWM range (0-255)
  // and store as force
  force = map(fsrReading, 0, 4095, 0, 255);

  //wait 3 seconds
  if(force > 1 )
  else if(force < 1);
Click to Expand