Sensors from Aqara were one of the 1st sensors I used in my home automation. Back in then, they were made for Xiaomi Mi Home hub. Things progressed since, and Aqara has their own independant ecosystem. I covered already some of their devices: 2in1 camera and ZigBee hub, or their ZigBee based switches. It’s time to poke all Aqara sensors in NodeRED.
Sensory overload
Unpacking care packages from Aqara is always a thing that brings me joy, they have sent me several of their sensors to try out and two latest hubs that you can use with HomeKit, ZigBee and integration of Aqara with Google Home and Alexa.
I will talk about the hubs in particular in my next article, but for now, I wanted to gather all Aqara sensors for use in NodeRED. All sensors supplied to me are ZigBee based and I will be using my trusty CC2531 (flash guide) to talk to them. In my line up I have:
- Aqara Contact sensor (door and window sensor) (AmazonUS, AmazonUK, AliExpress, Banggood)
- Aqara Temp & Humidity (AmazonUS, AmazonUK, AliExpress, Banggood)
- Aqara Vibration Sensor (AmazonUS, AmazonUK, AliExpress, Banggood)
- Aqara Leak Sensor (AmazonUS, AmazonUK, AliExpress, Banggood)
- Aqara PIR with Luminosity (AmazonUS, AmazonUK, AliExpress, Banggood)
I will check if all sensors are compatible with Zigbee2MQTT and show you how to intercept the data for your DIY smart home. There is one more tutorial that you will find quite helpful. This project automatically scans all ZigBee battery-powered devices and display the battery levels so you can track it. It can also let you know on your Android phone which sensors need attention.
Aqara sensors in NodeRED
The biggest advantage of the Aqara sensors is the ZigBee protocol. You don’t have to use these with Aqara hubs, but you can link these to your own automation server. I already covered the use of Aqara T1 switches in NodeRED – take a look if you want to add them to your setup.
Regardless of the sensor type, they all pair in the same way. Locate the reset button and hold it for 5 sec until you see a LED blink. Sensors should be added automatically within seconds. Just keep it close to the coordinator.
If you don’t know how to pair ZigBee devices with ZigBee2MQTT, I have you covered already – this tutorial will explain the procedure step by step. Moving on, I will assume you know how to pair and look up the messages from ZigBee devices.
Aqara PIR and luminosity
Initially, I was very impressed with the response rate of the sensor – it was reporting back every 10 seconds. Unfortunately, this only the case for 5 min, after which the sensor goes back to a pretty standard 1 min timeout with each trigger.
To my surprise there are some interesting metrics attached to the payload coming from this sensor:
{
"battery": 100,
"illuminance": 297,
"illuminance_lux": 297,
"linkquality": 134,
"occupancy": true,
"temperature": 32,
"voltage": 3105
}
I’m in the UK, so that temperature reporting isn’t for my climate, the 32℃ refers to the temperature of the PCB sensor rather than environmental. It shows 7℃ more than my ambient temperature.
Occupancy is returned as bool, and luminosity has 2 ways of reporting values via illuminance_lux
and illuminance
– these report the same value so feel free to use both. The maximum luminosity value reported by the sensor is 1000, which is considered broad daylight, and a dim room with just a night lamp on would return around 50.
To monitor battery, you get 2 values out of the sensor: battery in % and in Volts. Just remember to divide the battery in Volts by 1000 to get a real value.
Aqara Temperature, Humidity and Pressure Sensor
The sensor is easy to pair and reports the data every 60 seconds or on significant temperature change. Sensor reports 3 metrics: temperature in ℃, humidity in % and pressure in hPa. Apart from that you can also get the information about the sensor range and battery information in Volts and percentage.
This is how the payload looks like:
{
"battery": 100,
"humidity": 54.7,
"linkquality": 168,
"pressure": 1019,
"temperature": 25.98,
"voltage": 3055
}
I know a lot of my readers are using bald eagle units: Fahrenheit, so I have added the conversion for you in my NodeRED dashboard. While this is not retro-applied in the chart, you can use the toggle to start recording temps in different units moving forward.
This sensor measures the temperature of the air, however does not report the temperature of the PCB like other Aqara sensors. I use several sensors in my house in my DIY Smart Heating project. It’s the 3rd year running and I keep adding new features each year.
Aqara Contact Sensor
Next up, the small Aqara Contact Sensor which can be mounted on doors or windows. You can actually use 2 of these to create a DIY smart door with the ability to tell if you locked the door behind you. The contact reports nearly instantly, and there is no cooldown period.
The following payload is available on trigger:
{
"battery": 100,
"contact": true,
"linkquality": 165,
"temperature": 29,
"voltage": 3055
}
Just like with the other ones, you can get the link quality, battery information in % and Volts and extra temperature of the circuit – useful for monitoring purposes. The main information about the contact state is available as bool in msg.payload.contact
.
It’s worth mentioning that this sensor uses a different than CR2032 battery: CR1632, so be sure to get the correct ones.
Aqara Water Leak Sensor
It’s the first time I had a chance to play with the leak sensor. These are in my opinion great sensors to have, but very flawed in their design. Paired with the main stop-cock valve, they could prevent damage to your property. The problem is, these have to be deployed where you suspect a leak, directly in contact with water. I will make a 3D printed add-on which will increase the probability of detecting leaks quicker.
Sensor reports the following information:
{
"battery": 100,
"battery_low": false,
"linkquality": 65,
"tamper": false,
"voltage": 3055,
"water_leak": true
}
Just like before, there is information available about the link quality and the battery state in % and Volts. The water leak information is stored in msg.payload.water_leak
as a bool. What’s interesting, this sensor comes with tamper information. I would expect one on the contact sensor, but I guess it makes sense to add one here to inform you about the water ingress into the sensor. There is no temperature information from the PCB for this sensor.
The sensor responds within 1-2 sec of being submerged in water (both contacts needs to be wet), then returns to the normal state once contacts have no way of conducting electricity.
Aqara Tilt, Vibration & Drop Sensor
It’s another new to me sensor. While the Aqara app reports vibration, tilt and drops events, the sensor in node-red is capable of delivering more detailed information. The main action is stored in msg.payload.action
and can report values like drop, tilt, vibration
.
{
"action": "vibration",
"angle": 18,
"battery": 19,
"linkquality": 152,
"voltage": 2745
}
However, if the detected change in orientation is recorded a more detailed message is sent back as well that looks like this:
{
"angle": 18,
"angle_x": -81,
"angle_x_absolute": 171,
"angle_y": 2,
"angle_y_absolute": 88,
"angle_z": 9,
"battery": 19,
"linkquality": 162,
"strength": 19
"voltage": 2745
}
These values describe the angle of each axis and possible acceleration, but I don’t find the sensor to be responsive enough to be all that useful. It takes a significant change in position, vibration or a drop to update the position. There is a strength value associated with the value of the vibration which you can use to filter out weaker vibrations.
Just like with other sensors, we have the information about the battery in V or % there is link quality as well but the temperature of the PCB is missing.
Aqara ZigBee 3.0 line up so far:
- Aqara Hub M1S (EU, UK, US)
- Aqara Hub M2
- Aqara G2H Hub & IP Camera Banggood, AliExpress, US
- Aqara Camera Hub G3 UK, AmazonUS
- Wireless Remote Switch H1
- Smart Wall Switch H1
- Aqara T1 switches (UK, US)
- Aqara Curtain Driver E1
- Aqara Contact sensor (US, UK, AliExpress, Banggood)
- Aqara Temp & Humidity (US, UK, AliExpress, Banggood)
- Aqara Vibration Sensor (US, UK, AliExpress, Banggood)
- Aqara Leak Sensor (US, UK, AliExpress, Banggood)
- Aqara PIR with Luminosity (US, UK, AliExpress, Banggood)
Final thoughts
Aqara sensors are pretty good. Compatible with both ZigBee 3.0 and 1.2 ZStack, so you can add these to your DIY home automation. All files used in the tutorial are available for the download below so feel free to take advantage of them. Next up, I will play with the hubs and see what features these have to offer for us. If you are interested, you know where to find me, if you have any questions please leave them in this Reddit thread.
Project Download
Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.