 JsonObject &leitura = jsonBuffer.createObject();
 JsonObject &motion = jsonBuffer.createObject();
 
-int count = 15000;
+int r = 0;
+int g = 0;
+int b = 0;
+
+int errorCount = 0;
+
+int count = DELAY_TIME_TO_SEND;
 bool motionSensorRead = false;
 
 void setup() {


void inline readLeituraAndSendToFirebase() {
    readDataToSend();

    if (count > DELAY_TIME_TO_SEND) {

        if (leitura["temperatura"] == "nan" || leitura["umidade"] == "nan" || getEpoch().toInt() <= 1000) {
            return;
        }

        count = 0;
        Firebase.push(TABLE_LEITURA, leitura);
    }

    if (Firebase.failed()) {
        Serial.print(getErrorString(TABLE_LEITURA));
        Serial.println(Firebase.error());
        return;
    }
}

    Serial.println("------Count------/");
}

void inline updateCountErrosAndPrint() {
    if(errorCount > 1000) {
        Serial.println("/-----errorCount-------");
        Serial.println(errorCount);
        Serial.println("------errorCount------/");
        errorCount = 0;
        resetFunc();
    }
}

void loop() {
    updateNtp();
    readMotionSensorAndSendToFirebase();
