
Smart home, how I got to this. Part 3

In the first part we figured out why all this is needed and how I got to this, in the second we talked about software. It is time to stop at the most favorite section of DIY by the Habrachians - on hardware. So, we take textolite, ferric chloride, a soldering iron ... Although no, stop, we open the board editor. About the soldering iron, where to stick it, and where it is better not to need others will tell me better. And I will tell you what boards and sensors work for the benefit of my smart home.
Tire
As a bus, I use a four-wire telephone cable.
All cables are crimped with TP6P4C (RJ11) plugs.


Connections and branches occur through standard telephone jacks and splitters.

I made the pinout in accordance with the first purchased boards
- (green) - 12V
- (white) - 1-wire data
- (brown) - ground
- (yellow) - not used
In the first boards I bought, the 4th contact was not used and, accordingly, was not switched in the end devices, so it remained unused. In some circuits, 18V is applied to the fourth pin. But, if I did everything from scratch, I put 5V there to power the temperature sensors.
DS18B20 temperature sensors

Unaware of the peculiarities of working on parasitic power (bus lock from 0.3 to 1.5 seconds when requested), I just connected pin 1 to ground, and pin 2 to 1-wire.
Now I add new sensors in places where there are other boards from which you can take 5V. In the future, I want to equip old sensors with power conversion circuits and power them correctly.
Thus, the “correct” connection diagram looks like this:
- Leg 1 - Ground
- Leg 2 - to the 1-wire bus
- Leg 3 - 5V
Boards on DS2413
As I said earlier, I bought the first boards. I bought them here www.ab-log.ru/smart-house/1-wire-modules/2ch-module
The only drawback of this board, at that time, was the lack of transit of the fourth line, but now it has been fixed and it is present. As a pleasant feature, you can note the presence of LEDs, which is very convenient for debugging. On my boards, I was too lazy to do wiring for LEDs, so I had to debug with a tester.
Schemes of the first home-made boards were spied here www.benuks.ru/oborud.html#9
Scheme

Pay

Actually, in terms of functionality, they are completely identical to the purchased ones and are a two-channel key to control the 220V load.
Boards on DS2408
There was already where fantasies unfold.
The idea of the first board on the DS2408 arose when he made lighting in the kitchen. I would like to make four independent lighting zones and boards on the DS2413 would need two pieces. As a result, a circuit was born on the DS2408 which, in fact, differed only in replicated groups MOC3043M + BT138. He deduced all eight, three, so to speak, for future development. (Unfortunately, the circuit did not survive.)
The next two boards on the DS2408 were only for reading data. The first - receives data from the sensors for opening all windows and doors to the loggia, the second - receives data from door locks and motion sensors in the common corridor and near the door.
Scheme

Pay

When I started messing with the DS2408, the idea came up of making one combo board per room. Depending on the needs of a particular room in control systems, one board is bred on the DS2408 on which part of the contacts are responsible for managing the load, and part for reading data. For example, boards were made for the bathroom and the nursery with the ability to control two sources and read data from six.
Scheme

Pay

The appearance of the finished board

Two control outputs are the first and second group of bulbs. Two readers are data from two switches, one motion sensor, one door sensor, two in reserve. 

I want to note that there is one serious flaw in this board that complicates installation and maintenance. I brought to the terminal blocks only one pin 5V, 12V, GND, and, for example, the 5V contacts are needed in each sensor. I had to connect several wires to one, which is inconvenient and unreliable.
Constructor
Experienced readers already know this, but attentive readers have probably already noticed that all schemes have some common modules. Actually, having understood this, it is quite easy to design a chamber for your needs, knowing, in fact, only the course of electricity from the school curriculum.
Let's analyze in detail on the basis of my last motherboard, since all these conditional modules are present in it.

- Connectors
- Power module
- 1-wire chip with strapping
- Reader module
- Control module
Connectors
You can just draw conclusions on the board and hang the connectors on the wires (it was exactly like that in the purchased boards), but it seemed to me not very convenient and in the following boards I unsoldered these ones:

Power module
The main component here is the 78L05 chip, which is a wonderful thing that from any input voltage in the range from 7V to 20V produces the 5V we need.

It happens in different buildings, it just so happened that the availability was always different and all types had to be used.
- Vin - 12V
- GND - Earth
- Vout - to board power
As auxiliary elements, a strapping of capacitors (two solid-state and one electrolytic) is installed for stabilization.
1-wire chip with strapping
The chip itself.


