Contacts

A simple way to remotely control electrical appliances via the Internet. XControl control of devices via Ethernet network Expander of contact outputs

Hello, dear readers and guests of the "Notes of an Electrician" website.

In my previous publications, I introduced you to the touchscreen, controlled both manually and from the remote control.

But today I would like to draw your attention to the Sonoff Basic version of the relay (switch) with the ability to control directly from a mobile phone via Wi-Fi or the Internet.

The Sonoff Basic relay is a small-sized device (88x38x23 mm) that can be easily placed behind the ceiling space, in a building niche, or in the bowl of a chandelier or lamp.

Its cost at the time of publication of the article is a little less than 300 rubles. As you understand, this is quite acceptable money, moreover, for such a modern device. I got it on the well-known Aliexpress trading platform (the link will be at the end of the article).

The kit included two protective covers with mounting screws, but, unfortunately, there were no instructions.

The Sonoff relay has the following technical characteristics, some of which are displayed directly on its housing:

  • maximum controlled load current 10 (A)
  • supply voltage from 90 (V) to 250 (V)
  • wireless standard 802.11 b / g / n
  • WPA-PSK / WPA2-PSK security protocol
  • operating temperature from 0 ° С to 40 ° С
  • weight about 50 g

Sonoff Basic relay capabilities:

  • Wi-Fi load control
  • load control over the Internet
  • load control by a set timer, both with direct and countdown
  • load control from multiple mobile phones

These are the capabilities of the Sonoff relay. It can be safely used in smart home systems and for various other needs and requirements.

First, I will tell you how to connect Sonoff, and then we will check all of its declared control methods in practice.

So let's go.

Installing and connecting the Sonoff relay

To operate the Sonoff relay, it needs a supply voltage of 220 (V), which means that it can be easily installed in a place convenient for you, for example, in a chandelier bowl or directly under a stretch ceiling, as well as directly in a junction box, if there is enough space there.

For fixing the relay to the surface, it has two mounting holes.

The Sonoff relay connection diagram is very simple.

On the terminals (L) and (N) from the side (Input-Input), respectively, the phase and zero of the supply voltage 220 (V) are connected. Naturally, when connecting, do not forget about.

Please note that the wires to be connected must have a cross-section of no more than 1.5 sq. Mm. But I still tried to connect conductors with a cross section of 2.5 sq.mm. As a result, a rigid (single-wire) wire can still be connected without problems, but a flexible (multi-wire) wire is already inserted into the terminal with great difficulty, so it did not even have to be flattened and deformed a lot.

For example, I used a PVS brand power cable, which just has a cross-section of 2.5 sq. Mm. There is a plug at the other end of the cable, which I will later plug into any outlet with a voltage of 220 (V).

On the terminals (L) and (N) from the side (Output-Output), respectively, the phase and zero of the load are connected.

For the convenience of connecting the load, I connected a socket to the relay output.

By the way, terminal covers not only have a protective function, but also play the role of clamps for supply wires or cables.

This is how everything turns out beautifully and neatly. The Sonoff relay is connected.

As a load, I connected an LED lamp, about in one of my articles.

Here is a simple example of a Sonoff relay wiring diagram for a group of luminaires.

By the way, it is not necessary to use only a lamp or a group of lamps as a load. You can safely connect any other load to the output terminals that does not exceed the rated current of 10 (A). And if you still need to control a load with a current value higher than 10 (A), then it can be connected to a contactor, and with the help of a relay, you can already control the coil of this contactor.

In this regard, it can be added that when using a contactor, it is possible to control at least a single-phase load, at least three-phase, at least with an alternating current, at least a constant one.

It will look something like this.

Thus, the scope of the Sonoff relay is very wide and varied. It can be controlled by at least one light bulb, at least by a powerful single-phase electric heater, at least by a three-phase electric motor, etc. It all depends only on your needs and requirements.

And now we will consider all the possibilities of controlling the Sonoff relay in more detail.

