Design of Socket Based on Intelligent Control and Energy Management

—Smart home is one of the main applications of internet of things, and it will realize the intellectualization of household. Smart socket is part of the smart home, which can be controlled remotely by power supplied, monitor utilization condition, communication network and other functions. This article mainly introduces the intelligent electrical outlet of each hardware modules; software part mainly analyzes the socket's communication mechanism, and the electricity consumption of collected power statistics through diagrams to feedback through wireless communication. Things achieved in an environment of communication between the user and the smart power outlet timely feedback to the user, so as to achieve energy-saving purposes.


INTRODUCTION
The fast development of electrical makes our lives become more and more convenient.Social demand for power supply capacity is becoming more and more strictly.On one hand is how to save power; On the other hand is how to meet the need of the society of electricity [1],this area has being one of the most intractable problem throughout the world, under the environment of internet of things intelligent socket realizes to consume capacity and feedback to the client's function timely.
Functions and designing method of every module are introduced in this article in detail.Intelligent electrical outlet is an important part of intelligent household system, it can realize the power equipment monitoring easily, control and transmit data, communication technology uses the WIFI wireless technology; the technology is very suitable for household system communication network [2].Intelligent socket of the original concept is for the purpose of security and protection, it is on the basis of ordinary socket extending more functions, such as its several protection functions against short circuit, overvoltage and lightning.Now smart socket is on the basis of these features combined with the functions of control circuit remotely, and the statistical power of connection on the socket device, through the network it will transmit the data to the users, this data provides a basis for users make decisions wisely, it will make appliances become more intelligent eventually.
Intelligent socket sets WIFI module internally [3], the client that can perform such operations on an ordinary smart phone through the socket.Through intelligent control can switch implement control other switch remotely, operation results will also return to the remote control.It plays a switch setting's role.Intelligent socket mainly is used for household intelligent functions, it often matches with other electrical appliances.Intelligent sockets [4] can open circuit power supply, so as to control the electrical power supply or not; And intelligent host to communicate with each other to ensure the smart home system work normally.Some of the applications build on real time utility data will serve to user; others will analyze data in aggregate and serve policy and other decision makers.As a device can switch power supply of smart home, intelligent electrical outlet is the main medium of the future smart home life.Intelligent home has emerged with the development of computer science, communications, network and automatic control technology and so on [5].It is also a great change brought up by advancement of technology.

A. Framework of Design
The internal structure of the socket mainly includes MCU, WIFI communication equipment, memory ,relays, electric measurement module, keys, voltage conversion circuit, protect circuit, the power input port and the power supply output pin, which is shown in Fig. 1.The following picture presents the links between the related modules.The core is STM32, which will introduced detailed in the following article.

B. The microprocessor section
Due to using 32-bit embedded microprocessor ARM, STM32F103 is selected as the key controller of the system, this module is the core of the system, and its functions include data acquisition, dynamic data exchange, data operation, data statistics, data storage etc.Part of the MCU diagram as shown in Fig. 2. www.ijacsa.thesai.orgThe system power supply indicator light is PWR, its light is blue.LED0, and LED1 are connected with PA8 and PD2 respectively.The USB serial port, USB, power supply part of the circuit diagram is shown as the Fig. 4. Fig. 4. shows this circuit through the RST and DTR to control BOOT0 and RESET signal, so as to achieve a key download function modules.This section also has switch BUTTON, which is used to control the power of the whole system, if it is disconnected, the whole 3.3 V part of the system will be power outages.And the part 5V power supply is still open.It is shown in Fig. 4. F1 is considered as recoverable fuse, for protecting the USB.

C. WIFI wireless communication section
Based on the design requirements of master controller, we choose the USR-WIFI232-C322 chip [6] to realize hardware design together with other peripheral circuit, it also can use other chips and circuit to realize the WIFI communications functions.The main function is to realize the WIFI communication, to communicate with the MCU on data collection.The circuit diagram is shown in the Fig. 5 below.

