The magical automated bathroom mirror

One of the greatest advantages of building your own DIY smarthome solutions, for me at least, is the ability to combine sensors and outputs in ways that would make no sense for a traditional manufacturer to implement. My bathroom mirror not only shines light onto my face when I’m brushing my teeth, but also makes sure my towel is nice and warm just after I take a shower. Let me show you how!

First off, we start with a plain and boring mirror. I live in a rental apartment with aspirations of ownership someday like many others, and it came with this mirror included as standard. Luckily though, once I pulled it off the wall, I found a nice recess in the back with a few bare wires, waiting for me to attach a light, and this is exactly what I did.

The version 1

The one photo

Now I’ve done this before in my previous apartment, and I was able to find a grand total of one photo of it. Here I’m in the process of installing one light bar above and below the mirror, with an electrical box containing the power supply and other electronics. This meant that I could leave the mirror alone for the most part, but the box is ugly and my girlfriend complained about the direct light being too harsh. In this second iteration the aim is to have all the electronics completely hidden behind the mirror, and have the lights shine outwards from the sides. The main issue with this approach is the extremely limited space behind the mirror, meaning that any electronics I put there need to be very flat - 18mm tall maximum, from what I measured.

An attempt at reuse

I’m reusing the LED strips from the previous installation, and I also tried to reuse the LED profiles that came with it. However upon trying to line it up, it’s obvious that since the strips before were just at the top and bottom while this covers all four sides, there’s just not enough and it’ll leave some very visible and ugly gaps in the light around the edges. Also, since I’m mounting the LEDs behind the mirror now, there’s no need for any diffuser layer in front of it, so I can just have the bare LED strip shine outwards.

Adapting to the new mirror

Before I continue, a quick aside on safety. As this is being installed in a bathroom, this is a humid environment and the electronics need to be able to handle this. The LED strip I’m using is coated in a layer of silicone and is IP62 rated, and all the PCBs I’ll be showing next are covered in a layer of conformal coating to keep the moisture out. I specifically don’t write how-to guides as everyone’s situation and tolerance for risk is different, and what I deem to be safe in my situation may not be safe in yours! Anyway, continuing on.

One trip to Hornbach later yielded these lovely 15mm x 15mm right-angle aluminium profiles, and with the use of some very thin double sided tape, the theory is that the profile will be able to transfer some of the heat generated by the strip to the mirror itself. After cutting it all to size and positioning it a couple centimeters inset from the edge of the glass, here’s what it looks like:

The mirror on its front

If you take a look at the bottom, the LED strip is slightly too long! It comes in 10cm sections and there’s about a 2cm overlap. The silicon compound covering the top prevents it from sticking well to itself… to this day, I’ve just let it dangle freely below the mirror, it’s still tucked in enough that you can’t see it directly. I’m not claiming to have the perfect solution here.

Moving on to the electronics powering it. The sketchiest part of this project has to be the power supply, which is a 24 volt SANPU unit with the casing removed. These plastic cases are difficult to remove and for very good reason; this is definitely a “don’t try this at home” move… but the case was just too tall to fit, and I knew that it would be inaccessible once mounted on the wall.

The PCB

For the PCB itself, I repurposed a board that I had lying around from previous experiments. The white PCB has space for 5 MOSFETs, each one able to handle a channel on a 24V LED strip. In this situation I’m using a quite a long warm/cool white combination strip so I populated 4 of the 5 sections, and then put two MOSFETs for each channel in parallel to handle the extra current. Normally each one uses its own GPIO but I cut the traces and added a wire so that each pair runs off one GPIO, to ensure they stay in sync. I then added a BME680 temperature, humidity and air quality sensor to the bottom. Due to the height constraints and wanting to make sure the sensor didn’t sit so proud off the board that it was right up against the wall, I brought out the hot air rework station to solder the two directly to each other without the pin connection that I had originally designed it for.