I will not open the relay and watch its device, there is already plenty of information on this on the Internet - look at the corresponding resources on electronics. And judging by the reviews, the performance of the relay is quite decent. By the way, who is interested to know, the relay is assembled on the basis of the famous Chinese microcontroller ESP8266.

Load control via phone over Wi-Fi

Before talking about controlling the relay via Wi-Fi, I will say that it can be controlled manually. For this, there is a small recessed black button on its body. So, with one short press of it, the relay turns on, and when it is pressed again, respectively, it turns off. Moreover, for this it is not necessary that the relay be connected to a Wi-Fi network - it will also be controlled in Offline mode.

But in addition to this, the button also carries other functionality, which I will discuss below.

To implement the ability to control the load via Wi-Fi and the Internet, you need to install the eWeLink mobile application on your phone. This application can be found for both Android and iOS devices. To facilitate the search for the application, you can use the necessary QR codes on the package.

For Android devices, the eWeLink application can be downloaded for free from Google Play and installed on your phone without any problems. The program interface supports Russian.

For iOS devices, this app is available in the App Store. I have not tried to download and install this application on an iPhone or iPAD, so whoever tried this application on iOS devices, please write off in the comments about the results.

After installing the eWeLink application, you will need to register immediately, indicating the country and your email address. In this case, the phone must be connected to the Internet.

After that, a verification code will be sent to the mail (valid for 30 minutes), which must be entered in the corresponding line "Email code". On the same page, you must enter a password to enter your future account (at least 8 characters).

By the way, letters reach the mail services Mail.ru and Mail.yandex.ru (Yandex-mail) without any problems. But as far as I am aware, letters with a verification code do not always reach the Gmail.ru mail service (Google-mail), so take this into account.

Then it is necessary to pair the relay and the router by holding (for 5 seconds) the same button on the switch body, after which the green LED on the relay will blink. We put a tick on the first connection mode and click "Next".

Now you need to select our Wi-Fi network from the list and enter the password for it. In order not to enter the password each time, you can check the "Remember password" checkbox. Click "Next", after which the search for our device and its registration will begin (in time it took me no more than 2-3 minutes).

After successful pairing, the relay automatically transmits data to the Chinese cloud (Amazon AWS or Coolkit), which makes it possible to control it over the Internet. But I will return to this a bit later.

As you can see, our relay is now displayed in the list of all devices (so far it is the only one in the list, but others will appear very soon).

When the relay is online, the green LED on its housing is always lit. As soon as the LED starts blinking, then the connection with the router or the Internet is lost. It is just by this indicator that it is convenient to determine whether the relay is in the network (Online) or not (Offline).

While I was testing this device, I did not notice any problems with losing the network. The device is always online and responds stably to control commands.

Now you can try to turn on the relay through the phone. To do this, click on "Relay 1". Immediately a red inscription appeared that it was necessary to update the eWeLink application, although the update was not displayed on Google Play.

We go into the device settings (three dots in the right corner) and see that the application has the current version 1.5.2, and a newer version 1.5.5 is available. Click on the "Download" icon and the application update begins. After the update, the red inscription disappears, and in the settings we can see the new current version 1.5.5.

Remember !!! The main condition for the operation of the relay is the availability of Internet access.

If all of a sudden the Internet access is lost, then a green LED will start blinking on the relay case, and in the application on its tab the Offline mode will be displayed, i.e. not available for control.

So, to turn on our "Relay 1", you need to enter it and click on the round virtual button in the center of the screen. Moreover, the relay can be controlled from the general list of all devices by clicking on the corresponding small button (on the left). In general, as you like it.

When the relay is off, the button is white with a gray background filled around it. When the relay is on, the button changes its color to green, and the background around it turns blue.

In addition to banal control principles, you can set the time for switching on or off the relay by timer by setting the appropriate date and time for its control.

Moreover, it was surprising that the relay is triggered by a set timer even when it is offline (Offline), which means that all set timer programs are stored directly in the relay memory.

Click on the "Add timer" button and go to the timer settings page. Each timer is configurable to either turn on the relay or turn it off. There are two options for setting the timer:

  • one-time (one-time operation at a specified date and time)
  • repeated (periodic operations at a specified date and time, including indicating specific days of the week)

