0

IO Connection failed
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

IO Connection failed

by LLenvir on Sun Feb 28, 2021 5:17 pm

Hi nice people,

after many test I did not fix my trubble.

When I try to publish a sensor data some time works some time did not.

My sketch is based on TinyGSM library and the main point are:
-*-*--*-*-*-*-*-*---*-*-*---*
boolean mqttConnect() {
SerialUSB.print("Connecting to ");
SerialUSB.print(broker);
sensor_read();
// Connect to MQTT Broker without password if is possible
//boolean status = mqtt.connect("io.adafruit.com");

// Or, if you want to authenticate MQTT:
boolean status = mqtt.connect("io.adafruit.com", "", "");

if (status == false) {
SerialUSB.println(" fail");
return false;
}

SerialUSB.println(" success");

char soil_20_str[10];
sprintf(soil_20_str,"%d", soil_voltage_meno_20);
mqtt.publish(topicghsoil20, soil_20_str);
delay(2000);
return mqtt.connected();

}

void loop() {


if ( rtc.getSeconds() == 00 ){//rtc.getMinutes() == 59 &&

//rtc.standbyMode();
if (!mqtt.connected()) {
SerialUSB.println("=== MQTT NOT CONNECTED ===");
// Reconnect every 10 seconds
uint32_t t = millis();

mqtt.loop();

if (t - lastReconnectAttempt > 10000L) {
lastReconnectAttempt = t;
if (mqttConnect()) {
lastReconnectAttempt = 0;
}
}
delay(100);
return;
}


}

}
-*-*-*-*-*-*-*-*-*-*-*-*
In the account monitor page the results shown were:

2021/02/28 10:03PM
gh-soil-20
656
2021/02/28 10:02PM
gh-soil-20
656
2021/02/28 10:01PM
gh-soil-20
656
2021/02/28 10:00PM
gh-soil-20
656
2021/02/28 9:54PM
gh-soil-20
656
2021/02/28 9:53PM
gh-soil-20
656
2021/02/28 9:52PM
gh-soil-20
656

At 9:54 the connection failed... and in the Serial monitor the code were:

21:54:05.590 -> === MQTT NOT CONNECTED ===
21:54:05.590 -> Connecting to io.adafruit.comAT+CIPRXGET=4,0
21:54:06.943 ->
21:54:06.943 -> +CIPRXGET: 4,0,0
21:54:06.989 ->
21:54:06.989 -> OK
21:54:06.989 -> AT+CIPSTATUS=0
21:54:06.989 ->
21:54:07.036 -> +CIPSTATUS: 0,0,"TCP","52.54.110.50","1883","CLOSED"
21:54:07.130 ->
21:54:07.130 -> OK
21:54:07.130 -> AT+CIPCLOSE=0,1
21:54:07.177 ->
21:54:07.177 -> +CME ERROR: operation not allowed
21:54:07.177 -> AT+CIPSSL=0
21:54:07.223 ->
21:54:07.223 -> +CME ERROR: unknown
21:54:07.223 -> AT+CIPSTART=0,"TCP","io.adafruit.com",1883
21:54:07.270 ->
21:54:07.270 -> OK
21:54:08.058 ->
21:54:08.058 -> 0, CONNECT OK
21:54:08.106 -> AT+CIPSEND=0,72
21:54:08.106 ->
21:54:08.106 -> >F

Could someone help me?
Thanks in advance.
Last edited by brubell on Mon Mar 01, 2021 10:17 am, edited 1 time in total.
Reason: removed sensitive credentials

LLenvir
 
Posts: 16
Joined: Tue Dec 29, 2020 8:32 am

Re: IO Connection failed

by brubell on Mon Mar 01, 2021 10:18 am

Do you know where in your code the error below occurs?

Code: Select all | TOGGLE FULL SIZE
21:54:07.177 -> +CME ERROR: operation not allowed
21:54:07.177 -> AT+CIPSSL=0
21:54:07.223 ->
21:54:07.223 -> +CME ERROR: unknown
21:54:07.223 -> AT+CIPSTART=0,"TCP","io.adafruit.com",1883


I can assist but need to know which function call is causing that error.

brubell
 
Posts: 1435
Joined: Fri Jul 17, 2015 10:33 pm

Re: IO Connection failed

by LLenvir on Mon Mar 01, 2021 10:25 am

Hi Brubell,

that error occur when "mqtt.publish(topicghsoil20, soil_20_str);" line is working.
I think becouse the connection is CLOSE "+CIPSTATUS: 0,0,"TCP","52.54.110.50","1883","CLOSED"".

Thank you

LLenvir
 
Posts: 16
Joined: Tue Dec 29, 2020 8:32 am

Please be positive and constructive with your questions and comments.