In this case, the DS2408 is connected as follows:
- Leg 3 - 5V
- Leg 4 - to the 1-wire bus
- Leg 5 - Ground
- Legs 2, 7, 8, 9, 11, 12, 13, 14 are bidirectional input / output, i.e. the very legs to which the reading or control modules are connected, depending on what we need
The pull-up resistor and the zener diode were on the original board and in the documentation for the chip, I do not know their exact purpose.
Reader module
This is actually just the contact of the foot with the connector for ease of installation plus a pull-up resistor (without it, even very weak pickups will be able to generate enough voltage for false triggering)
Control module
Consists of two main elements: MOC3043M optocouplers and BT138 triac.
The optocoupler is needed for galvanic isolation (so that the 220V network is not connected in any way and does not affect the control network).


- Foot 1 - 5V
- Leg 2 - to the output of 1-wire
- Leg 4 - to the triac
- Leg 6 - 220V
Principle of operation: when the value 1 appears in the corresponding register DS2408, the corresponding leg is connected to the ground. A current begins to flow in the circuit from leg 1 to leg 2, a diode lights up inside, and closes the circuit between legs 4 and 6, applying voltage to the triac.
A triac is needed to control the load powered by AC, since the optocoupler cannot itself hold a high load.


- Leg 1 - 220V
- Leg 2 - load output
- Leg 3 - from optocouplers
The principle of operation is like that of a transistor in DC circuits, when voltage is applied to leg 3, the circuit between legs 1 and 2 is closed
Door and window opening sensors
As I wrote earlier, I used Soviet reed switches without marking plus neodymium magnets 1x10 mm as opening sensors.
The connection diagram is simple to disgrace, one contact at 5V second to the read contact on the board.
If I didn’t have reed switches with magnets, I would buy, for example, these sensors:

In fact, these are the same reed switches and magnets, only packed in a case.
Motion sensors.
As a motion sensor, you can use almost any security motion sensor, the main thing is that it can be powered by 12V and switch 5V (and most of them). In stores, you need to ask exactly the security sensor, since if you talk about lighting control, you will be slipped a sensor that 220V commutes and is powered by them, and you can’t connect such a sensor without dancing with a tambourine.


Sensors usually have seven contacts; for the needs of a smart home, I used four of them
- T2, T1 - tamper contacts that are responsible for unauthorized opening. In my case, I did not connect, as unnecessary.
- NC, C, NO - sensor contacts. I used the normally open contact NO and C. They connect to 5V and the read contact on the board, respectively.
- -12V + - sensor power. Everything is clear here.
Leakage sensors
As the experiment showed, if two contacts (5V + read contact from the board) are inserted into water, then the contact is considered closed, so it does not bother. The old Soviet telephone “noodles” with partially exposed (along the entire length from different sides) wires, that's the whole leakage sensor.

Connection of classic switches
I didn’t get accustomed to the push-button switches (which are reset), because in rooms where there are several light sources with a group of switches and only a part is turned on, it’s problematic to turn off the remaining ones, since the household does not have a logical button-lamp connection in the brain.
I have regular keyboards. Down-> off, up-> on If the light was previously turned on or off by the computer, you need to click back there. But in any case, if you need to turn off, then the final position of all the switches below and vice versa.
The switch connects to the gap between 5V and the read contact on the board.
Back-up circuit
Let me remind you that the inclusion of light occurs according to the following scheme:

One of the main disadvantages of such a system with centralized control is that when the central node (server) fails, it becomes impossible to control the light. You can, of course, transfer the on / off logic to the board with the controller, but this is not possible on the basis of 1-wire. Therefore, for such emergencies, I added a small switch connected in parallel with the electronic key. The switch is located on the case in which the board is packed. In the event of an accident (by the way, such an accident occurred immediately after the first part of the article), the circuit breaker can be forced to close the circuit, which, of course, is not very inconvenient, but there is still light during server repair.
CCTV
There is no longer any iron DIY, but probably worth mentioning.
I used the cheapest ORIENT SDVR-404 board for video capture.

At that time, it seemed that more than one camera was not needed. There are three cameras now. And it would be better if I then took a motherboard with four processors, and not with one.
The cameras are Chinese non-names, but they are, in principle, enough for my needs.

Conclusion
That's actually all the iron. As you can see, nothing complicated, scary or mysterious. I hope my articles came in handy for you, and perhaps made me create my own system.
Special thanks to all those who wrote to me, asked questions and asked for continuation, this part could not exist without you.
Update: I
posted the source code for the boards in github
github.com/sashacmc/smarthome-1wire
Update 2:
Continued here: Smart home, as I have come to this. Part 4