adafruit / Adafruit_FONA

Arduino library for the Adafruit FONA
https://www.adafruit.com/products/1946
211 stars 238 forks source link

MQTT Publish failed!! #96

Open Bhavikjp opened 6 years ago

Bhavikjp commented 6 years ago

Hello,

I have used SIM808 GPS/GSM Module, Adafruit_FONA library and, MQTT publish function. MQTT connection established but, there is an error in publishing data.

Serial Monitor view:

AT+CIPSTART="TCP","test.mosquitto.org","1883" <--- OK <--- CONNECT OK <--- > ---> 84 84 3 194 0 15 0 7 68 101 118 105 99 101 49 0 36 97 116 111 122 105 111 116 38 115 101 61 49 53 53 56 53 48 51 57 50 50 38 115 107 110 61 105 111 116 104 117 98 111 119 110 101 114 164 <--- SEND OK Publishing GPS data: Mydata <--- ERROR Failed to publish data! ---> AT+CIPCLOSE <--- CLOSE OK

Code is like this,

#elif defined(PROTOCOL_MQTT_MYSIGNAL) const char* MQTT_SERVER = "test.mosquitto.org"; const char* MQTT_SERVERPORT = 1883; // Connect to MQTT broker if (!fona.TCPconnect(MQTT_SERVER, MQTT_SERVERPORT)) Serial.println(F("Failed to connect to TCP/IP!")); if (!fona.MQTTconnect("MQTT","","","")) Serial.println(F("Failed to connect to MQTT broker!")); if (!fona.MQTTpublish("MyTopic", "Mydata")) Serial.println(F("Failed to publish data!"));

Can you please suggest a way to solve it out with an example.

Thanks!!