#IoT…or should I say #IoTea?

The Texting Tea Pot

or How I Spent My Winter Vacation

I have a problem. It’s a small, first-world problem to be sure, but a problem nonetheless. You see, I’m often the first one up in my house and I want my cup of tea. But the timer I usually set (on our microwave) to alert me when the tea is done steeping is loud enough to wake my wife. I can’t just replace it with another, quieter timer because I’m always waiting for the tea in an adjacent room. I often attempt to not use any timer, which (as I’m easily distractable in the other room) leads to oversteeped or forgotten tea. I can’t tell you how many pots of tea I’ve thrown away, but it’s an absurdly wasteful amount — at least a third of the pots I brew.

My solution is to have the tea pot text me when the tea is ready. I usually have my phone with me and, if not, I’m usually on my laptop, which now can receive forwarded SMS as iMessages right on my desktop. None of these messages will wake my wife and will hopefully lead to fewer tossed pots of skunky tea.

There were a couple of things I wanted to consider as I thought about doing this. One is that I wanted to continue using my existing tea pot. It’s a beautiful Japanese-style cast iron pot that my parents gave me for my birthday several years ago. I didn’t really want its beauty to be marred by sticking a piece of electronics on it, which likely wouldn’t work anyway because it gets incredibly hot when filled with boiling water and because I have to take it to the sink to rinse it out. (Water and electronics don’t usually mix well.) I didn’t want to be unplugging and replugging my tea pot in to take it to the sink either. The tea ritual is — and should be — non-technical. Or at least feel non-technical, since I am, after all, introducing technology into the tea process. I wanted to keep the ritual intact as much as I could.

That also meant I didn’t want to be pressing any buttons. Even though, yes, I press buttons now on my microwave to set a timer, it always felt bleh and intrusive to tea making. I wanted it to be magic, an enchanted object, to just work. I’m also fortunate (some would say deprived) in that I almost exclusively drink black tea, most of which has roughly the same timing (~4 minutes), so I didn’t have any timing settings to fiddle with. After four minutes, just tell me the tea is ready, pot. Don’t make me do anything extraneous.

I also didn’t want anything electronics-looking sitting on my kitchen counter. I wanted it to blend in, be unnoticeable, be a piece of invisible technology. It shouldn’t draw any attention to itself or require any maintenance.

With those constraints and principles in mind, I tried to figure out how it might work. The first thing I considered was what, if I wasn’t going to manually push a button, triggered the whole microinteraction of texting me when it’s ready. I couldn’t use a proximity sensor, because the kitchen gets a lot of traffic and people just standing near the counter would cause many false positives. The lid of the iron pot makes a really distinctive click when put on, so I pondered using that as the trigger, but it would probably have to be a pretty sensitive sensor to pick up that distinct sound in the kitchen, even in the mornings when it’s dead quiet. Too much of a chance of false positives again.

The solution I settled on was temperature. When the tea pot is filled with boiling water, its temperature rises distinctly: far above that of human body temperature, so the chance of false positives is small, unless someone sits a very hot dish near the sensor, which is unlikely for where my tea pot sits on my counter. (One of the beauties of only designing for oneself: just one well-known context to deal with. I would’ve had to add more code to adjust for this otherwise.)

Since I didn’t want the sensor on the tea pot itself, I needed a sensor that could measure temperature from a short distance. Since I was using Arduino for a platform (mostly because it’s the one I’m familiar with), I chose this contactless infrared temperature sensor from Adafruit, which works well with dark metal objects and has a simple, accompanying Arduino library. I followed the instructions, did a little soldering, put it on a tiny breadboard, and had it up and running in about an hour, getting an LED to turn on when I held my hand a few inches over the sensor. I found out that the human hand was about 26C and the hot tea pot about 32C in sensor readings from a few inches away. As it turned out, this was the easy part.

I needed my solution to be able to send a text, and the only way I could figure out how to do that was by hooking the Arduino up to the internet and hoping I could find a service that would let me do that. I wanted to use an Arduino Yun for this project since it has built-in wifi, but after many, many fruitless hours (including a complete reinstall of its software) trying to get it onto my flat’s wifi network, I gave up. Luckily, I had an Electric Imp and an Arduino Shield for it, so I used that instead. It would turn out to be a very fortunate decision.

Arduino Uno, Electric Imp Shield, and the temperature sensor.

Getting the Imp hooked up to my wifi network was pretty trivial using BlinkUp and my iPhone. But, n00b that I am, I had no idea how to get the Aduino to talk to the Imp. All I really needed it to say was, “Hey, the tea is ready, send a text!” but I was baffled how to do that. I begged coding proficient friends for help and they gently pushed me to this tutorial. Which, over two days, I tore apart line by line to figure out how it worked, then stripped out anything I didn’t need. I finally got the Arduino to pass a character to the Imp.

You should know (or probably realize by now) that I’m a lousy coder. I find it extremely difficult to think through all the programming logic, especially any nested logic (e.g. If this function is going on, and this is happening inside it, what are the implications? etc.). I can literally feel it pushing against the limits of my IQ. So how I code turns out to be something like this:

  1. Steal code.
  2. Break it. (Sometimes on purpose, mostly by accident.)
  3. Try to figure out why it’s broken.
  4. Fix. (?)
  5. Cross fingers.
  6. Repeat.

The phrase “Knowing enough to be dangerous” is applicable here.

