Another smart home, in three parts. Part One, Iron
I want to tell and show the results of a project that has been developing for about 10 years. It develops as a hobby, so it happens that a new device is made in a week, and then in six months - nothing is done. I really do not like the phrase "Smart Home", so it will not be found further. Also, there will be no circuits, code examples, entangled in wires of breadboards and other boring things. There will be many photos and discussions on general topics.

About 10 years ago, it somehow coincided that I got a job as a developer of embedded electronics and bought an apartment. There was not enough money, the apartment was one-room, I lived alone. I wanted something such that, as I later found out, it was called "Studio apartment." An exciting lesson that cannot be finished - repair. And where does the person who soldering iron picks up before the pens starts to make repairs? Right, with wiring. I wanted the light to turn on from the TV remote control. No sooner said than done. Then I wanted that in the dark at the opening of the front door the light in the hallway would turn on. Reed switch at the door, working. Then I wanted to turn off the doorbell. Ok done. Then he wanted to go to the toilet at night and turn on a small light bulb. Ok, I connected the motion sensor. Well, since I have such a smart switch - can I connect it to a computer? Connected. In general, after about five iterations of iron and hundreds, if not thousands of iterations of software, we got such a lighting controller.

What can he do?
The next step was the repair in the bathroom. And what is most important in the toilet and bathroom?Freshener, book or tablet. Warm floor. And there is also a fan, and a couple of light channels. And I want to open the door at night and the weak light itself turned on. And then the fan turned on for a couple of minutes. So stop it. 4 exits. Yeah, there's a lighting controller! I redid it a bit, and as a result, I got a lighting controller and a warm floor. Looking ahead - then it was divided into two slightly different logical devices - for heating and for bathrooms, balconies, kitchens. The first connects three temperature sensors, one in the control loop, two just for measurement; for example, outside temperature and, for example, coolant temperature. The second remained with one temperature sensor, but got a pair of leakage sensors. Here it is in the photo:

What can he do?
Then he took up the balcony. There are also a couple of light channels, a warm floor. The second controller got a brother.
Everything worked, everything was fine until I went on vacation ... I returned - the refrigerator did not work. An autopsy revealed a blown varistor and fuse. It is clear that the power surge, it’s good that everything was limited to both of them. Changed, earned. But the trouble does not come alone, after a couple of weeks the same thing happened with the air conditioning.
Need to do something. What? That's right, a controller to protect the power grid.

What can he do?
At the same time, he changed his job, he began todress better to earn money, bought a car and saved up a little money. And what does a city dweller do with a car and some free money? He buys a summer cottage. I was no exception. Electricity was constant there, but it was worse with water. There was a pipe from which a day something barely flowed there. The task is clear, we need a barrel, a pumping station and a boiler. And of course, another controller. This time water supply and watering.
But here the fun begins - pressure and water level sensors, soil moisture sensor. Industrial are not at all humane, so I decided to do it myself. The water level in the tank - at first I tried capacitive, it didn’t work. And different sensors, and different circuits - nothing. Okay, I’ll try another principle, ultrasonic, since there are a lot of inexpensive ones in China. Earned. At the same time, a humidity and temperature sensor added there.

Pressure. Where else measure the pressure of liquids? Yeah, the car! I chose the GAZ oil pressure sensor. According to the parameters 0-6 atm, the thread is the same as on the water switch gauges. There were doubts about corrosion resistance - but for three years now everything has been working. You can change in advance, since they cost a penny. Here it is, to the left of the pressure gauge. The flowmeter made on the basis of a conventional water meter by gluing a magnet to the impeller, and a Hall sensor on the case.

Soil moisture sensor. He also made capacitive, but did not grow together, in the end, I just measure the resistance with two probes. Well, let it be the temperature of the soil.

It turned out something like this (yes, apparently they are all the same):

What can he do?
Then at home I wanted to make decorative lighting. I bought RGB tapes, but how to manage? Buy ready? Not my method, we make an interior lighting controller. Here it is:

What can he do?
All is well, but RS485 ... Where is it? There were several options, I will describe in the next part, as a result, everything came down to another controller. He also connected the drive of the entrance gate.

What can he do?
I would like to talk about some of the nuances from my point of view.
Why RS-485 and not wireless interfaces? Why not wifi?
I don’t remember where already, but I heard such a phrase - where copper can be laid, copper needs to be laid there. As you can see, to implement this system, you must almost completely redo the wiring. So why not lay extra signal wires? Which is better - dead batteries, clogged ether, or good old copper?
Why not an ARM with Linux, but an ancient 8-bit controller? How is the internet of things?
Everything is simple - the principle of reasonable sufficiency. Why use megabytes of memory and Linux to light a bulb? And in any case, the power unit, input circuits, etc. will be exactly the same.
Why not touch screens, custom switches, mobile phones, tablets, voice control?
I believe the interfaces should be consistent. Waking up at night to drink water, I do not want to figure out which of the 5 buttons to press me to turn on the light. I want to press the standard switch, drink some water and go to bed further. I don’t want each of those who come to tell me what needs to be done to turn on the lights in my house. It’s one thing with a tablet to set up an irrigation or lighting schedule, set the limits of permissible voltage for protection, and quite another to turn on the light.
But what about Internet control?
Of course, there is control over the Internet. I can do anything from anywhere within the framework implemented in hardware. But there is one thing - all controllers must be autonomous and perform their basic functions without any network, Internet or other servers. If I forgot to pay for the Internet - I do not want to be left without light. If I have a bad connection at the cottage - I just want to press the button on the controller to turn on the pump and tank. And the irrigation schedule - you can configure it later.
With the iron part, that’s all, in the next, second part, I will describe the server part. And I will show a few more photos of all this in the collection on the example of a couple of projects.

