void loop(){ if (!mqttClient.connected()) { reconnect(); }
if (abc == 1){ Serial.println("Starting Sensor"); digitalWrite(5, HIGH); Serial.print("calibrating sensor "); for(int i = 0; i < calibrationTime; i++){ Serial.print("."); delay(1000); } Serial.println(" done"); Serial.println("SENSOR ACTIVE"); delay(50); digitalWrite(12, HIGH); Serial.println("wait till module gains stability"); delay(5000); //for (int x=0; x<20; x++){ int xyz = 2; while (xyz != 1){ Serial.println("Started Detection"); if(digitalRead(pirPin) == HIGH){ //digitalWrite(ledPin, HIGH);
Serial.println("motion detected "); xyz = 1; digitalWrite(14, HIGH); mqttClient.publish("Daccess/MotionSensor/status","Motion Detected"); }
delay (1000); } abc = 2; } mqttClient.loop();}
Hi Shantanu,
I reformatted your code.
It appears that loop()
is never called due to commenting of the left bracket in the second for loop..
Cheers,
ml
--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.