We make a smart smoke detector Zigbee from a regular fire smoke detector Rubezh IP 212-50M2
I came across a few of these detectors here absolutely by chance. We open the passport and read – FIRE SMOKE DETECTOR OPTICAL-ELECTRONIC AUTONOMOUS IP 212-50M2. The production is carried out by Rubezh Group of Companies
LLC “Fire Automation Design Bureau”.
On the one hand, the thing is useful, it will warn you about smoke in the room with a siren sound. But on the other hand, it is just as useless, since no other communication with the user is provided, except for the loud siren screaming. And if you are not nearby, you will not hear anything. Although we must give credit to the manufacturer, it screams very loudly.
So, a decision was made to independently modify this detector – to make it smart, so that it could be integrated into the system Smart Home. We select the protocol Zigbee.
I just want to warn you right away that the author is not a real welder, this is his hobby.
So, let's take it apart and see what and how the factory sensor is made and how it works.
The title contains the word “autonomous”. This means that it is powered not by the mains, but by a battery. In our case, this is a 9-volt battery of the type “Crown”.
The heart of the detector is a system of photo and LED diodes. One transmits, the other receives. When smoke appears, something in the receiver changes and the alarm is triggered.
Let's move on. On the detector board, we will be interested in only three contacts.
Contact marked 1 – +9 volts.
Contact marked 2 is GND.
Contact marked K1 – when smoke is detected, a meander appears on it with an amplitude of 5 volts and a frequency of approximately 2.5 kHz.
As a component Zigbee select the company module E-Byte E180-Z5812SP manufactured on the company's chip Telink TLSR8258. The module has proven itself well in my other projects (Water meter, Electricity Meter).
Module Zigbee powered by 3.3 volt. Since there is no such voltage on the detector board, a power converter with 9 volts on 3.3. And it is desirable that the converter itself has low consumption, after all, our device is battery-powered. The choice fell on HT7133-1 with maximum current 100 mA and input voltage from 5 to 30 volt. The power supply issue has been resolved.
There are a couple of questions left.
The first is to convert the meander into a constant signal with a level of no more than 3.3 volts. We take this scheme as a basis
VD1 – a conventional low-power silicon diode.
R6-R5 – voltage divider. R5 – pull-up resistor to ground of the chip itself TLSR8258.
C1 – smoothing capacitor.
The second question. Somehow it is necessary to control the battery discharge. For this, a voltage divider with a coefficient of 1 to 3 is also needed. But it is impossible to make a constantly connected divider because of the same autonomous power supply – extra battery consumption, extra 30 µA. Therefore, it is necessary to provide for the divider to be connected only at the moment of measurement. The community suggested a diagram of such a divider.
Now let's examine the case for additional functions. And we find that on the bottom on both sides (inner and outer) there are such pushers that protrude by about 2 mm on each side.
In this case, if you put the mounting plate in place, it presses the pusher and it goes into the body by about 2 mm. This can be used for a signal TAMPER. Tamper – this is when the device is out of place, shifted, fell off, turned over, i.e. is not in the position in which it should work.
So, let's summarize what we will be monitoring and transmitting to the network.
Battery voltage in mV.
Battery charge level in percent.
Send an alert when smoke is detected.
Send an alert when a device is detected to be detached from the mounting plate.
Send a command when smoke is detected – so that something can be turned on or off.
So, we already understand a little what we want from the device and can start designing the electrical circuit.
First, you need to count the number GPIOwhich we will need.
Control button.
LED indicator of device operating modes.
Turning on the divider to measure the voltage on the battery.
The actual measurement of the battery.
Control TAMPER.
And of course, control of operation when smoke is detected.
SWS – to download the firmware.
RESET – to be able to restart the module.
TXD – to output debugging information via COM port.
So it turns out that we need 9 GPIO. Module E180-Z5812SP has the required number of them.
To create the circuit and the board I use the program EasyEda. As a result of the known parameters, we obtain the following basic diagram of the device.
In general, the scheme is ready, we need to estimate the size, location and fastening of the board. The ideal place was found on the longitudinal side wall of the battery compartment.
But before you lay out and order the board, you need to prepare the software. What's the point of ordering a board if the program doesn't work as expected.
For testing we take Dev-Board joint development.
Thank you To Olegat one time he sent me several of them.
So, back to the program. Earlier I created it specifically for such cases sample to simplify creation Zigbee End Device devices on TLSR8258. We take it as a basis and just modify it a little according to our needs. First, we need to decide which clusters Zigbee we will use.
Power configuration. For this cluster, we will be interested in only two attributes.
BatteryVoltage – the value can be from 0x00 to 0xFF. Unit of measurement 100 mV.
BatteryPercentageRemaining – the value can be from 0x00 to 0xFF. However, there is not a direct dependence, i.e. 100 – this is not 100%It's like this there – 0x00 = 0%, 0x64 = 50% And 0xC8 = 100%. If the value is equal to 0xFF – measurement error (simplified)
IAS Zone. This is just the notification cluster. We will be interested in the following attributes
ZoneType – attribute defines the sensor type. We will have 0x0028 – Fire sensor.
ZoneStatus – attribute of the state of the sensor and its elements. We will be interested in the following statuses
Alarm1 – this is actually a smoke alarm.
Tamper – notification if the detector is disconnected from the mounting plate.
Battery – low battery alert.
Test – just for testing, it will work when you press the button on the device board.
OnOff. This cluster will send a command when smoke is detected depending on the settings.
OnOff Switch Configuration. The cluster will allow you to configure commands sent when smoke is detected.
A small nuance. For the signal Tamper It is better to use a micro switch NCso the leakage current will be less than when using a switch NO. But! NC are found on sale much less often. I found it on Ali, but the Chinese guy who had them listed NC, And NOsent it to me anyway NO. Therefore, there will be two firmware files. With NO and with NC just in case.
So, the program is written and tested on Dev-Board. It should be noted that we applied absolutely standard methods in terms of ZCL. None “custom” attributes and clusters. What does this give? Most Zigbee hubs many standard clusters can do it out of the box. This means that the device will work without problems in many systems. For example zigbee2mqqt This device works and displays correctly without any external converter.
Now you can start designing the board.
We are sending gerber file to one Chinese and after 10 days the payment is with us.
The board is ready, we solder all the necessary elements on it. And we get this picture.
We fix the board to the bottom of the detector body.
To do this, you need to remove a little plastic in position 1. This is easily done with regular nippers. Then we combine the microswitch with the pusher (position 3), check that the pressing occurs correctly and the pusher does not move away from the switch rod throughout the entire pressing range. And then with a 1.8 mm drill from above (arrows with number 2) we mark the holes on the case. Next, we drill them to a diameter of 2.4 mm and countersink them from the back of the case with a 5 mm drill. And we fasten it all with two countersunk screws. M2.2×9.5mm.
Ignore the third hole. I was experimenting with a longer bracket.
Next, we need to slightly modify the original detector board. Since we took up some space with our board + bracket, the original board does not fit into place. A small “boss” interferes – most likely, it is some kind of coil.
You just need to unsolder it, lengthen the leads and solder it so that the case is moved outside the board.
Now everything fits into place. You can mount and check.
Well, then you need to somehow connect all of this to Smart Home. As the last one, it works for me Home Assistant. At the time, I did not want to become a hostage of any one company. After all, it is no secret that the device of one company is not a fact that it will work with Hubom another company. That's why I chose this scheme – as a coordinator I simply have Zigbee stickand as a gateway I use zigbee2mqtt (installed in Home Assistant as an Addon). Why I chose zigbee2mqtt? It's simple. K zigbee2mqtt you can connect a device that is completely unknown to him by writing an external converter, and it will work perfectly with it.
Let me repeat, zigbee2mqtt works with the device without any converters, but to make everything look nice, to have an “icon” of the device, we will still write a converter. And after that, the device will look like this in the zigbee2mqtt Web interface
Let's go to the tab ExposesIt's like this there.
Home Assistant picks up the sensor from zigbee2mqtt automatically.
Well, and one more thing. For example, Smart Home Yandex. Out of the box it shows the main parameters without any problems.
P.S. If anyone wants to repeat this, I will provide several links.