D. Memory module
The memory may store WIFI parameters and other data for storage, and sequences of instructions that are performed by the CPU, or any other device are included in the computing system.The storage parameters including WIFI wireless network mode, the connection of the router network name, password, selection of WIFI network IP address, destination IP address, etc.After the socket makes connection, MCU reads the parameters from memory [7], it will control WIFI to generate WIFI network automatically or connect with a router.MCU reads target parameter information from memory, this system call through WIFI devices to send control code and other data to a specified device.

E. Relay module
The Relay connect with the MCU's GPIO port by triode [8], MCU controls relay on or off through the output of the GPIO port, which is shown in Fig. 6.

F. Power Measurement System
It will inevitably contain many sensor modules inside the hardware during intelligent home appliance.The power energy metering module acts as a sensor.It becomes one of the fundamental sensors during many sensors in the home appliance, the following parameters are measured: voltage, current, power factor, power, reactive power and apparent power [9].Electricity metering module [10] is mainly be composed of a set of EEM301 modules, when the socket is connected, it can realize the inspection of the values about the output current and voltage from the socket, and the results will be sent to the MCU.Electric power management is very necessary, we don't use the simple way of calculation about power is multiplied by the time, which choose the level metering chip, it can satisfy the precision of electricity measurement requirements.
On this part we use EEM301 module for the intelligent power acquisition, it is applied to the smart home, for collecting the electrical power consumption, real-time power, real-time voltage, current, and it can connect WIFI, wireless communication modules by UART, SPI and other wireless communication modules.Users can remote monitor the home appliances by visit the WEB server.So it achieves the remote monitor and intelligent purpose.
In the part of hardware design, voltage and current sampling, the power supply circuit design, circuit communication that is designed.The circuit schematic diagram of the power supply is designed as the Fig. 7.Power supply is based on LD0 chips, and takes the form of diode M7 as the protection circuits.By employing the designs, the reliability of the over-voltage protection circuit, the source, the source system, the electronic device is improved.Fig. 7. Circuit Schematic Diagram Of The Power Supply 485 communication circuits use the technique of optical coupling isolation within the input, output and power supply module.From the design of hardware, the power supply is isolated, its requirements is simple, the light coupling communication interface can be directly connected with the TXD , RXD, RD pins in EEM301,in this paper we adopted the following circuit is shown in the Fig.8 [11].The current and voltage detection are adopted resistance of sampling and current transformer sampling mode.

G. The key module
Key's main function is reset the socket or restore the factory settings.While the push-button is pressed less than 3 seconds, the system will reset when the socket is released then all devices will restart.While the push-button is pressed more than 3 seconds, the outlet will restore the factory default settings.To reset the socket, it will not affect the socket's runtime patterns, connecting network name, password, IP address etc., only to restart; To restore the factory default settings, the socket outlet will work in router mode [12], the socket will generate a WIFI network automatically, through the process of the client it can be connect to the Internet, and it also can set the socket parameters.

H. Other modules
Protection circuit is mainly be made of resistance and fuse.When the current is larger than the rated current, the fuse will disconnect automatically in order to ensure safety.If the voltage turns to unwanted fluctuations, and the transient voltage is greater than the specified voltage, through the resistance's short circuit effect, it will force fuse disconnected to ensure the safety of electricity.The power input ports are terminal blocks, for connecting wire, zero line and the ground respectively.PE or PEN line are not allowed to connect in series between sockets.

III. THE SOFTWARE DESIGN OF THE SYSTEM
The intelligent socket's essence is the socket as a carrier, and it accomplishes a remote smart home system through WIFI wireless [13].That is to say, If we have a super smart socket, no matter where we go, we can control the home air conditioning, lights, television and other household appliances just only with the phone, and we also can realize monitoring of family power and getting its analysis table.

A. The main program flow
The purpose of designing of the system software [8]that is the server mainly be responsible for receiving a serial data from the port, after parsing, according to the inventory build listening socket, the client connection is accepted, maintain the client socket connection, At the same time it will send the received binary data stream to the client.Client application then launches three threads, including connection thread, receiving data thread, data processing thread which they will complete the functions such as data receiving and parsing, displaying and so on.Client applications send a connection request to the server, after setting up the connection the client will send request to the server for reading data, the server processes the request and sends data, the client then starts the corresponding thread for processing.The server establishes TCP/IP connection [14] with MCU firstly, then starts receiving data thread, being responsible for receiving the corresponding data; once the thread has processed the data and displayed then stored it in the database server.To monitor the client connection thread, it is responsible for establishing user socket and listening socket connection.
The system uses the way to connect client applications to the server even in the face of application, platform or network failure.Once a connection is successfully made, the next task often is to read the data thread, read correspondent datum from the buffer, then write the information to a table, avoid the loss of data.View and update data for tables and views: Show as well as update data for tables and views [15].

