Temperature Sensing Mug

 

I took this project on as a present for my girlfriend, who, during the colder months, is more or less addicted to coffee/hot chocolate/tea. Her mug broke, and I was just going to get a new one for her birthday, but I wanted to add a little functionality to it. The new mug now senses and displays the relative temperature of its contents on a 10-LED blue bar display and has a rechargeable battery, which is charged through a 5.0V DC jack. Turned out pretty well, although it reacts a tad slow to temperature changes, as you can see in the video.

Electronics

I started constructing the circuit on a breadboard, using a PIC12F615 as the core of the project, first working out gathering and displaying temperature data. After a bit of research, I found that a standard small-signal diode’s voltage drop actually varies with temperature. The voltage drop reduces by about 2.3mV per degree Celsius, and the PIC’s analog to digital converter’s resolution is about 4mV. I couldn’t do any precision temperature sensing, but I didn’t need to, since I just had ten LEDs to display the data.

To get the voltage drop of the diode into the PIC, I put a 10 kOhm resistor in series with it, much like a voltage divider, and ran the output of the voltage divider into the PIC. Calculating how many LEDs should be on at what voltage was a bit interesting, and took a lot of guess work. At the bottom of things, I found that cold/icy water gives you a reading of about 145 from the ADC, and hot water gives you about 115.  115, the minimum, is subtracted from the result to give the PIC a value from 0 to 30. However, since higher temperatures give a lower value, that number is subtracted from 30 to flip it. With that range of 30, each LED in the bar display represents a range of 3, and from there it’s just division by 3 via repetitive subtraction to figure out how many LEDs should be on.

Displaying the temperature on the bar display was interesting because the small, 8-pin PIC that I used doesn’t have the I/O to directly drive all ten LEDs. I thought I would just use a 10-bit shift register to extend the output, but I stumbled into several issues because of the operating voltage range I would have because of the rechargeable battery. The voltage range is 3.0V-4.0V, so I could only find shift registers that are CMOS, which can’t sink or source enough current to drive the LEDs. On top of that, I couldn’t find any 10-bit shift registers, so I had to link two 8-bit ones together. Then I had to buffer their outputs with a couple of 8-bit buffers (also couldn’t find a 10-bit one) that, on top of it all, were surface-mount devices, making soldering challenging. Once it was all said and done, it worked, but it wasn’t very compact.

Now, onto the power source. It needed to be a rechargeable battery because you can’t very easily open up a mug and pop in a few new AA batteries. I opted for a 900mAh Lithium-Polymer battery because they aren’t finicky about being recharged without fully discharging, and it’s a very slim battery. To charge it, I used a MAX1555, which regulates charging voltage and current for you, allows a huge voltage range for the input voltage, and lets you charge the battery while the circuit is operating. As I mentioned before, I used a 5.0V DC jack to charge the battery, and this is connected to the MAX1555.

Testing the charging circuitry

While Lithium-Polymer batteries are flexible about when you recharge them, they aren’t very happy about over-discharging. This happens when their voltage falls below about 3.0V and the battery is still supplying current. To guard against that, I had to add something in to shut the circuit off when the supply voltage falls below 3.0V, and I did that with a MAX16052 voltage watcher. Its output is driven low when its input falls below 0.500V, so I used a voltage divider to bring 3.0V down to that. The output is connected to the base of an NPN transistor that is between the rest of the circuit (the load) and ground.

Everything put together on a breadboard

Because the MAX1555, MAX16052, and buffers were all surface mount, I put together some breakout boards to test them on a breadboard.

Construction

I first tried making the double-sided board myself, and it didn’t turn out too bad. Just in case, though, I ordered a couple boards through BatchPCB. I followed most of the usual steps to make the board, but to align the bottom and top, I ironed on the top side, drilled the holes, and aligned the holes in the bottom side with the top before ironing the bottom on. I put together a little glass-table-with-light jig to see the holes in the board easily so I could align the sides.

Little Glass-Table-With-Light Jig in action

I went through a few revisions to reduce the number of vias, which ended up being very finnicky and difficult to solder. In general, I think it was the soldering that killed the board. I wasn’t using flux, and I was using an old Radioshack iron that liked to burn things. Eventually, I did get the mug working with a board that I made, but it later broke, so I used one of the boards that I ordered. The battery went under the board and was protected from the sharp leads with a few layers of electrical tape, and the resistors for the LEDs are up in the air like that to save space.

The board with everything soldered on

Now, the mug had to be modified. Most travel mugs have an insert, which holds the liquid, and an outer shell. They aren’t connected, except at the top, so the air between the two is what insulates your warm beverage. The circuit goes in the gap between the two, but there wasn’t nearly enough room for my board and battery. To make that room, I opened up the mug and took a 3/4″ piece out of the insert. To reattach the bottom to the rest of the insert, I superglued it for structural support, then sealed both sides of the seam with FDA-approved food-grade silicone. Sonic welding would have been nice, but I don’t have the equipment.