The heart of the board is an ESP32-C6 mini board off AliExpress, and I also use a 24V to 5V DC-DC converter, again off AliExpress. This interfaces with the sensor and lights. With that all in place, it’s time to get this onto the wall!

The final result

Here’s the final result. I’m super happy with how it looks, and with the lights off, you won’t even notice it’s there. The only telltale sign is that after you’ve finished having a shower, the middle patch of the mirror won’t have any condensation due to the heat generated by the power supply directly behind it. A little side effect, and also this heat generated also unfortunately greatly affects the temperature sensor readings. While I tried to position the PCB as close as possible to the hole at the bottom where the cables are fed out for the LEDs, the temperature is always a bit off. This isn’t a big deal as what I really wanted was the humidity sensor, and that works great! Which brings me on to…

But wait, what about the warm towels?!

It’s time to bring in a second device to the equation. Directly next to the bathroom sink is a electric towel rack radiator. It plugs into the wall using a standard wall plug, but is competely superfluous from an apartment heating perspective because there’s also underfloor heating in the bathoom too. So the only thing it’s good for is heating towels. But if the room is already at temperature, you don’t want to have this thing heating towels all day. The trick to use here is to come up with a simple way to detect if someone is having a shower, and then automatically turn on the radiator.

The smart socket

Let’s tackle the second part first, which is automatically controlling the radiator. This was solved with an Athom smart socket, which I used to replace the existing wall socket. With this in place, I can switch on and off the power from Home Assistant, and even monitor the amount of power the radiator consumes. Neat! Also, it comes with a button on the front that I can use to manually turn it on and off if I so desire.

Now to tie it all together. With the humidity sensor placed in the mirror, we’re able to detect the increase in humidity when someone takes a shower. A simplistic implementation would be to define an arbitrary threshold of humidity and trigger on that, but this has the risk of triggering on an overly humid day, and will take a while longer to trigger, potentially not warming the towels in time. Instead, if we track the rate of change of humidity, we can expect that when the shower first turns on, the humidity in the room is going to increase a lot more rapidly than that of normal environmental changes. In Home Assistant, under Devices & Services -> Helpers, we can create a helper sensor; specifically a derivative sensor.

Humidity derivative graph

I’ve got this sensor set to track the percentage change in relative humidity per minute, and we can see that when I turned on the shower at 09:12 this morning, the graph starts fluctuating rapidly. Normally, this number stays at much less than 5% per minute, which is the threshold that I used to create my automation on. With a simple automation, I detect a +5% change, and then turn on the radiator. This means that it turns on almost immediately after I start my shower, and by the time I finish, the towel is nice and warm. It then stays running until the change is between 2 and -2 for a few minutes, which gives time for the towel to be dried a bit before turning off.

The good and the bad

Overall it’s been working great, and I think my girlfriend was on to something with having the lights behind the mirror, at least from an aesthetic standpoint. However it’s definitely less bright than having them facing you head-on, and I think in a V3 iteration I may also want to add a light that extends outwards from the top of the mirror and shines down. I think this would allow the best of both worlds by allowing you to choose.

The inaccurate temperature sensor is also a shame, as currently I have no good way of getting the temperature accurately in that room. I’ll need to come up for another solution for that in the future. Also, while I’ve found the signal strength on these little ESP32-C6 mini boards to be generally adequate for my apartment usecase, putting it behind a mirror on an outer wall of the apartment at just about the furthest point away from the access point has caused some signal issues. Next time I’ll be choosing a board with an external antenna that I can position on the edge of the mirror, past the LEDs.

I’ve now combined this with a Shelly i4 behind the light switch, and apart from the few signal interruptions every now and then, it works just the same way anyone would expect! When you turn the light switch on, the lights behind the mirror turn on too. I keep them at 80% normally, and if it’s not bright enough, just pull out your phone, open Home Assistant and boost them up to 100%.

© 2025 Elvin Luff. Back to top