Home

WiFi Coffee Pot

On Youtube (writeup below):

On GitHub:

The first clip was recorded on 7/3/2022 and the last on 8/23, so the whole project took about seven weeks. Let’s talk about it.

Phase 1: pre-contemplation. I joke about this idea, not really imagining that I will actually do it.

Phase 2: I record the first clip, not sure if this is going to work.

Phase 3: pen and paper sketches of app UI, opening the coffee pot to see if I can fit the hardware in there (I decided it would be possible, but too tight for service in case anything broke, and taking it apart would be a nightmare), and making a list of parts: right off the bat, microcontroller, relay, breadboard, soldering iron, jumper wires, resistors, LED’s. At this phase I also did some Android training since I had never used Kotlin and hadn’t used relatively current Android API’s.

Phase 4: grind loop. The first batch of hardware arrived. Soon after, the Arduino Nano 33 IoT sold out and has been since. I kept going, like a guy on a collapsing bridge. In the video, you see me discuss the initial use of the system to light an LED. This really was a live test of a huge amount of code. Usually experts recommend testing little bits at a time (write only as much as you can test) so you don’t get too many bugs at once (the difficulty to fix a system of related bugs, or bad logic, is much more than simple ones.), but I have done this stuff before, and this fun project does not call for the discipline of professional work.

One thing I don’t clearly say in the video is that for the purpose of the test, the LED is being used as a stand-in for the actual coffee pot. Instead of switching to complete a DC circuit with resistors and an LED, the relay would switch the AC wall current. The LED is just a simple, visual, sort of traditional breadboard equivalent of computer programming’s “Hello, World!”. The plan changed a few times, so I bounced back and forth between programming and buying parts. I would build some, then get stuck because I determined what parts I wanted to use, order them online, then wait. I would usually order things at the end of my weekend, for them to get here Wed-Sat, in time for me to do another sprint on the weekend, fitting the software in in-between.

The hardware side of things: the build, which is put into time-lapse, took place over the course of probably 3 or 4 weekends. I brutally tore open a wall wart AC to DC adapter which was not meant to be opened, and got a 5v power supply. I arranged the parts on the desk and carefully measured their 3 spatial dimensions, then included some wiggle room. I used these to shop for a project box. The one I found had a gasket. When I selected the relay, I had to find one that met two constraints: it had to be able to switch the wall’s AC current at a certain amperage rating, and it had to run at a very low voltage; my Arduino Nano’s GPIO supplies 3.3v. The coffee pot says it uses 700W, so since P=IV, 700=115A, A= about 6. So the coffee pot pulls about 6 amps. I found a relay fitting these parameters.

The first step was to mount the hardware on to the project box. I used a printer power cable for the wall to the box, so I bought a socket such as this one from Digi-Key. I was going to use a polarized on on the other end, but instead decided to use a 2-prong wall socket, so that the coffee pot would be unmodified and I could plug it back into the wall if anything went wrong with my box. I used Harbor Freight’s just-released cordless rotary tool which was so new I had to ask for it, and the clerk got their only one out from unshelved stock, noting that he was pretty jealous. I used the digital caliper and scribe to mark out symmetrical cut-out marks for the power entry connectors, Dremel-ed holes for them, and super-glued them in. On the side, I drilled holes for the LED holders.

I needed resistors to protect the LED’s, and I used V=IR, 3.3v=.015R (assuming these LED’s draw 15mA) to find my resistor value. I clipped the + lead (the longer one) on the LED’s and soldered the also-trimmed resistors to them, then insulated them. With the box ready, I started pulling wire and pre-wiring the setup outside of the box. This included crimping spade connectors, soldering wires to the four leads of the AC/DC adapter, and tinning and fastening some wires into screw terminals. That reminds me, I used a screw terminal adapter for the Nano for security and modifiability. When all the connections were made, soldered, crimped, and screwed in, it was time to hot glue the components to the inside walls of the box. I had been adjusting where I planned to put everything as I installed the power ports and LED’s and it was a tight fit. I had not realized how bulky insulated spades are, and the Nano adapter was unplanned-for. In the end, it did all fit, but just barely. I could have taken some spades off and used butt connectors or solder in the worst case, but I didn’t have to.

The software side of things: Making things talk is notoriously difficult, and I make it look easy because I only choose really simple projects. Actually no, you have to know about threading, timing, protocols, the state pattern, binary and bitwise operations, character encodings, endianness, message framing, and such a “monstrous heap of nonsense, a hodgepodge of foolishness” (poorly remembered quotes from a translation of Don Quixote, describing his windmill antics) that upon getting momentum in typing that list, I got a sudden urge to go lie down.... [After my repose:] ... and that’s just for a simple project like this. The protocol itself is documented in the comment linked here.

Thanks very much to Michael Contreras for the Arduino Timer library. This library is exactly what you want it to be, with a nice API and no spillage. The only thing I could have asked for would be a cancel(id) instead of cancelling all timers. That had to be worked around, but it was not too bad.

Android app development was mostly new to me, and Kotlin was totally. Luckily, since I know the fundamentals of application development, I could drag and drop code samples to get this outcome, more or less. It s amazing how little actual physical work it takes to get this result—it goes to the glory of the Android team, and some credit to myself, for all the years spent learning how to do this. Android actually requires you to run UI tasks and IO tasks in their own threads. It s great.

I thought I was really cute and funny taking photos of the coffee pot for status images:

I made no effort to finish documentation beyond necessary to clarify my own thoughts; I made no tests; I made no effort to refactor the code from shortest-path job completion to a refined, well-structured professional-quality product because this isn’t that, it’s just my daily-drinker coffee pot.

Please note: products I linked to are not necessarily the ones I used, but are close enough.