In addition to the countdown timer, there is a countdown timer. Very useful functionality for specific purposes. It is configured similarly to a direct timer, only with the possibility of a single actuation.

In addition to forward and backward timers, there is a cyclic timer in the "Settings" tab (three dots in the right corner).

In this tab, you can configure various options for the relay actuation cycles. I will not talk about this in detail, tk. everything is simple and intuitive here.

The total number of configured timers, including the cyclic timer, can be no more than 8. And be careful, because when the time of different timers overlaps each other, none of them may work !!!

Also, in the settings, you can specify in which position the relay will remain if the 220 (V) power is suddenly disconnected from it. There are three options here. By setting the appropriate checkboxes, you can choose that when the 220 (V) power supply reappears, the relay can either turn on, or turn off, or remain in its original state.

By the way, this is a very handy feature. Just remember the nuance that, when the 220 (V) power supply disappears and reappears, for some reason it always turns on, even when it is in the off state. Imagine that you are not at home, the mains voltage “blinked” a little and the controller turned on the chandelier on its own. Here, such an incident will not happen, tk. in this case, everything can be customized to suit your needs.

In addition to the above, all devices connected to you in the eWeLink application can be grouped together and combined in various scenarios.

Is it possible to control the relay from several phones at once?

Can! Naturally, in this case, the eWeLink application must be installed on each phone.

There are two options here. The first option is to enter the eWeLink application under the same name and password from different phones and control the relay.

True, if you enter the application on one phone, and then at the same time enter the application under the same username and password, but on another phone, then an error will occur on the first phone and the application is automatically exited. In this case, the second phone remains in the application and you can use it to control devices.

At the same time, I would like to note that when the relay is controlled from one phone, its status is displayed almost instantly on all phones that are connected to it.

Load management over the Internet

In addition to controlling the relay via a phone via a Wi-Fi network, it can also be controlled via the Internet from anywhere in your location, i.e. absolutely from anywhere in the world where there is Internet access.

So, to control the circuit breaker via the Internet, you need to enter the same eWeLink application under your name and password that you specified during registration. And then everything is by analogy. The same application, the same settings, the same control buttons, etc., the only difference is that you are not at home in the range of your Wi-Fi network, but at a distance of hundreds and thousands of kilometers from home.

A little about the cloud.

However, you will not be able to control the relay without the Internet. control goes not through a local network, but through the Internet, i.e. the same Chinese cloud that I mentioned above. And it doesn't matter whether the control is via Wi-Fi or the Internet, the control always goes through the cloud, and access to the cloud requires Internet access.

In this regard, various craftsmen have already figured out how to untie this device from the Chinese cloud or make control only through a local home network. For anyone interested, this information can be found on certain resources.

By the way, if you need a similar device, but with the additional function of radio control from the remote control, you can order the Sonoff RF relay.

If you want to control the load where there is no Internet at all, then you can use the Sonoff G1 relay (GSM / GPRS with SIM card support). Also, this manufacturer has available relays with temperature and humidity sensors Sonoff ТН10 / ТН16 and two-channel (for controlling two independent loads) Sonoff Dual relays.

In general, the manufacturer Sonoff has many different devices, I will tell you about some of the most interesting and significant ones on the pages of my site, so subscribe to the newsletter so as not to miss interesting releases.

You can buy Sonoff relay here:

  1. Sonoff Basic: https://goo.gl/jXyNm3
  2. Sonoff RF (radio controlled): https://goo.gl/TRPqN6
  3. Sonoff G1 (GSM / GPRS with SIM card support): https://goo.gl/EkpTdp
  4. Sonoff TH10 / TH16 (temperature and humidity sensor): https://goo.gl/MWAL5p
  5. Sonoff Dual (two-channel): https://goo.gl/a7rV56

And already by tradition, a video based on the materials of the article, where you can more clearly see the configuration and control of the Sonoff relay:

MP709
USB relay, internet controlled
1320 RUB

The proposed block in assembled form allows you to implement the principle: buy - connect. The block will allow the radio amateur to get a power load switch connected to a personal computer via a USB port. The device will be useful for use in everyday life, at home, in the country. With its help, you can turn on lights, water valves and other loads via the Internet. If desired, the product can be placed in the enclosure, which is included in the delivery set. However, the user must independently modify it (make holes and cutouts).

MP709 Specifications
ParameterMeaning
Upit. constant, V+4,75...5,25
Upit. No. constant, V+5
Ipotr. Max. at Usup. nom., mA...50
Supported operating systemsWin XP / Vista / Win 7
Output load capacity10 A / ~ 220 V
Number of channels1
Number of MP709 controlled from one PC
using the MP709.exe program
...32
Overall dimensions, LxWxH, mm48 x 16 x 19
Recommended case, not included
Operating temperature, ° С0...+55
Operating relative humidity,%...55
ProductionContract Manufacturing
in Russia
Warranty period12 months from the date of purchase
Weight, g100
MP709 scope of delivery Description MP709

The central part of the device is an ATtiny45 microcontroller operating at a frequency of 16.5 MHz. The control is carried out using a personal computer via a USB port.
Attention: the device does not contain protective fuses, be careful during installation.

MP709 Software Description

To work with the device, download the MP709.exe program above. The program can work in 2 modes: local and remote.

In local mode the left window displays the connected MP709 devices. The right mouse button renames the device or displays information about it. For convenience, rename each device according to the task being performed, for example "RELE_1". The maximum number of connected devices is 32. In the same window, you can change the state of the load. On the right are the menu items for the analysis of external influences on the load.
Checking the box "state file" allows you to control loads through the file "MP709.local.set", file format is text, command format =, for example RELE_1 = ON, RELE_1 = OFF.
Checking the "FTP" box allows you to manage loads through the "MP709.remote.set" file stored on the FTP server (generated in remote mode).
Placing a check mark in the "schedule" field allows you to manage loads according to the schedule schedule file - "MP709.local.shd". File format (case is important!):
DD.MM.YYYY D HH: MM: SS =
Where DD.MM.YYYY - day, month, year, D - day of the week (value from 1 to 7, where 1 - Sunday, 2 - Monday, etc.), HH: MM: SS - hours, minutes, seconds, NAME - relay name, ON - enable, OFF - disable. It is allowed to use "*" in the fields of date, day of the week and time, for example:
**. **. ***** 6 20: **: ** RELE_1 = ON
means: every Saturday at 20: 00-22: 59: 59 RELE_1 is switched on.

Remotely the left window displays a list of MP709 devices. In the left window, you can change the state of the load, and in the right window, the date, time and state of devices are displayed. In this mode, the file "MP709.remote.set" is formed, which is transferred to the FTP server, then the file "MP709.remote.state" is read, which is read from the FTP server and displayed in the right window. By pressing the "update" button, "MP709.remote.set" transmission and "MP709.remote.state" reception are performed.
The "Settings-Autostart" menu item allows you to configure the program's autostart when you log on to the system.
The menu item "Settings-Minimize on startup" minimize the program to the tray.
The menu item "Settings-System messages" allows you to configure the display of system messages.
The menu item "Settings-Log actions" configures the maintenance and display of the protocol of the operations performed.
The "Settings-Delay" menu item adjusts the delay between repetitions of file analysis operations and access to the FTP server.
The "Update" menu item becomes available when there is a new version of the software and allows you to download the latest version of MP709.exe.

It is also possible to manage the load using the command line:
MP709.exe = ...
For example:
MP709.exe RELE_1 = ON RELE_2 = OFF
To manage loads via the Internet, you need to register on any public server that supports FTP access to files, for example, http://narod.yandex.ru/ and create a personal page. After that, you need to edit the MP709.ini file by entering your registration data into it, for example:
HOSTNAME = ftp.narod.ru
USERNAME = mp709
HOSTDIRNAME =
PASSWORD = password
Only then will it be possible to remotely control the loads.
If you want to run the program in local mode on several computers, then specify different file names in the REMOTE_STATE_FILE parameter, for example
Computer 1:
REMOTE_STATE_FILE = MP709.PC1
Computer 2:
REMOTE_STATE_FILE = MP709.PC2
And in the REMOTE_LIST_FILES parameter list them separated by “;”, for example:
REMOTE_LIST_FILES = MP709.PC1; MP709.PC2;
Don't forget to save the ini file and restart the program.

