 
 
 /* TOGGLE RELAY FUNCTIONS - START */
-
-//void toggle_relay1()
-//{
-// /* Function to toggle_relay1 when the interruption from the falling edge signal from pushbutton1 happens */
-//    if(digitalRead(pushbutton1) == LOW && digitalRead(pushbutton2) == HIGH){
-//        state_relay1 = !state_relay1;
-//        digitalWrite(relay1, state_relay1);  //Writes the state_relay1 to relay 1
-//    }
-//}
-
-
-//void toggle_relay2()
-//{
-// /* Function to toggle_relay2 when the interruption from the falling edge signal from pushbutton2 happens */
-//    if(digitalRead(pushbutton2) == LOW && digitalRead(pushbutton1) == HIGH){
-//        state_relay2 = !state_relay2;
-//        digitalWrite(relay2, state_relay2); //Writes the state_relay2 to relay 2
-//    }
-//}
+void toggle_relay1()
+{
+    /* Function to toggle_relay1 when the interruption from the falling edge signal from pushbutton1 happens */
+    if(digitalRead(pushbutton1) == LOW && digitalRead(pushbutton2) == HIGH){
+        state_relay1 = !state_relay1;
+        digitalWrite(relay1, state_relay1);  //Writes the state_relay1 to relay 1
+        changeSocketStatusSocket1Timer.start();
+    }
+}
+
+
+void toggle_relay2()
+{
+    /* Function to toggle_relay2 when the interruption from the falling edge signal from pushbutton2 happens */
+    if(digitalRead(pushbutton2) == LOW && digitalRead(pushbutton1) == HIGH){
+        state_relay2 = !state_relay2;
+        digitalWrite(relay2, state_relay2);     //Writes the state_relay2 to relay 2
+        changeSocketStatusSocket2Timer.start();
+    }
+}
+
+void changeSocketStatusSocket1()
+{
+    // Send auth data
+    String jsonChangeSocketStatus = String(
+      "{ \"apiKey\": \"" + String("{{{apiKey}}}") + "\"" +
+       ",\"socketNum\": \"" + String(1) +  "\"}" );
+
+    Particle.publish("changeSocketStatus", jsonChangeSocketStatus, PRIVATE);
+
+    changeSocketStatusSocket1Timer.stop();
+}
+
+void changeSocketStatusSocket2()
+{
+    // Send auth data
+    String jsonChangeSocketStatus = String(
+      "{ \"apiKey\": \"" + String("{{{apiKey}}}") + "\"" +
+       ",\"socketNum\": \"" + String(2) +  "\"}" );
+
+    Particle.publish("changeSocketStatus", jsonChangeSocketStatus, PRIVATE);
+
+    changeSocketStatusSocket2Timer.stop();
+}
+
 
 double get_Irms0_current(){
 

int socket1Counter = 0;
int socket2Counter = 0;

/* SEMI_AUTOMATIC SYSTEM MODE FOR WORKING OFFLINE - END */

/* CREATE INSTANCES OF THE EMONLIB LIBRARY */

    Serial.print("Corrente1 (A): ");
    Serial.print(Irms0);                    // Irms0
    Serial.print("      ");
     Serial.print("Corrente2 (A): ");
    Serial.print(Irms1);                    // Irms1
    Serial.print("      ");
    Serial.print("Potencia1 (W): ");