As it turns out, Electric Imp works really well with Twilio, an internet-based text and voice communication service. I signed up for a developer account, gave them $20, and got use of a phone number for texts to come in from. I added my Twilio account info to the Imp-provided Twilio code, and voila, I could get texts from an internet connected device. I made a Contact on my phone for Tea Pot (including a picture of said pot) and added the Twilio phone number to it. So now I could get texts from Tea Pot.

After several days of code wrangling, I decided it was working well enough for a field test with an actual pot of tea. Just as no plan of attack survives contact with the enemy, so too does no prototype remain unscathed by actual use. When I tried using this hunk of sensor and code with a real pot of tea, a few things happened. The most catastrophic was timing. Tea would steep for a few seconds then send me a text. I started to get a dozen texts in the space of a minute as I, like Mickey Mouse in Fantasia with the enchanted brooms, frantically tried to shut everything off.

Crap coder that I was, I had been using Arduino’s delay() function for timing. A few Google searches later informed me that I was an idiot and should have been using Millis() instead. So I spent a day trying to swap out the simple delay() for the much more complicated millis(). And for actual programmers reading this, yes, I’m sure millis() and its accompanying rules is trivial to you. But for me, it was a nightmare. I had the overall timer (check to see if the pot is hot) and within that timer, the steeping timer (brew the tea for four minutes). I couldn’t get anything to run properly. I must have rewritten most of the program code five times before throwing up my hands in despair. I almost gave up the whole project here.

But then I remembered I also had the Electric Imp to work with, and it has a very congenial sleep() function, that’s as simple as the Arduino delay() but (seemingly) without any of the drawbacks. So I moved all the brewing timing to the Imp, keeping the general Millis() timer on the Arduino. So that fixed that.

The second problem I encountered was even after I poured the steeped tea, the pot was often still warm enough to trigger the call to the Imp and thus send me multiple text messages for the same pot of tea. I had to fix this also via the temperature check. I noticed wild fluctuations in temperature happened when the pot was picked up to pour out the tea. I had the Arduino check for those fluctuations and if it detected them, realize it had finished brewing and not trigger the Imp (again).

The proof-of-concept prototype

The code solid (finally), I turned to the shell. As I noted, I didn’t want to see the technology making all this happen. Who wants to see a raw Arduino with shields sitting on their kitchen counter? Very few, I’d wager.

My seemingly brilliant idea was to hide the Arduino et al inside a tea tin, ergo disguising it in a thematically appropriate manner. After all, my counter is usually littered with loose leaf tea tins anyway, why not repurpose one? I guessed that the Arduino and shields would all fit inside one of my old Peet’s tea tins. And it did. But not the Arduino and the plug. So it fit perfectly…just as long as I didn’t want it to have power. I spent about an hour playing Ship in a Bottle trying to get it to all fit nicely without any luck.

After taking the shield apart and putting them back together again, the Imp stopped connecting to my wifi network. I cried. Real tears. And I don’t cry very often. It was a power issue (as in the Imp not getting enough), even though the day before, it ran trouble free with that same power cord and setup. The Imp needed more power — again, even though the day before it was perfectly fine. Because hardware. Two trips to Radio Shack later, it was fixed.

Back to the casing. Since the Peet’s tea tin didn’t work, I went to three different grocery stores to find a slightly bigger tea tin. I got Harney & Sons tea tin that fit everything inside. I made a hole in the back via a hammer, nail, and awl and put the power cord with a right-angle connector through the hole. After making sure the Arduino and shield would all fit, I tried to measure where the sensor inside fell using X and Y coordinates. Then I carefully made a hole in the front at that spot. I didn’t make the hole too big because I didn’t want it to be noticeable. But it was really difficult to get the tiny hole to line up with the tiny sensor. Especially with my peasant hands. Just to get the Arduino and shields to be vaguely in the location inside the tin was a challenge. I needed something that would help position the electronics…but wouldn’t catch on fire. My wife had the idea to use a big stone or two positioned around the electronics, and that’s what I did. But still: no luck. So the hole became bigger and, alas, slightly more noticeable.

Inside the tea tin

Even with the bigger hole, it was a challenge to get everything to line up. I went through at least a dozen fake pots of tea trying to get the sensor to just “see” the pot. I felt like a stop-motion animator making a tiny adjustment then doing it again: pour hot water; wait to see if the Imp’s red LED lit up (my signal the sensor had worked and passed a message to the Imp); rinse the now hot pot in cold water to cool it down again, then refill it with hot water. Over and over and over. Until finally, it worked. I didn’t dare touch it after that.

One last surprise: When I finally thought I was done and put the lid on the tea tin, I somehow forgot that tea tins are meant to be sealed. Tightly. To let no air in or escape. So the whole apparatus got really hot and basically started calling for help via texting me every four minutes claiming tea was ready. Punching some holes for ventilation in the top and back seemed to fix the issue.

Hidden in plain sight

In the end: success. (Sort of.) I pour the hot water, walk away, and about four minutes later, a text arrives, telling me my tea is done. But it’s still far more delicate than I’d like. If it got knocked to one side, I would hate to recalibrate the hole/sensor again.

Is it solving world hunger? No. But maybe someone reading this will think up other, better, more universal uses for something like this. Or at least learn something from my mistakes, the biggest of which was thinking this would take a few days. I was off by something like a magnitude of ten on that estimation.

All growth is painful, and at times, this project certainly was. But I stepped out of my comfort zone — way out — and I suppose that’s something. And that’s what I did on my winter vacation, 2014.