Hello dear readers! The next story about how the manager of the middle link, blowing off the dust from the stale glands on the shelf, creates such pain that causes pain in the eyes of professionals of all stripes. ¡But, it works, amigo!
I admit, this time I wanted to do everything right. I took the Raspbery Pi from the shelf. The pie that I already used in my robot lawn mower:
link to post and
link to another post . I took the mosquitto, everything had to work on mqtt, but you cannot run away from yourself. Under the cut there is a sea of rakes, bicycles, poor soldering, a solid hell for a perfectionist.
It all started with the desire to supplement my project
Noorik , which I set myself at the gate. In short, this is a DIY solution for a GSM gate opener.
To open the gate, it is enough to close certain contacts on the board.
Replaced arduino with esp8266 and made a web interface with an open button. This turned out to be interesting, but then I wanted a single interface for opening sliding gates, sectional garage doors and wickets.
When I started to paint all my Wishlist, it turned out that I needed the same:
- boiler room control system
- security system
- mobile interface to surveillance cameras
- data on the temperature in the house and on the street
Backend
Malinka worked fine, but at the next power-up it just stopped turning on. The power LED lights up first, then goes off smoothly in 3-5 seconds, the element (polyfuse T075) near the power socket gets very hot. And here it was already itching to use mqtt, blackjack, invite courtesans and other delights.
It does not matter, the benefit of his fate was waiting for another patient. Orange pi zero in the studio. How much I did not suffer with this miracle of Chinese thought - to breathe life into such a small pie turned out to be beyond my strength. I downloaded the firmware on the official and left sites, I bought the firmware from my hands and exchanged for cryptocurrency. I think I just got a defective sample.
I realized that fate itself pushes me into the arms of the bicycle industry, and that it’s too good to hide joy, I plunged into this activity with my head.
The first thing I decided to use as a head unit (broker, server) was a smart phone. You know these old things just do not go away. I used it, my wife, my daughter, then I controlled
my robot-snow blower from this smartphone, I tried to
drown it in the river (I never got to the Moscow River, but this pipe made a rustle in Pakhra). And here it is - a new life for the Samsung Galaxy S3.
Installed on the smartphone Palapa Web Server and Ftp-server. The idea is simple in the MySQL database, only three tables: values, logs, rules.
- In the table of values, key / value pairs.
- In the logs table, the history of changes in values.
- In the rules table, rules for changing some cells depending on the value in others.
All this farm is served by a single php script, which, using an http request, writes or issues data from the database, and also maintains the rules on a schedule.
I don’t even understand what the level of programming should be in order for a person to want to see it, but I’m ready to show you the code - write in the LAN.
Frontend
Do not throw stones at me, I confess myself. I used Bootstrap. Yes, sinful.
The original idea was to wrap all this through Phonegap and get a full application. I would say more, I did it, but in the end, the online version turned out to be more workable. Himself and his wife on the phone just made a shortcut on the desktop to open the desired page on the internal ip.
Each element responds to the event click + is checked by the status of ajax requests to the server and is changed if necessary. Very convenient, because you see all the changes that have taken effect by the rule or made by another user.
Actually, the code on request without problems.
ESP-8266
I tried different modules and clean ESP-8266. As a result, the most convenient option was the module LOLIN V3.
Power supply using pulse power supplies.
Modules for the gate required relays and I had concerns that the contact relays would work. As a result, work and solid-state and contact. The problem is that a large number of modules, even without marking about it, are low-triggered.
When the module is turned on, a short-term opening occurs, which leads to an involuntary opening at power on. It is solved by tightening to zero and declaring the state before declaring the type of output.
digitalWrite(rele, 1)
As a result, the module for the garage assembly looks like this. The PIR sensor for detecting movement is neatly gnawed into the native skin.
In my boiler room, my boiler is very simple and there is no question of any complex automation.
In addition, each circuit serves a separate pump.
In series with the automata, relays were switched on to control the pumps and the boiler.
Carefully shoves the entire economy in the shield.
Firmware
I decided to use the Arduino IDE for the firmware in order not to get involved with nodemcu and lua. On the Internet and on GT in particular, a huge amount of information for beginners.
From the interesting, it seems to me, the function of connecting with wifi. The fact is that in my house 4 wifi networks can be added. In order not to rigidly set the name of the network, we pre-scan the available networks.
SetupWiFi code () void setupWiFi() { WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(100); while(WiFi.status() != WL_CONNECTED) { int n = WiFi.scanNetworks(); Serial.println("scan done"); if (n == 0) Serial.println("no networks found"); else { Serial.print(n); Serial.println(" networks found"); for (int i = 0; i < n; ++i) { Serial.println(""); Serial.print(i + 1); Serial.print(": "); Serial.print(WiFi.SSID(i)); Serial.print(" ("); Serial.print(WiFi.RSSI(i)); Serial.print(")"); Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*"); j=0; ssid=WiFi.SSID(i); Serial.print("Connecting"); ssid.toCharArray(charBuf, 50); WiFi.begin(charBuf,WIFI_PASS); while(WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); j++; if(j>20){ break; } } if((WiFi.status() == WL_CONNECTED)){ break; } } } } Serial.println("Connected"); Serial.println(WiFi.localIP()); }
When the automatic mode of the boiler house is on, the temperature in the street and the temperature of the heat carrier are checked.
- At temperatures below 14 * C, the warm floor of the first floor is switched on.
- At temperatures below 4 * C, all circuits are switched on.
The coolant temperature is selected according to the table, depending on the cross-section of pipes and outdoor temperature. When the required room temperature is reached, the boiler is turned off. A kind of gesteresis is applied to everything to smooth the transitional values.
The security system works even easier. The table has a rule that when the security system is on, if movement is detected in one of the PIR sensors, SMS is sent via the API of one of the services.
Plans
- creating an online version on a remote server and synchronizing changes for remote management.
- Displaying data from GSM / GPS beacons in the car;
- Opening the gate when our machines appear in a certain area;
- Connection to the security system;
Photo voting. What project to do next?
To finish the delta 3D-printer on construction stiletto heels
Stabilizer for SLR camera
Thanks for attention. With you was SlavaGik.