Electrical schematic diagram MP709
MP709 Frequently Asked Questions

I can't download the program on my PC. What could be?
- A program that runs on the PC of the MP710 device accesses the operating system registry directly and therefore some antiviruses prohibit its work on a PC. To ensure its operation, please create a folder on your PC (for example, "Trust"), and in the "Exclusions" antivirus settings, tell it "Always trust its contents". Place and unpack the downloaded program archive into it. Run the program also from this folder. To download the program from the site, please, disable your antivirus(after the download is complete, you can turn it on again).

How can you control the MP709 from your program written in Delphi, for example?
When the program is running through the files MP709.local.set and MP709.local.shd (see description).
Or a command line like "MP709.exe RELE_0 = ON RELE_1 = ON" (see description).

How can I find out the current state of the device through the command line? (ON or OFF)
After starting the program (from the command line too), the file of the current states of devices MP709.local.state is generated, and it must be analyzed to find out the current state.

How to make sure that when launched through the command line and controlling the relay, the MP709.EXE program window does not pop up every time, but as an option it always hangs minimized in the tray?
To prevent the program window from popping up when you call it through the command line, just check the "Minimize on startup" checkbox.
If you want the program to always hang in the tray, then manage it through the MP709.local.set file.

Does the software work on Linux?
- Works if the user independently writes a control program. Add. info for MP709, MP709_Example.rar, mp709_adriver.tar.rar

I bought your device MP709 and now I can’t configure it to work via FTP. What files need to be changed and what programs need to be installed?
The first thing to check is the availability of an FTP connection to the server using, for example, Total Commander.
- To manage loads via the Internet using the MP709, please do the following:
- Disable your antivirus.
- Disable firewall.
- Register on any public server that supports FTP access to files, for example http://narod.yandex.ru/
- Create a personal page.
- Specify your registration data in the MP709.ini file, for example:
HOSTNAME = ftp.narod.ru
USERNAME = my_mp709
HOSTDIRNAME =
PASSWORD = password
- Now remote control of loads using the MP709 is possible.
- Connect to the server via FTP using, for example, Total Commander.

- What USB hub can be used to connect multiple MP709s on one PC?
- Any HUB with external power supply is suitable for connecting several MP709s.

- Which program can be used to control multiple MP709s on one PC?
- To control several MP709s (up to 32 pcs.) On one PC, you can use the MP709.exe program.

I connected the MP709 according to the instructions, connected an incandescent lamp to the relay. In this case, the relay works several on and off (4 times it works), then the program writes a port error and the relay is not in the list of devices, i.e. disappears as a device. What is the reason?
- This effect can occur due to strong electromagnetic interference. Please connect the MP709 via a USB hub.

goods - 0 pcs.



1 - 2 pieces:RUB 3500.0
3 - 10 pcs:RUB 3250.0
11 - 25 pcs:RUB 3100.0
26 - 75 pcs:RUB 2950.0
76 - 100 pcs:RUB 2550.0
> 100 pcs:RUB 2350.0

Documentation:


Latest version of "Firmware"

Software:


Web interface SDK


Description:

Module Laurent (pronounced "Laurent") designed to control digital and analog devices, sensors and actuators via Ethernet (LAN) interface. Laurent has a rich hardware peripheral in its composition, including:

  • powerful electromagnetic relays 220 V / 7 A (4 pcs)
  • input (6 pcs) and output (12 pcs) discrete lines
  • input for connecting a temperature sensor
  • impulse counters (4 pcs)
  • PWM output
  • ADC, two channels
  • RS-232 port