I had to cut out a hole in the outer shell for the DC jack, too. I guesstimated the height, which was a little dumb of me, but it ended up working just fine. Anyway, I found that I couldn’t cut the hole with a Dremel like I wanted to because the plastic melted, even with the Dremel on its lowest speed. I just started the hole with a Dremel and used a small steel file and X-ACTO knife to make the hole.

Lastly, everything had to go together. I dropped the circuit board into the mug, aaaand. It didn’t fit. Oops. I thought I measured it out, and 2.5″ worked just fine! Another look at the board file, and I found that I had actually made the radius of the circle 0.05″ larger than it should be, by accidental mouse slip. I used my Dremel and a grinding bit to take the extra board off, but it was a close cut because that 0.05″ was a border between the edge of the board and where the copper started. Dropped the board in again, and it didn’t fit, again. Oops oops. The LED bar display was too close to the edge, so I rounded off its corners. The third time was the charm, though, and after a little bit of work, the board was in place.

I dropped some hot glue into the edges to keep the board in place, although it was a pretty tight fit to begin with. Then I glued the diode to a notch I had cut into the insert so it could be a bit closer to the liquid. To seal the DC jack in place, I globbed hot glue over the hole, then cut it flat with a razor blade when it had dried. After cutting a hole for the plug, it was all glued into place. Last was to put the insert back into the outer shell. With the help of my friend, Austin, I put hot glue on the lip of the insert, then pushed it into place. The hot glue created a seal and it was all good to go after a thorough washing.

 

:D

Problems and Improvements

No project is complete without feeling incomplete, so here’s some stuff that went wrong with the mug:

The first time around, I used a board that I made. One LED went out, probably from a bad connection, and when the battery ran out, it never started back up again, no matter how long I let it charge. After putting together one of the boards that I ordered, the circuit just didn’t start up. After poking around, I found that the circuit worked when the DC jack was plugged in and there was no battery, but as soon as the batter was in the mix, it didn’t start at all. I eventually found that it was because of the diode. The circuit was running, but the voltage drop was out of the PIC’s range because, apparently, the amount of current through a diode also changes its voltage drop. When the battery was attached, more current went through the diode, which raised its voltage drop out of range of the PIC, so no LEDs turned on. I changed the resistor that was in series with the diode to 33 kOhms to reduce the current, and thus the voltage drop, to bring things back into range.

The second big issue is that, as battery depletes, the number of LEDs that light up goes down and down until the battery dies. This means that 150 degrees equates to 8 LEDs at a full charge, but only 5 before the battery dies. This, again, is because of the fact that current through a diode changes its voltage drop, which I didn’t know until after the fact. As the voltage of the battery goes down, so does the current through the diode, which, in turn, lowers the voltage drop of the diode.

If I were to make a Mug v2.0, here’s what would be different:

  • I would first use a PIC with enough I/O to directly drive the LEDs. That would greatly reduce the component count and make the software on the PIC simpler.
  • The battery’s voltage would be regulated to 5.0V. I didn’t think of this, and once I did, it was too late and I thought I could get around it because nothing depended a whole lot on the voltage. Except for the current through the diode. This would also make component selection easier, since 5.0V is a lot more common than 3.0V-4.0V.
  • I just wouldn’t use a diode to sense temperature. I’d use a thermistor or something else that’s suited for temperature sensing.
  • I’d add in a “charging” indicator light, not sure why I didn’t for this one. It’s tough to figure out when it’s done charging.
  • Maybe I’d throw in a numerical display for the temperature, instead of the bar display.
  • It’d be pretty cool to use a bicolor LED display so I could change the color of the display depending on the temperature.

Last, but not least, here’s the circuit diagram and board layout:

Schematic

Board

Ben Oztalay

  1. April 13, 2011 at 12:24 pm | #1

    Hi

    Nice project.
    I developed the Smart Thermal, some time ago with Arduino.
    see: http://brasilrobotics.blogspot.com/2010/03/smart-thermal-arduino.html

  2. Mike
    May 19, 2011 at 12:16 am | #2

    Cool idea, I think if I made this I would make the LED’s show when the fluid in the cup is at a temperature range that is drinkable rather than the overall temperature. At least that way the device would never have to be turned off. Worth a thought or two.

  3. Henry
    November 12, 2011 at 2:53 pm | #3

    can I buy it from you?

    • November 13, 2011 at 6:44 pm | #4

      Nope, sorry. It was a present for my girlfriend. I’m working on a second version right now that I might head that way with, though.

  1. April 10, 2011 at 1:55 pm | #1
  2. April 12, 2011 at 8:07 am | #2
  3. April 12, 2011 at 4:34 pm | #3
  4. April 12, 2011 at 8:53 pm | #4
  5. May 5, 2011 at 8:27 am | #5
  6. May 18, 2011 at 5:12 am | #6

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: