The best and cheapest motion sensors for your smart home?

Published by Oliver on

Automatic lights are magical. You walk into a room and the lights just turn on… to add this magic to your smart home you need motion sensors. Many motion sensors. Here is everything you need to know about them and my experience on how to find and install cheap and reliable motion sensors.

What do they do?

Well motion sensors do exactly what they are named after: they sense motion. This is part of (maybe the most important one) of a larger concept called presence detection. For your smart home to act automatically and react to you it needs to know where you actually are. That is what presence detection is for.

While other technology from cameras to NFC to GPS can work well for presence detection motion sensors are a reliable, relatively precise and affordable solution.

How do motion sensors work?

While there are different technologies most motion sensors are PIR sensors. Passive Infrared (PIR) sensors work by detecting infrared light. We humans, as well as animals, emit this infrared light in the form of heat. Motion sensors build a kind of grid where they detect this heat. If the number and position of grids with high(er) amounts of infrared light changes too quickly they trigger an alarm.

This alarm will usually be sent to some base station. Most sensors are working wirelessly with a battery although there are systems with wired sensors.

What kind of motion sensors are needed for a smart home?

I find motion sensors to be one of the most important parts of my smart home. They allow the software to detect where (or anyone else in my apartment) am and to react to it. I enter the room, the lights turn on. No further action needed from my side. Perfect!

For anyone building a new smart home from the ground up (and I mean actually building a house here or doing extended renovations) consider a wire based solution like KNX. While they are sometimes a little bit more expensive and more complex to set up, wired solutions will be super reliable.

For anyone else, like me, who is adding smart home components on top of an existing home I would recommend going with a wireless, battery powered, solution. Unfortunately this means that Wifi is not an option. It just uses too much power.

Instead you should go with a solution based on a wireless protocol more suited for smart home applications. I tried different kind of sensors. I started out by building my own motion sensors based on cheap PIR sensor modules, Arduinos and the NRF24L01 transceiver chip. The awesome MySensors framework covers the software side. While this is fun and I actually used it for more than a year, ultimately it is to error prone and too time consuming for me.

Next I tried something else: cheap 433Mhz motion sensors. I bought a Sonoff 433Mhz bridge, flashed Tasmota onto it, and bought a cheap generic 433 Mhz motion sensor. After finding out the code it sends when triggering an alarm I could use it as a motion sensor. This was way less work, still cheap and more reliable. Still I did not really like the solution. The motion sensor is quite big and kind of ugly and 433Mhz modules like this use one way communication. This means sometimes alarms get lost as the sensor is not re-sending them.

The 433Mhz motion sensor sitting on a shelf

Then I tried a more high end existing solution: the Hue motion sensor. It works really well, is integrated into the great Philips Hue ecosystem and uses Zigbee, which is power efficient, builds a mesh network and has two way communication. While this is great I knew I would need a lot of these sensors and this solution is just too pricey. 40€+ for just one sensor is too expensive. To be honest it also does not look very nice either, although it is still way better than the 433Mhz module.

Then I tried the Tradfri motion sensor from IKEA. Basically the same as the Hue solution but way cheaper at about half the cost. It is also possible to link a motion sensor to a smart bulb without using any Hub or base station with the Tradfri solution. I am not sure if that is possible in the Hue system. Still I was looking for a better fit.

When testing Zigbee2MQTT I finally found my personal preference so far: the Xiaomi Aqara motion sensor. It is even cheaper than the Tradfri solution at around 8-12€ depending where you buy it, smaller and better looking and still using the same Zigbee technology. It als comes with a small mounting stand and glue pads included. It works with a single CR2450 cell and in my ~1,5 years of usage they still show a minimum of 70% of their capacity. As a small bonus it also measure the brightness of the room.

Battery state of all my Zigbee sensors after around 1.5 years of usage for the oldest ones

While the Aqara Hub seems to be working great I use the sensors exclusively with my Zigbee2MQTT setup to avoid using another cloud based service. All needed features are supported and I haven’t had any issues so far.

Cute little Xiaomi Aqara motion sensor (on the left)

PIR modules for a DIY solution
Arduino Pro Mini 3.3V for a DIY solution
NRF24L01+ modules for a DIY solution
433Mhz motion sensor
Hue motion sensor
Tradfri motion sensor
Xiaomi Aqara motion sensor
If you are interested in buying a motion sensor consider doing it via my affiliate links above. It does not change prices for you and allows me to pay for the servers 😉

Where to place motion sensors?

Now to achieve the presence detection motion sensors are needed in any room that has lights that should be controlled automatically. It is beneficial to have the motion sensor detect you as early as possible, to hide the small delay while actually turning on the lights. Therefore it is best to mount it somewhere opposite to the entrance of the room. If a room is bigger or has several entrances multiple motion sensors might be needed.

Motion sensors usually work in a cone of a little less than 180° horizontally and around 90° vertically. The Aqara motion sensor claims 170° horizontally which seems to be true. It seems to get more precise with lower range but I had no problems with motion detection up to ~6m. I usually place the small motion sensor on a shelf somewhere across from the entrance to a room.

Be aware that it might not be a good idea to place it directly across from the entrance as it might then also pick up motion from outside the room. A little “reach” into the doorway will allow the sensor to sense motion earlier though and thus hide the delay in switching on the lights. I usually place mine at around 1.5-2m height but you can use the provided foot to tilt it if needed.

where to position a motion sensor. Bad behind the door, ok across from the door, perfect in a corner
Professional sketch of where to place your motion sensors

In the sketch above you can see some example positions. The one behind the door in usually a bad one because it can detect you only after you moved a couple of meters into the room, resulting in a delay with the lights. Directly across is better but has the aforementioned problem of reaching far outside the room. Personally I placed most sensors in the edges of a room across from the door. This will detect motion early but not too far outside the room.

You should also consider that the infrared light the sensor is detecting is basically heat. Knowing this you should if possible avoid pointing the sensor at changing heat sources like the stove, heaters and maybe also the windows at close distance. Otherwise you might get unexpected “motion” detected. I also noticed that steam from the kitchen or bathroom would occasionally mess with the sensor. This is less of a problem though as you are usually in the room anyways when this occurs.

What to use motion sensors for?

Possibly combined with other methods motion sensors are a great tool for presence detection. Of course you can make you smart home react in a variety of ways to a presence. It can be used as an alarm system, but consider maybe buying a professional system for that if it is really important to you.

Another idea would be starting or stopping any process. For example in my case I control my vacuum robot via my smart home system. Usually I run it on a schedule when I am not at home. I thought about adding a feature where I stop the robot when motion is detected so that it does not bother me should I return early. I did not really have a need for that yet though.

In my opinion the most important use case for motion sensors is automating your lights. I have lights in every room that are controlled by my smart home. To automate them I also added 1-2 motion sensors per room. Now whenever I enter a room the lights turn on – no light switches needed. It is awesome! I do not even need to turn off the lights. If no motion is detected for a certain time the lights will turn off again.

Be sure to tune each sensors behavior to your usual use case here though. I use different delays for each room to turn off the lights. Usually I use the default of 90 seconds until no more motion is reported. In the bathroom there might be longer periods of no motion where I still want my lights turned on, therefore I increased this timeout to 10 minutes.

Increasing the timeout for a sensor can be done via a simple command in the config file of zigbee2MQTT but should not be lower than 60 seconds. I added this line to my sensor: occupancy_timeout: 600

I also made some of my motion sensors depend on the time of the day. There is no need to turn on the lights during the middle of the day. Therefore rules for rooms with windows check timeOfDay != "DAY" before switching on the lights. These day & night times are borrowed from this nice blog post and further described in my post about smart cooling fan. The hall way for example has no windows and will therefore turn on the lights at all times.

How to integrate the Xiaomi Aqara motion sensor with OpenHab?

If you are using OpenHab and Zigbee2MQTT (that part will work the same with any other smart home system) it is quite easy to integrate the Aqara motion sensor. The basic steps are:

  • pair the sensor with your Zigbee2MQTT instance by pressing the small button for 5 seconds
  • update the config for the sensor in Zigbee2MQTT and give it a proper name (and timeout setting if needed)
  • create a Thing in OpenHab for the sensor
  • create Items in OpenHab linked to the things channels
  • add the Items to your dashboard or use them in rules

If you need more details about this process checkout my guide for Zigbee2MQTT where I describe the process of adding an Aqara motion sensor and read more tips and tricks. I also have a general 3 part guide on how to set up your smart lighting system. Part 3 deals with the software side.

My motion – light rules are actually pretty simple. Here are a couple of examples for different kinds of rooms

rule "Switch bathroom lights depending on motion sensor"
when
    Item motionZigbeeBath received update
 // has the 10 minute timeout
then 
	logDebug("Rule", "Motion in bath detected")
	//if (MotionSensorsActivated.state == ON) { // motionsensors are activated
    	logDebug("Rule", "Switching lights in bathroom to " + motionZigbeeBath.state.toString)
    	sendCommand(Bulb_Bath_dimmer, motionZigbeeBath.state.toString)	
	//}
end

rule "Switch kitchen lights depending on motion sensor during the night"
when
    Item motionZigbee1 received update
then 
	logDebug("Rule", "Motion in kitchen detected")
	if (timeOfDay != "DAY" && MotionSensorsActivated.state == ON) { // is night & motionsensors are activated
		logDebug("Rule", "Switching lights in kitchen to " + motionZigbee1.state.toString)
    	sendCommand(H801kuecheObenDimmer, motionZigbee1.state.toString)	
        sendCommand(H801kuecheUntenDimmer, motionZigbee1.state.toString)	
	}
end

rule "Switch hallway lights depending on motion sensor"
when
    Item motionZigbeeHallway received update
then 
	logDebug("Rule", "Motion in hallway detected")
	if (MotionSensorsActivated.state == ON) { // motionsensors are activated
    	logDebug("Rule", "Switching light in hallway to " + motionZigbeeHallway.state.toString)
    	sendCommand(BulbHallway_dimmer, motionZigbeeHallway.state.toString)	
	}
end

The possibilities are endless here though. Your smart home sensing you means it can directly react to you. If you have another great use-case for motion sensors write me an email or a Twitter message.

If you are looking for more smart home content check out the email list or follow me on Twitter!