The module can be controlled in different ways:

  • via embedded web page
  • direct HTTP requests
  • a set of textual control commands using the DirectIP protocol (TCP port 2424)
  • TCP-2-COM interface - transparent data exchange between serial port and TCP port 2525
  • autonomous management of hardware resources when various events occur (CAT system)

The module has a built-in Web control page. It is enough to launch any browser, enter the IP address of the module (by default 192.168.0.101) and you get a convenient visualized interface for managing various resources of the module and monitoring its parameters in real time.



With the Laurent module and the CAT system, you can quickly build a server health monitoring system over the network and automatically reboot it if a hang is detected. Server and Laurent are on the same subnet. Laurent periodically sends a PING command to the server over its IP (CAT system). If there is no answer, the power is automatically reset through the relay.

Management is performed by referring to a specific HTTP page with various parameters that determine the action to be performed. For example, if you run the query as shown below, then relay number 4 will be turned on:



It is possible to connect several modules to one network via a router:

Laurent modules can be easily connected to a wireless Wi-Fi network via a Wi-Fi router. This combination of Laurent module and Wi-Fi router allows you to control / manage the module from almost any device equipped with a Wi-Fi interface at a considerable distance.

Distinctive features:

  • control module with Ethernet (LAN) interface
  • does not require additional circuit elements - immediately ready for use
  • hardware resources are available on terminal connectors
  • 4 x relay (220 V / 7 A)
  • 6 x discrete opto-isolated input lines
  • Possibility of direct connection of a temperature sensor
  • 2 x 10-bit ADCs for external voltage measurement
  • 4 x opto-isolated pulse counters
  • 12 x discrete output control lines (up to 50 V, 0.5 A per line)
  • PWM output for smooth change of power input to the load
  • serial port RS-232
  • TCP-2-COM interface ("transparent" network data transfer bridge between RS-232)
  • a set of ready-made high-level control text commands (KE - commands) via TCP / IP protocol (open command interface)
  • recommended supply voltage: 6 to 9 V (recommended power supply PWR-75A)
  • indication LEDs of network activity and module status
  • indication LEDs of discrete input lines
  • each module has a unique serial number
  • Supports Windows 95, 98, 2000, 2003, XP 32/64 bit, Vista 32/64 bit and Windows 7 32/64 bit
  • OS Linux support
  • embedded web server for management and monitoring
  • the ability to connect several modules to one network (it is necessary to change the IP / MAC addresses)
  • the ability to change the network settings of the module (IP, MAC, Default Gateway, Subnet Mask)
  • password protected access to the control web page and command interface
  • system "Guard" - the mode of automatic tracking of changes in the states of input discrete lines
  • the ability to save and then restore the states of hardware resources after power off (relays, discrete output lines, pulse counter, PWM)
  • system CAT- automatic control of the output resources of the module when events occur on the input lines, by timer, by the threshold of the temperature sensor and by the PING command of the remote device

Contents of delivery:

The scope of delivery includes only the Laurent module itself. The module is packed in bubble wrap or shock-absorbing foam or cardboard box. When sent by mail, the module is packed in a sturdy cardboard box and covered with a paper "airbag". Documentation and drivers are available electronically.


Guarantee:

The normal operation of the module is guaranteed for 1 year from the date of sale, subject to the operating conditions and storage rules given in the Technical Description. In the event of a malfunction, the defective module is exchanged (repaired). The warranty does not cover modules that have mechanical, electrical or other damage caused by improper operation.


A situation often arises when an Ethernet network is laid in a room or even a building and there is a desire to use it to transmit a simple command from one room to another. For example, from the watchman's room, by pressing a button, open the door in the backyard. Now it is possible to do this without using computers and servers, without writing additional programs, etc. It is enough to connect the Laurent command and execution modules to the network, apply power and make small adjustments. After that, the modules will be able to communicate with each other directly.

This article discusses the M2M (Module-to-Module) technology using the example of setting up communication between Laurent-2 and KBX-3D.

