diff --git a/Adafruit_MQTT.cpp b/Adafruit_MQTT.cpp index f08ec05..7b775dd 100644 --- a/Adafruit_MQTT.cpp +++ b/Adafruit_MQTT.cpp @@ -788,6 +788,8 @@ bool Adafruit_MQTT_Publish::publish(uint32_t i) { } bool Adafruit_MQTT_Publish::publish(double f, uint8_t precision) { + if (isnan(f)) + return false; char payload[41]; // Need to technically hold float max, 39 digits and minus sign. dtostrf(f, 0, precision, payload); return mqtt->publish(topic, payload, qos);