Sensors
Tea temperature coaster
Stand a cup of tea or coffee on it. It reads the cup's temperature without touching it and beeps when the drink is cool enough to sip.
- Hard
- about 60 min
- ESP32-C3
- 8 parts
- 10 wires
- 61 lines of code
ESP32 packs are built on real parts: the simulator runs Arduino Uno circuits only.
Idea
Everything warm gives off infrared light, and the sensor measures it. The hard part is aiming: the sensor sees a wide cone, so it must sit close under the cup.
Before you start
Hot drinks scald. An adult pours and carries the cup, and the electronics stay dry under the coaster's top plate.
What you learn
Two I2C parts sharing the same two wires, and remembering a past state (it was hot) to act once.
How it works
input
MLX90614
decides
ESP32-C3
output
OLED 0.91 in
Buzzer
Powered with 5 V through the board's USB-C port.
A reference design. The sketch is compiled with the real ESP32 toolchain, and its pins are checked against the wiring table automatically. It has not yet been built and tested on real parts by us, so wire it on the bench and run the checks before you build it into a case. Real modules vary: follow the labels printed on yours, not their position in the picture.
Parts
0 of 8 ready
No prices here: they change by shop and by week. Buy each part by its name and the note beside it.
You also need
A computer with Arduino IDE 2 installed (free)
3D wiring
One jumper per step, with the USB cable unplugged. Several wires may share 3V3, 5V or GND: the expansion board or breadboard gives each its own pin.
Step 0 of 10
Lay out the parts
Seat the board on its expansion board or breadboard and lay the modules out round it. Nothing is connected yet.
All connections
tea-coaster.ino
// Tea temperature coaster
// Reads the bottom of the cup without touching it and beeps once when the
// drink has cooled enough to sip.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_MLX90614.h>
const int PIN_MLX_SDA = 6;
const int PIN_MLX_SCL = 7;
const int PIN_OLED_SDA = 6;
const int PIN_OLED_SCL = 7;
const int PIN_BUZZER_POS = 10;
const float TOO_HOT_C = 65.0; // above this: wait
const float READY_C = 58.0; // at or below this: ready to drink
const float NO_CUP_C = 35.0; // below this there is no hot cup on the coaster
Adafruit_SSD1306 oled(128, 32, &Wire, -1);
Adafruit_MLX90614 mlx;
bool wasHot = false;
void setup() {
pinMode(PIN_BUZZER_POS, OUTPUT);
Wire.begin(PIN_OLED_SDA, PIN_OLED_SCL);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
oled.setTextColor(SSD1306_WHITE);
mlx.begin(MLX90614_I2CADDR, &Wire);
}
void loop() {
float cup = mlx.readObjectTempC();
oled.clearDisplay();
oled.setTextSize(3);
oled.setCursor(0, 4);
if (cup < NO_CUP_C) {
oled.setTextSize(2);
oled.setCursor(0, 8);
oled.print("No cup");
wasHot = false;
} else {
oled.print(cup, 0);
oled.setTextSize(1);
oled.print(" C ");
oled.print(cup > TOO_HOT_C ? "HOT" : cup > READY_C ? "wait" : "ready");
}
oled.display();
if (cup > TOO_HOT_C) wasHot = true;
if (wasHot && cup >= NO_CUP_C && cup <= READY_C) {
// it was hot and has now cooled: three rising notes, once
tone(PIN_BUZZER_POS, 880, 120);
delay(160);
tone(PIN_BUZZER_POS, 1100, 120);
delay(160);
tone(PIN_BUZZER_POS, 1320, 200);
wasHot = false;
}
delay(500);
}
Libraries
- Adafruit GFX Library: install it from Sketch > Include Library > Manage Libraries.
- Adafruit SSD1306: install it from Sketch > Include Library > Manage Libraries.
- Adafruit MLX90614 Library: install it from Sketch > Include Library > Manage Libraries.
Uploading
First time with an ESP32: in Arduino IDE open Boards Manager, search “esp32” and install “esp32 by Espressif Systems”.
- Open the sketch in Arduino IDE.
- Plug the board in with the USB-C cable.
- Tools > Board > ESP32C3 Dev Module (USB CDC On Boot: Enabled), then Tools > Port and choose the board's port.
- Press Upload (the arrow). Wait for “Done uploading”.