do not place publish code in the main loop. Sending MQTT messages within rate limits
change to:
void loop() {
if (millis() - timeold == measuretime)
{
Cayenne.loop();
detachInterrupt(digitalPinToInterrupt(5));
rpm=rev*(60000/measuretime);
Serial.println(rpm, DEC);
rev=0;
timeold=millis();
attachInterrupt(digitalPinToInterrupt(5),RPMcount,FALLING);
}
i am not sure whether this will work, but give it a try.