FEATURED

Smart home from an old smartphone or antipattern home automation / SurprizingFacts

Hello, dear readers! Another story about how a mid-level manager, blowing dust off stale glands on the shelf, does this, which makes professionals of all stripes a pain in their eyes. ¡But, it works, amigo!

I confess, this time I wanted to do everything right. Took Raspbery Pi off the shelf. A pie is the same as I used in my robot lawnmower: a link to the post and a link to another post. Took mosquitto, everything had to work on mqtt, but you can not escape from yourself. There was a sea of ​​rakes, bicycles, bad soldering, a continuous hell for a perfectionist.

 image

It all started with the desire to complete my project [No1945]Noorik, which I set myself At the gate. In short, this is a DIY solution for the GSM gate-opening unit.
To open the gate, it's enough to close certain contacts on the board.

 image

Replaced arduino with esp8266 and made a web interface with the open button. It turned out to be interesting, but then I wanted a single interface for opening the sliding gates, the garage sectional doors and the gate.

When I began to paint all my Wishlists, it turned out that I needed the same:

  1. boiler room control system
  2. security system
  3. mobile interface to CCTV cameras
  4. data on temperature in the house and on the street

Backend

Malinka worked fine, but with the next turn it just stopped turning on. The power LED first lights up, then gently extinguishes in 3-5 seconds, the element (polyfuse T075) is heated very warmly near the power socket. And then my hands were scratching to apply mqtt, blackjack, invite courtesans and other delights.

It does not matter, the good of his fate was waiting for another patient. Orange pi zero in the studio. How much I did not suffer from this miracle of Chinese thought – to breathe life into such a small pie turned out to be a matter beyond my strength. I downloaded the firmware on the official and left sites, I bought the firmware from my hands and exchanged it for crypto currency. I think I just got a defective sample.

I realized that fate itself is pushing me into the arms of cycling, and that to hide the joy, I plunged into this lesson with a head.

The first thing I decided to use as a head unit (broker, server) was a kind of smartphone. You know these old things just do not go away. I used it, my wife, daughter, then I ran my robot snowplower from this smartphone, I tried to drown it in the river (I did not get to the Moscow river, but in my native Pahra this pipe caused rustle). And here it is – a new life for Samsung Galaxy S3.

Installed on the smartphone Palapa Web Server and Ftp-server. The idea is simple in the MySQL database with just three tables: values, logs, rules.

  • In the values ​​table of the key / value pair.
  • In the logs table, the history of value changes.
  • In the rules table, the rules for changing one cell depending on the value in others.

All this farm is served by a single php script that writes or outputs data from the database via http request, and also maintains the rules according to the schedule.
I do not even understand what level of programming a person should want to see, but I'm ready to show you the code – write to the LS.

Frontend

Do not throw stones at me, I I confess myself. I used Bootstrap. Yes, he is a sinner.
The initial thought was to wrap it all through Phonegap and get a full application. I will say more I did, but as a result, the online version proved to be more efficient. To myself and my wife on the phone I just made a shortcut on the desktop to open the desired page on the internal ip.

Each item responds to the event by clicking + the ajax status checks for requests to the server and changes if necessary. It is very convenient, because you see all the changes that took effect by rule or made by another user.
Actually, the code on demand is no problem.

ESP-8266

I tried different modules and a clean ESP-8266. As a result, the most convenient option was the module LOLIN V3.

Power supply by means of switching power supplies.

Modules for the gate required relays and I had concerns that the contact The relays will fire. As a result, both solid and contact are working. The problem with the fact that a large number of modules even without marking about it are low-triggered.

When the module is turned on, a brief opening occurs, which leads to an involuntary opening when the power is turned on. Solved by a pull-up to zero and declaration of the state before the announcement of the type of output.

  DigitalWrite (rele, 1);
  DigitalWrite (rele2, 1);
  PinMode (rele, OUTPUT);
  PinMode (rele2, OUTPUT);  

As a result, the module for the garage assembly looks like this. The PIR-sensor for motion detection is neatly gnawed into the native skin.

In the boiler room I have a very simple boiler and no question of any complicated automation.

In this case, each circuit serves

The relay for controlling the pumps and boiler was connected in series with the automata.

Gently pushes the entire farm into Shield.

The firmware

There are currently no product reviews.
I decided to use the Arduino IDE for firmware, so as not to mess with nodemcu and lua. On the Internet and on the GT in particular, a huge amount of information for beginners.
From the interesting, it seems to me, function of connection with wifi. The fact is that I have 4 wifi networks in my house and can be added. To hard not specify the network name, 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 switched on, the outdoor temperature and the temperature of the coolant are checked according to the schedule.

  • At the temperature below 14 * С, the first floor of the floor is switched on.
  • At temperatures below 4 * С all contours are included.

The temperature of the coolant is selected according to the table, depending on the cross-section of pipes and street temperature. When the desired room temperature is reached, the boiler switches off. To all, a certain hysteresis is used to smooth the transition values.

The security system works even easier. In the table there is a rule that if the movement of one of the PIR sensors is detected, SMS is sent via the API of one of the services.

Plans

  • Create an online version on the remote server and synchronize the changes for remote control.
  • Displaying data from GSM / GPS beacons in the car;
  • The opening of the gate when our machines appear in a certain zone;
  • Connection to the remote control system;

Voting on the photo. What project should I do next?

To finish the delta 3D printer on building stiletto heels

Stabilizer for the SLR camera

Thank you for attention. With you was SlavaGik.