How it all began, or Lighting Controller
About 10 years ago, it somehow coincided that I got a job as a developer of embedded electronics and bought an apartment. There was not enough money, the apartment was one-room, I lived alone. I wanted something such that, as I later found out, it was called "Studio apartment." An exciting lesson that cannot be finished - repair. And where does the person who soldering iron picks up before the pens starts to make repairs? Right, with wiring. I wanted the light to turn on from the TV remote control. No sooner said than done. Then I wanted that in the dark at the opening of the front door the light in the hallway would turn on. Reed switch at the door, working. Then I wanted to turn off the doorbell. Ok done. Then he wanted to go to the toilet at night and turn on a small light bulb. Ok, I connected the motion sensor. Well, since I have such a smart switch - can I connect it to a computer? Connected. In general, after about five iterations of iron and hundreds, if not thousands of iterations of software, we got such a lighting controller.

What can he do?
- 4 lighting channels, continuously adjustable;
- Doorbell or lock relay;
- Door open, motion sensor, bell button;
- Remote control receiver RC-5.
Lighting and heating controller
The next step was the repair in the bathroom. And what is most important in the toilet and bathroom?

What can he do?
- 2 lighting channels, continuously adjustable;
- Output for fan;
- An output for connecting a heater;
- Relay for controlling the power of heaters (for heating) or the executive mechanism of protection against leaks (for bathrooms);
- Door open sensor.
Then he took up the balcony. There are also a couple of light channels, a warm floor. The second controller got a brother.
Power controller
Everything worked, everything was fine until I went on vacation ... I returned - the refrigerator did not work. An autopsy revealed a blown varistor and fuse. It is clear that the power surge, it’s good that everything was limited to both of them. Changed, earned. But the trouble does not come alone, after a couple of weeks the same thing happened with the air conditioning.
Need to do something. What? That's right, a controller to protect the power grid.

What can he do?
- Two voltage measurement channels, for example before and after the normalizer or uninterruptible;
- Current measurement;
- Relay disconnection of consumers at the time of excess voltage;
- Exit to an independent release to completely disable everything;
- Customizable protection thresholds, calculation of power consumption - instant, per hour, per day, full.
Water and irrigation controller
At the same time, he changed his job, he began to
But here the fun begins - pressure and water level sensors, soil moisture sensor. Industrial are not at all humane, so I decided to do it myself. The water level in the tank - at first I tried capacitive, it didn’t work. And different sensors, and different circuits - nothing. Okay, I’ll try another principle, ultrasonic, since there are a lot of inexpensive ones in China. Earned. At the same time, a humidity and temperature sensor added there.

Pressure. Where else measure the pressure of liquids? Yeah, the car! I chose the GAZ oil pressure sensor. According to the parameters 0-6 atm, the thread is the same as on the water switch gauges. There were doubts about corrosion resistance - but for three years now everything has been working. You can change in advance, since they cost a penny. Here it is, to the left of the pressure gauge. The flowmeter made on the basis of a conventional water meter by gluing a magnet to the impeller, and a Hall sensor on the case.

Soil moisture sensor. He also made capacitive, but did not grow together, in the end, I just measure the resistance with two probes. Well, let it be the temperature of the soil.

It turned out something like this (yes, apparently they are all the same):

What can he do?
- Exits for a pumping station, a water heater and a valve for collecting water into the tank;
- Remote sensor for water level in the tank, humidity and temperature;
- Remote sensor of moisture and soil temperature;
- Two pressure sensors, flow meter, control of the automation of the pumping station;
- 4 channels of control of irrigation valves;
RGB Ribbon Controller
Then at home I wanted to make decorative lighting. I bought RGB tapes, but how to manage? Buy ready? Not my method, we make an interior lighting controller. Here it is:

What can he do?
- 4 PWM outputs for LED strips, RGB + white;
- and nothing more.
RS485 Gateway - Ethernet
All is well, but RS485 ... Where is it? There were several options, I will describe in the next part, as a result, everything came down to another controller. He also connected the drive of the entrance gate.

What can he do?
- 4 discrete and 3 analog inputs, 2 relay outputs.
- Real time clock.
- And most importantly, the RS485 gateway is Ethernet.
To summarize
I would like to talk about some of the nuances from my point of view.
Why RS-485 and not wireless interfaces? Why not wifi?
I don’t remember where already, but I heard such a phrase - where copper can be laid, copper needs to be laid there. As you can see, to implement this system, you must almost completely redo the wiring. So why not lay extra signal wires? Which is better - dead batteries, clogged ether, or good old copper?
Why not an ARM with Linux, but an ancient 8-bit controller? How is the internet of things?
Everything is simple - the principle of reasonable sufficiency. Why use megabytes of memory and Linux to light a bulb? And in any case, the power unit, input circuits, etc. will be exactly the same.
Why not touch screens, custom switches, mobile phones, tablets, voice control?
I believe the interfaces should be consistent. Waking up at night to drink water, I do not want to figure out which of the 5 buttons to press me to turn on the light. I want to press the standard switch, drink some water and go to bed further. I don’t want each of those who come to tell me what needs to be done to turn on the lights in my house. It’s one thing with a tablet to set up an irrigation or lighting schedule, set the limits of permissible voltage for protection, and quite another to turn on the light.
But what about Internet control?
Of course, there is control over the Internet. I can do anything from anywhere within the framework implemented in hardware. But there is one thing - all controllers must be autonomous and perform their basic functions without any network, Internet or other servers. If I forgot to pay for the Internet - I do not want to be left without light. If I have a bad connection at the cottage - I just want to press the button on the controller to turn on the pump and tank. And the irrigation schedule - you can configure it later.
With the iron part, that’s all, in the next, second part, I will describe the server part. And I will show a few more photos of all this in the collection on the example of a couple of projects.