The inspiration for this device came about from the distressing amount of tea that I would make for my wife which would end up untouched and stone cold. We drink a lot of tea, but the problem is that it is far too hot to drink immediately after it is brewed - usually getting to the ideal drinking temperature in about 10-15 mins. Unfortunately it is often forgotten about and only found some time later, lukewarm and insipid.

The simplest solution to this problem might be some kind of timer, but the tea may cool at different rates depending on the ambient temperature, the size, shape and material of the mug and the amount of milk added. What is really needed is a way to monitor the temperature of the tea and initiate an alert when the temperature drops below a calibrated threshold. There didn't seem to be any products available to achieve this in a convenient and usable package, so I decided to try and make one - and use it as an excuse to learn about microcontrolers and the ESP8266. There are a few other descriptions online of similar devices that people have prototyped, but none of them were quite what I wanted. These are the features that I wanted my design to incorporate:

I initially experimented with monitoring the temperature by placing the cup on an aluminium disc attached to a thermocouple, but this was unreliable as the thermal conductivity between the cup and the disc was very poor. I eventually decided to use a non-contact infra-red thermopile thermometer to directly measure the cup temperature: this proved to be very accurate and instantaneous, and the component I used (the MLX90615) can be bought for less than £4 ($5).

The final design is built around an Arduino Pro Mini (clone) and ESP8266-01 module. Everything is powered by a 1200mAh Li-ion battery and a 3.3V LDO regulator, connected to a USB lithium charging board. The Arduino is connected to the MLX90615 thermopile via an I2C interface, and the ESP8266 via UART serial (using AT commands). Also connected to the Arduino is an RGB LED module (that indicates the temperature), piezo buzzer, battery voltage monitor and status LEDs. For the enclosure I used a USB cup warmer/hub which I gutted – this was perfect as it was the right shape (for a cup), had USB ports (for charging), an on/off switch and I could just about fit everything in it. I removed the thin metal disc (that the cup sits on) and replaced it with a transparent acrylic disc so you can see everything inside and the cup can be illuminated. In total I spent about £10 on components (~$15).

When the device is first turned on, it tries to connect to the AP stored in the ESP module's flash. If this fails, the ESP is put into AP mode and a status LED flashes inviting the user to send a new SSID and password via a formatted HTTP request to the ESP with a smartphone.

When a hot cup is placed on the device, the temperature is sampled over several seconds to determine if it is stable. Then the device enters an active mode: the cup is illuminated by the RGB LED with a color corresponding to its temperature (red for hot, blue for cold) and the cup temperature, the ambient (device) temperature, the threshold temperature and the battery voltage is posted to a ThingSpeak channel every 30 seconds. This in turn is monitored by a freeboard.io dashboard that can be viewed on a smartphone. When the cup temperature drops below a set threshold (stored in the Arduino's EEPROM) an SMS is sent to the user via ThingHTTP and a Twilio account, and an audible alarm is sounded (the alarm is cancelled if the cup is picked up). If the tea is allowed to go tepid (below 30 C) it will post a tweet about it (via ThingTweet) to shame the user (my wife) into proper tea drinking habits.

Finally, I wanted to have a way of allowing the user to set their ideal tea drinking temperature (the alarm threshold). This could have been done with some extra buttons or over WiFi, but that wouldn't be very interesting. So instead I came up with the idea of programming the device via the existing input (the thermometer) using just hot and cold objects – something which as far as I know is completely unique. To enter the temperature programming mode, a cold object (< 0 C, like an ice cube or some frozen food) is held above the device for 3 s. Then, at one second intervals the object temperature is sampled: if it is below 0 C, the threshold temperature is decreased by 1 C, if it is above 50 C (by switching to a hot cup) the threshold temperature is increased by 1 C. The power of ice and fire!