B. Specific details
For the serial port settings section, first of all, we need to make the serial clock can be set, in APB2ENR registers' configure the serial port 1.Then configure a serial port baud rate in USART_BRR registers.After then, we can go on serial port controlling on the USART_CR1 register.Then in the USART_DR register, data can be sent and received.Of course, a serial port state of nature can be read by USART_SR register.

C. The specific process
After initialing the server which will send out the radio instruction via a serial port at regular intervals, the received instruction socket will reply their own media access control (MAC) addresses to the server.
In general, the server will decode after receiving the response of the frame socket.If the server received the socket for radio command response frame, then obtained the MAC address of the socket [16], and read the output socket's order through a serial port, got the socket's power information instruction, after receiving the order, then it would send the response frame of power information to the server.

D. The design of the PC client software
The PC client authentication information is divided into three parts, they are user login interface, electricity information query interface, and actual data generated interface.This system establishes log-in boundary wish to realize the identification [17].It is shown in Fig. 10.The curved line chart draws a full time power.One of the two lines is the actual power, measured by the meter, and the other power is through the power measurement modules which are designed in this paper, As it can be seen clearly from the Fig. 12.The two approximately equal, so the feasibility and validity of the molding methods offered [19] in this paper are confirmed in this paper.www.ijacsa.thesai.orgFirst, Users can accomplish logging the system remotely, and they can view the device's current work status, ultimately the client will allow the electricity used by domestic appliances to be "dynamically" managed .This design reduces the waste of electricity by users.This will alert users track how much energy each appliance is using and command it to use less.This will alert the user to use a power saving device, so get rid of some bad habits of electricity or energyconsuming devices can be replaced with energy-saving equipment according to the situation.

E. The software design of the intelligent mobile terminal
The major implementation of the smart phone terminal interface is showing the electricity situation, and electrical function.The Intelligent mobile terminally connect to the web via 3G network.The requestor can access the specified URL, an XML aware static reporting program can read that data directly.And it is displayed on the phone's screen of the result.The users can control the condition of the sockets and devices through the electric state interface.And it also can control the opening and closing of the corresponding socket [20].

IV. CONCLUSION
The automatic control system realizes the automatic control for intelligent electrical outlet by WIFI wireless communication technology and Internet technology.The system has much advantages in reliability and performance, It will better realize the automation and intelligent in control process.
The next further job mainly realizes the intelligent socket all the way of timing control, it also can add a leakage protection switch to regular socket, eventually it will be able to make it more practical by analyzing and improving them.Later, we can add an LED display in the smart socket further, it can make convenient for users to intuitive interact and experience intuitively.So as to solve a common problem the current socket owned: the user does not know what the current state of the socket presently.However the display screen can solve this problem.Of course, on the other hand intelligent socket also need to keep the traditional control mode, so that the user can according to own needs to choose whether to let it "smart".

Fig. 4 .
Fig. 4. The System Power Supply Indicator Light

Fig. 6 .
Fig. 6.Relay module Power supply is available only when the relays are connected.At the same time, on the connect circuit between the relay and triode parallel a led, acting on the indicator.A lighted LED indicates a working relay, however flickers with any activity.It can control socket on or off through STM32 control relays.

Fig. 9 .
Fig. 9.The physics topology structure between the communication server and its clients

Fig. 10 .
Fig. 10.User login interfaceBefore being activated, the software read the information of interface elements, and generate graphical user interface (GUI) dynamically according to the information.The socket's equipment interface can add or delete a socket for users, and it also can control the state of the socket whether open or not.The electricity information that will be displayed in the Fig.11.Show the real-time electrical appliances[18].