Smart Home 'Reactive' Smart Mirror Project

Warning:  This project involves mains voltages and these can kill you, especially in close proximity to water. The mirror frames used here are earthed and all the components are rigidly fixed. All joints are crimped and soldered where applicable and heat-shrink sleeving is also used. If you are not comfortable or skilled in doing this kind of work, leave it to a professional.

You can read my research and thoughts on smart mirrors but, this project shows how I have retrospectively implemented a 'reactive smart mirror' in our main bathroom and main bedroom ensuite. Both are fully integrated into my contextual smart home.

The whole point of this project is to improve our quality of life and to deliver a great user experience. It will make the mirror light and Demista a zero touch user experience. The light level will also automatically adjust to time of day and other smart home context.

Note:  I know you can buy standalone 'smart mirrors' but they have limited features and control. By fully integrating the mirror into my contextual smart home, the mirror becomes a sensor providing wider context to my smart home. I also have much greater control over its features and this is covered later.

I am also developing and building an 'interactive smart mirror' too and this will be covered as a separate project.

Design

My initial design has the following elements:

Power

I'm using one of my very efficient 12V dc power supply modules (also one of my smart home building blocks) to deliver permanent power to the Arduino, via a 5V dc-dc converter. The reason for doing it this way is because I want a local 12V dc power supply for the LED strip light. Because the power requirements of my smart mirror controller will be quite low, I could also use Power over Ethernet (PoE) if I wanted too.

Networking

I could use Wi-Fi connectivity but, for best reliability I am using a wired Ethernet network connection. As part of this project, I have run Ethernet cable to both mirrors and this could be used with Power over Ethernet (PoE).

Lighting

I firstly wanted something that looked really good but also wanted dimmable lighting around or above the mirror. This allows the brightness to be set based on context, such as time of day. My Home Control System will be responsible for "telling" the mirror what brightness to use when enabling the light, because on it has the context to do this intelligently. So for example, during the day time the mirror will light up with 100% brightness but later on it will use lower light levels (to avoid dazzling people).

I could use 220V ac dimmable lighting my two mirrors are above a sink and it is much easier to control a 12V LED strip, which will also look much better.

Demista Pads

Demista area brand of heating pads designed to stick to the back of mirrors. They are available in 12V, 24V, 110V ac and 230V ac versions. I've been using the 230V versions for many years and they are extremely reliable and work really well.

Power switching to the Demista pads is done with a solid-state relay. I could use my own relay boards (which would be much cheaper) but, I want my solution to be totally silent in operation.

Other Sensors

As I have all of the required components in place to connect up a number of other sensors, I am adding these too:

Note:  A smart mirror is not an ideal location for temperature and humidity sensors because it is above a sink (a localised source of heat and humidity) and the mirror is also heated too. I'm adding them for now to test how well they work in practice. Since they simply plug in, this is easy to do.

Ruled Out

I did also consider intelligently controlling the mains power to the shaver socket but this can detect when something is plugged in to it and already cuts power when nothing is plugged in. Adding 'smart' control didn't seem to improve anything.

Build

I'm using my Smartisant Arduino PRO1 PCB (V3) to connect various smart sensors and to provide the secure control and reporting functionality. This PCB is connected using a cheap Ethernet module. This is one of my smart home building blocks and it provides a huge amount of reusable functionality at a very low cost. It provides great performance and is incredibly reliable too. I can also populate the PCB with just the parts required for each project, so it is also very cost effective.

Proximity Sensor

For this project I'm using a JSN-SR04T ultrasonic distance sensor. It has good range and accuracy and is also waterproof. With some clever algorithms, it can be made incredibly reliable and responsive to people standing in front of it. Being ultrasonic, it will also detect things regardless of what colour they are.

To make them look better, I have spray painted mine white, which is more in keeping with my bathrooms. This doesn't really impact the performance.

The key to using this kind of sensor in this sort of application is to use the right software algorithm, to deliver a great user experience. It is possible to tune the detection range of this sensor down to the nearest centimetre and I have configured it to ignore objects more than 70cm away, so you have to be standing right on front of the sink/mirror for it to detect you. I've also a developed my algorithm that will ignore a person walking across the front of the sensor but, will detect you quickly if you stand still in front of it.

This is the kind of use case where a wireless, battery powered sensor will never work well. To get a fast detection response time, it has to 'ping' every 500mS to 1s. This would flatten a battery very quickly. You also need an algorithm that does not ping too quickly as this makes the sensor 'sing' and this can be heard.

The proximity sensor essentially 'drives' everything. Once a person is spotted the light comes on for 30 seconds and stays on for 30 seconds after the last proximity is detected. So if you walk away to pick something up on the other side of the bathroom, the light will still be on when you get back. Lights going on and off for no reason are really annoying!

The heated mirror Demista pad works the same way but it is on for a minimum of 90 seconds.

Temperature Sensor

My Smartisant Arduino PRO1 PCB makes it really easy to connect one or more Dallas 1-Wire DS1820 temperature sensors. It has space for the required 4K7Ω resistor and uses a 4-way Molex connector to connect them.

Humidity Sensor

My Smartisant Arduino PRO1 PCB also makes it really easy to connect a Honeywell HIH-4000 series humidity sensor. It has space for the required 0.1µF capacitor and also uses a 4-way Molex connector to connect it.

