My device connection flips in and out and i do not receive any data?
Any suggestions what is wrong?
which device are you using?
It´s now ok. I hade to add a delay(100); in the loop().
you dont have to add the publish lines in the main loop. have a look at Sending MQTT messages within rate limits