   if (now - lastMsg > 50) {
      lastMsg = now;
      status=digitalRead(BUTTON_PIN);
-     String msg="K";
+     
      if(status==HIGH )
      {
-          char message[1];
-          msg.toCharArray(message,58);
-          Serial.println(message);
           
-          if(lastStatus==0){
-            //publish sensor data to MQTT broker
-            client.publish("/theringbot/ring", message);
+          if(lastStatus==0 ){
+            
+            char message[2];
+            message[1] = 0;
+            
+            if(now-lastActive > 10*1000 ){
+              
+              message[0] = 'k';
+              Serial.println(message);
+              
+              //publish sensor data to MQTT broker
+              client.publish("/theringbot/ring", message);
+              lastActive = now;
+            }
+          
           }
           
           lastStatus = 1;

 *  NodeMCU采集到的tilt传感器电压值发到MQTT Client
 * Tutorial URL 
 * CopyRight John Yu
 */
#include <ESP8266WiFi.h>
#include "/home/smarkus/Arduino/libraries/pubsubclient/src/PubSubClient.h"

int BUTTON_PIN = 5; 
const char* ssid = "Forum";

WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
int lastStatus = 0;

void setup_wifi() {
