Beverage Temperature Monitor

ECE 4180 Lab 4 - by Roy Blatt and Yarin Gurfel

Introduction

When making hot beverages, it is often difficult to get the beverages to be at a comfortable temperature for consumption. People often try to sip their drinks before the temperature has settled, causing a tongue burn. The Beverage Temperature Monitor continuously monitors the temperature of the user's beverage, and alerts the user once the beverage has reached the user's desired temperature.

Here's how it works: users insert a beverage-specialized thermometer into their drink and select their desired beverage temperature using a Bluetooth app. Once the beverage has cooled to the users' desired temperature, the users get notified via Bluetooth. Simple!


Components

Below you can see an image of the project with the following components:

  • An MBED Micro-controller (of course)
  • A DS18B20 beverage-specialized thermometer
  • A 4.7k ohm pull-up resistor
  • An RGB LED
  • And finally an Adafruit BLE.

/media/uploads/inaga/mbed.jpg


Demo

Let's take a better look at the project. Below you can see a short video demonstrating the use of the Beverage Monitor.


Code

main.cpp

#include <stdlib.h>
#include <mbed.h>
#include <math.h>
#include "DS18B20.h"
#include "OneWireDefs.h"
#include <vector>


#define THERMOMETER DS18B20
Serial myPC(USBTX, USBRX);     // serial comms over usb back to console
RawSerial  dev(p28,p27);
PwmOut R(p24);
PwmOut G(p22);
std::vector<char> TEMP;
int thetemp=0;
int powers[4]= {1,10,100,1000};
void dev_recv()
{
    thetemp=0;
    while(dev.readable())  TEMP.push_back(dev.getc());
    if (TEMP.size() >=3) {
        for (int c=TEMP.size()-2; c>=0; c--)
            thetemp = (TEMP[c]-'0')*powers[(TEMP.size()-c-2)]+ thetemp;
    }
}

int main()

{   
    dev.puts("Input your desired drink temperature:\n");
    myPC.baud(9600);
    dev.baud(9600);
    // device( crcOn, useAddress, parasitic, mbed pin )
    THERMOMETER device(true, true, false, p20);
    while (!device.initialize());    // keep calling until it works
    device.setResolution(tenBit);
    while (true) {
        dev.attach(&dev_recv, Serial::RxIrq);
        TEMP.clear();
        if (thetemp>=device.readTemperature()) {
            G=1, R=0;
            dev.puts("Your drink has cooled down and is ready!\n");
            wait(10);
            thetemp=0;
        } else G=0, R=1;
        wait(2);
    }

}


Please log in to post comments.