Light Level Sensor

My Smartisant Arduino PRO1 PCB makes it simple to connect a Light Dependent Resistor (LDR) to act as a light level sensor, using an analogue input. I've also got a project page on developing my own light level sensor. It is self calibrating and provides a value between 0% and 100%.

Sensor Location

I installed the sensors though holes in the side of the frame and thought this would be OK, as they are not really in sight. My wife disagreed, and so I'm going to be 3D printing a cover to make the installation much tidier. This does mean relocating the LDR to the top of the frame though, as it won't work behind any kind of cover.

The 3D design for the sensor cover, created using Autodesk Fusion 360.

This is the proximity sensor mounted along the bottom edge of the mirror.

Lighting

For the ensuite smart mirror, I decided to stick with the exisiting light tubes for now and I'm using this zero-crossing ac switch with opto-isolator. This makes it very easy to control and is silent in operation.

Testing

Installation

Warning:  This installation involves mains wiring and mains voltages that could kill you. If you are not comfortable doing something like this, get a qualified electrician to do the mains wiring for you.

I'm actually installing two reactive smart mirrors as part of this project, one in our main bathroom and another in our main bedroom ensuite.

Main Bathroom

This is actually a wall mounted mirror that I made myself. I bought the 75cm × 60cm mirror and mounted it onto an aluminium frame myself, installing the Demista pad on the back. There was mains power above the mirror for a light already. Initially a pull-cord switch at the bottom of the mirror controlled the lighting and Demista pad.

There is not much space behind this mirror, so I'm using an Arduino Mega 2560 Pro with my own PCB for this installation. The light unit uses 12V dc LED bulbs and plan to replace this with a 12V LED strip to make it dimmable.

Main Bedroom Ensuite

This is a commercially available, wall mounted 70cm × 50cm mirror with integral lighting, that we bought. There was mains power for a light above it already installed. I extended the mains wiring into the metal frame of this mirror. Initially a pull-cord switch at the bottom of the mirror controlled the lighting and I added a Demista pad myself.

The front mirror slides up and off to reveal the frame. There is quite a lot of space inside for my new hardware so I'm using an Arduino Mega 2560 with my own shield for this installation. The two fluorescent tubes are 220V ac and will be replaced with 12V LED strip lights, which means they become dimmable.

The sensors will be invisible (behind the mirror) and will protrude through 5mm holes on the right side of the frame.

To get the perfect positioning, I've designed a mount for the proximity sensor to be 3D printed using Autodesk Fusion 360.

And this is the 3D printed part, which allows the sensor to be mounted along the bottom of the mirror. This is a custom part for this installation and similar one will be printed for the main bathroom mirror.

Smart Home Integration

Over my many years doing smart home (I started in 2004), I have developed my own library of code for Arduino processors and this includes functions to integrate it into my distributed Home Control System and connect numerous types of sensors. These 'slave processors' can then do clever stuff like local control, self-monitoring of performance, local signal conditioning and rate limiting, send warnings and errors, or host some functions locally.

This maximises reuse across my many smart home projects, making it very quick and easy to develop and test new smart home capabilities. My smart home also employs the concepts of technology abstraction, meaning my smart home is also technology agnostic. This allows old technologies or broken sensors and devices to be swapped out with new ones, with minimal effort and zero reconfiguration.

Most of the Arduino processors installed in my smart home use an Ethernet IP network interface, to enable them to send and receive events with my Home Control System, using my unified communications protocol. Wired networks ensure very low latency and hence a great user experience, though occasionally I will use Wi-Fi.

Adding sensors and devices to my Home Control System is simply a matter of adding one line of JSON for each one, to the main configuration file. This defines the name, zone, object type and also the details of the slave processor it is hosted or controlled by. All the intelligence is within my Home Control System, which receives and sends encrypted events using my unified communications protocol. It sends events to update my smart home on things like the temperature, humidity, fan state, appliance and lighting state changes, occupancy, etc.

Note:  These smart mirrors are not stand-alone smart devices. They a fully integrated into my smart home and report all activity and sensor readings back to my Home Control System. This means they contribute to the overall whole home context, including things like its virtual sensors. Both mirrors are a source of occupancy and feed into the nested occupancy model used by my contextual smart home.

Summary

From the outset, this project was about improving our quality of life, by delivering a great user experience and making these mirrors and their lights and Demista pads a zero touch user experience. I also used it as an opportunity to add more sensors to my contextual smart home and benefit from the associated context that they add to it.

I haven't added any confusing technology. These mirrors are fully automatic and will make life simpler for my family and guests. This kind of zero touch user experience works for everyone, regardless of age or ability and it fits well with my company ethos of 'intelligent assisted living for all'.

These reactive smart mirrors also have none of the issues associated with interactive smart mirrors, such as privacy and permission to control other smart home features, which is really important when guests and visitors will be using them.

This project is the foundation of my 'interactive smart mirror' project, which features an interactive touch screen mounted behind a one-way mirror.

Examples

My @smartest_home will occasionally tweet about the Ensuite Smart Mirror.

My @smartest_home will occasionally tweet about the Ensuite Mirror Light.

Further Reading