M2M technology allows modules to communicate with each other using textual data, for example, using Ke-control commands without the participation of an external server, i.e. offline. For example, in automatic mode, when an event occurs, send a control command to another module located in the same network. At the same time, external servers or programs are not needed - everything can be done using the CAT + M2M bundle in the module itself.

For example, let's look at this task:

Two modules are connected in the local network: Laurent-2 and KBX-3D. It is necessary that when the 1st input line of the Laurent-2 module is closed, the relay of the KBX-3D module flips. An important condition is the absence of an external server. Everyone should execute the modules themselves without “outside” help.

Just in case, at the beginning we will consider the procedure for connecting several modules to the same network. The subtlety is that all modules have the same IP and MAC addresses by default. For normal operation of network devices, these parameters must be different for devices on the network. Therefore, for our example, let's change the network details of the Laurent-2 module, and leave the KBX-3D settings unchanged.

Go to the Laurent-2 Web interface (default address: 192.168.0.101). Go to the settings section and change the IP and MAC addresses. Set IP 192.168.0.102 and MAC 0.4.163.0.0.12.

In order for the changes to take effect, the module must be reset, for example, via a power reset. After that, the module will be available at the new address and will not conflict with MAC addresses with the KBX-3D module, the settings of which we have left unchanged.

Let's create a CAT event on the Laurent-2 module. If the voltage level on the input line IN_1 changes (for example, the line is shorted to + 5V from a button or some contact sensor), then Ke-control commands will be sent to the IP address of the KBX-3D module as a reaction to this event.

The command line contains two at once - the command to enter the password for accessing the KBX-3D module ($ KE, PSW, SET) and, in fact, the command to control the relay ($ KE, REL). At the end of each command, there must be a ‘;’ character - when sent, it will be replaced with carriage return and newline characters (CR + LF).

The command with the password is transmitted because, by default, the security system is enabled in the modules, which blocks the execution of commands for managing the module resources until the access password is entered.

If the security system is disabled on the KBX-3D module, then there will be no need to send the first command with a password.

On the Laurent-2 module, it is recommended to enable the software contact bounce suppressor. If this is not done, then when using a mechanical key or a button connected to the input line, when pressed, instead of one event, several tens are formed at once due to the "bounce" of the mechanical connection. Accordingly, an attempt will be made to send a list of commands for execution dozens of times, which is not always acceptable.

Everything is now ready. It is enough to send a signal from the button (high level) to the input line IN_1, the CAT system will work, the set of specified commands will be sent to the KBX-3D module and the first relay of the KBX-3D module will be turned on.

For the convenience of connecting the button to the input line, it is recommended to connect the GND and ISO_GND lines. The point is that the input lines of the modules are opto-isolated. There is no special need for buttons for this, and you can send a signal from the board itself to the input line (for example, from the +5 V terminal). For this, the ground of the input line and the power supply of the board must be common. This is achieved by connecting GND and ISO_GND.

The example is simple, but opens up wide possibilities for controlling your equipment.

As practice has shown, household satellite tuners used by cable operators often have to be restarted due to periodic loss of sound or image. This is caused by various factors: an inhomogeneous signal level from the convector, overheating of the receiver or drying out of electrolytes. You can keep the staff on duty for quick switching, but when it is economically unprofitable, the described device will help. In principle, the application of the developed device is not limited only to this field of activity.

Briefly:
Appointment. Allows through the local network (or the Internet) to control the switching on and off of loads connected to controlled relays.
Device. In principle, the device consists of three modules: an Ethernet module, a microcontroller module, and a load control module.
The Ethernet module is assembled on a Microchip ENC28J60 microcircuit and it is more expedient to take it ready-made, for example, here: http://www.aliexpress.com/wholesale?SearchText=enc28j60. I used the Atmega32 microcircuit as a microcontroller. The control module contains transistor keys that turn on the corresponding relays. Each relay turns on or off power to the consumer in need of it.
Operating principle. The principle of operation of the device is easy to understand from the schematic diagram:

