It was necessary to implement power management from a cell phone. There are a lot of these solutions, and there are a lot of different technological solutions and price frames. But the problem was that it was necessary to make it VERY urgent, as the customer said - "It is necessary yesterday." Given the distance from Moscow in 6000 km (and the coming weekend), the problem arose decent.
Having looked through the Internet, I came across an article - http://www.lanmart.ru/blogs/mikrotik-rb750up-remote-power-management-220v/ which helped a lot, considering that this router was available, though it was used, for another but when it is VERY necessary it is possible and removed :) ')
For implementation details, welcome under the cat (photo)
Initially decided to test, taking one outlet and act exactly in accordance with the article.
And nothing worked :) After a brief search in Google, it turned out that after upgrading the firmware and upgrading the PoE version (command in MikroTik interface ethernet poe settings upgrade routers), this instruction ceases to correspond to reality as a resistance test was added. And when using the relay it is.
But it does not matter! A little knowledge of the basics of electrical circuits and the station of a young technician visited in childhood prompted us to try to throw a diode. The result is what you see in the picture (do not scold for the installation - it was only at the time of the test)
AND BINGO! It worked exactly as we needed :)
Then everything was neatly packaged in a standard electrical shield -
And connected. Now through the WinBox (or the web interface, or ssh, or telnet), you could control the power by sending commands interface ethernet set ether2 poe-out=forced-on to disable and interface ethernet set ether2 poe-out=off to enable Changing the port number (from 2 to 5) it was possible to control a specific outlet.
Further (we remember TZ) management via the cell phone was required. In general, there was no problem anymore - there is WinBox for mobile platforms, and a web interface, and many SSH clients. Also (since there is a USB port in the router) it was possible to connect a USB modem and control it via SMS. But we were already unstoppable.
Since the customer wanted him to have everything HOW possible, the Windows Phone 8X by HTC and Microsoft Visual Studio Express 2012 for Windows Phone were taken. And the project MikrotikOnOff was created in it.
All the programming at the end was reduced to only three actions - 1. Created a form
return appStatCmd . Result ; } catch { Return "Error connecting to server" ; } }
private void Btn_All_On_Click ( object sender, RoutedEventArgs e ) { MessageBox . Show ( MikrotikSSHCommand ( MikrotikIP, MikrotikSshPort, MikrotikUser, MikrotikPassword, "system script run 0" ) ) ; }
private void Btn_All_Off_Click ( object sender, RoutedEventArgs e ) { MessageBox . Show ( MikrotikSSHCommand ( MikrotikIP, MikrotikSshPort, MikrotikUser, MikrotikPassword, "system script run 1" ) ) ; }
private void Btn_Test_Click ( object sender, RoutedEventArgs e ) { MessageBox . Show ( MikrotikSSHCommand ( MikrotikIP, MikrotikSshPort, MikrotikUser, MikrotikPassword, "system script run 2" ) ) ; }
At the creation of the program is over :)
Next, create scripts on the microtic - you can through System - Scripts. It is possible through the console
/ system script add name = "All On" policy = ftp , reboot, read , write , policy, test , winbox, password, sniff, sensitive, api source = \ "interface ethernet set ether2 poe-out = off \ r \ \ n interface ethernet set ether3 poe-out = off \ r \ \ n interface ethernet set ether4 poe-out = off \ r \ \ n interface ethernet set ether5 poe-out = off " add name = "All off" policy = ftp , reboot, read , write , policy, test , winbox, password, sniff, sensitive, api source = \ "interface ethernet set ether2 poe-out = forced-on \ r \ \ n interface ethernet set ether3 poe-out = forced-on \ r \ \ n interface ethernet set ether4 poe-out = forced-on \ r \ \ n interface ethernet set ether5 poe-out = forced-on " add name = SystemIdent policy = ftp , reboot, read , write , policy, test , winbox, password, sniff, sensitive, api source = \ "system identity print"
And you can check, pack and give to the customer.
A little about the pros and cons of this solution - pros
Cost - except for the phone, which was, then the total price of the solution was 3120 rubles (2,200 router itself, 400 rubles a box, 160 rubles - 4 sockets for a DIN rail, 280 rubles - 4 relays with pads, 80 rubles - 4 terminal connectors )
Reliability - Mikrotik routers are quite reliable and stable in operation, which allows you not to worry about the power management system itself hanging (previously faced with two remote control systems - quality and stability were not up to par)
Manageability - in my case, it was only necessary to remotely manage power from a cell phone, but no one forbids making more serious decisions using all sorts of micro-device tools - from simple ping and rebooting when not responding to fairly complex script actions with the execution schedule
4 controlled sockets - in most solutions of this price level it is one, which is rather inconvenient
Easy for the end user - just press one button for power management
Minuses
Electrical safety - all the same, considering some “collective-farm” solutions, there are some concerns about its protection and other parameters. I would do it now - I would take a bigger box and push it to each outlet for a diffuser.
PS: Smart people on ixbt suggested that another diode is needed
Jamal: So that when the voltage is removed from the relay, the inductive current surge from it does not fry everything around. A diode is needed so that the inrush current runs inside a closed loop formed by the winding and diode and is spent on heating the windings and the diode, and not on burning the surrounding electronics.
Where does this shot, you can smoke from the same Wikipedia or textbook of electrical engineering. In short: a coil, by definition, resists a change in current, and if the current stops (the relay is de-energized), the energy stored in the coil will tend to keep the current from stopping. Hence the surge.
But I did not do this, this advice was received after delivery to the customer. But considering that it has been working for quite a long time, we will hope for the best :)