For interactive use of the system, a web interface is provided, by entering which, the operator enables or disables the corresponding port (see figure). The design and firmware provide for the use of 20 output ports: PA0… PA7, PC0… PC7, PD4… PD7. However, if desired, the number of outputs can be increased to 80 pieces - for this it is necessary to use decoders (for example K155ID3) and rewrite the web panel javascript so that the MK outputs generate control words (0x0 ... 0xF). This approach will somewhat complicate the device circuit and it will become necessary to reboot the tuners "in turn". It is much more appropriate to use several described devices under different IP addresses.

Microcontroller firmware... To flash the Atmega32 I used a 4 wire programmer for the COM port and software. I was flashing it on an old PC running Windows XP. I have not tried it on modern operating systems, due to the lack of COM. firmware.

You also need to install the fuses as in the picture.

Firmware source codes with comments can be downloaded. The source folder contains a working Makefile. To compile the project, I used the free one. To do this, open the command line, go to the project folder and type "make". As a result of the compiler's work, several intermediate linking files and a HEX firmware file will appear in the folder.

To clear the result of the compiler's work - in the same place, on the command line, we write "make clean".

If you are going to cut the sources, then pay attention to two functions:

Fill_tcp_data_p (buf, plen, PSTR ("string to be sent to the packet")); char stroka = "string to be sent to the packet"; fill_tcp_data (buf, plen, stroka);

We use the first function where it is clearly necessary to pass a string (static text). The second is used with string variables.
From file ip_arp_udp_tcp.c:

Uint16_t fill_tcp_data_p (uint8_t * buf, uint16_t pos, const prog_char * progmem_s) (char c; // fill in tcp data at position pos // // with no options the data starts after the checksum + 2 more bytes (urgent ptr) while ((c = pgm_read_byte (progmem_s ++))) (buf = c; pos ++;) return (pos);) ... uint16_t fill_tcp_data (uint8_t * buf, uint16_t pos, const char * s) (return (fill_tcp_data_len (buf, pos , (uint8_t *) s, strlen (s)));)

Collected copies:

Demonstration of work:

The microcontroller firmware provides for changing the IP address (192.168.1.99 by default) and the javascript domain. So, go to the address: 192.168.1.99/?i=91 will change the device address to 192.168.1.91 after rebooting (use it very carefully and only if absolutely necessary, so as not to lose the device !!! :)). The script domain changes like this: 192.168.1.99/?d=mydomain.com, i.e. your script will be loaded from the address: mydomain.com/eth/script.js... Please note that the eth directory on the server should contain.

Open script.js and change the port descriptions to suit your needs:

Var name = "Port Control:"; // title // below the port names (can be replaced with something meaningful) var title = ["PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", " PA7 "," PC0 "," PC1 "," PC2 "," PC3 "," PC4 "," PC5 "," PC6 "," PC7 "," PD4 "," PD5 "," PD6 "," PD7 " ];

For example, I have it like this:

Var name = "" Rainbow ", 75 degrees"; // title // below the name of the ports (you can replace it with something meaningful) var title = ["Russian illusion", "24 techno", "Manor", "Healthy TV", "Retro", "Drive", "Phoenix + cinema "," Children "," Hunting and Fishing "," Europa Plus "," Sony Entertainment "," Sony Sci-Fi "," Multimania "," National Geographic "," НСТ "," not used "," not used "," not used "," not used "," WWW-SERVER "];

A mobile phone charger (output voltage approx. 7 volts) can be used for the power supply. In standby mode, the current consumption is about 120 mA. When one relay is turned on, the current consumption increases to 180 mA. It should be borne in mind that if it becomes necessary to activate all relays at the same time (disconnect all receivers), then the power supply must already have the appropriate power (at least 1.5 A).

The presented article is just a demonstration of the device. In the commercial version, the direction of this development has been significantly expanded - up to 150 ports, three temperature sensors, etc., it all depends on the order. (Another example for 40 ports :)

Structurally, the device can be placed in the case of some out-of-date switch in a 19 ″ telecommunication rack. Since there was no such switch at hand, I ordered in the "Mobile Service" just such a box from the fiber-optic input-distribution system (it costs 290 tons without VAT):



Did you like the article? Share it