Hello Aaron,
Thank you for your answer and I apologize for the late response.
In this connection it is submitting a TCP and MQTT connection.
It is true I was using the wrong port.
I have been reading FAQ and I figured out that a TSL connection is missed but I did not know how to. How can I get one ?
This is a sample of the code sending temperature from ttgo SIM800L to hivemq cloud :
//importing libraries
const char apn = “”;
const char gprsUser = “”;
const char gprsPass = “”;
const char simPIN = “”;
const char* mqtt_server = "********.s2.eu.hivemq.cloud";
const char Topic_Temperature = “test/test”;
TinyGsmClient client(modem);
PubSubClient mqtt(client);
// TTGO T-Call pins
#define MODEM_RST 5
#define MODEM_PWKEY 4
#define MODEM_POWER_ON 23
#define MODEM_TX 27
#define MODEM_RX 26
#define I2C_SDA 21
#define I2C_SCL 22
// BME280 pins
#define I2C_SDA_2 18
#define I2C_SCL_2 19
uint32_t lastReconnectAttempt = 0;
// I2C for SIM800 (to keep it running when powered from battery)
TwoWire I2CPower = TwoWire(0);
TwoWire I2CBME = TwoWire(1);
#define IP5306_ADDR 0x75
#define IP5306_REG_SYS_CTL0 0x00
#define DHTPIN 4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
float temperature = 0;
long lastMsg = 0;
bool setPowerBoostKeepOn(int en){
I2CPower.beginTransmission(IP5306_ADDR);
I2CPower.write(IP5306_REG_SYS_CTL0);
if (en) {
I2CPower.write(0x37);
} else {
I2CPower.write(0x35);
}
return I2CPower.endTransmission() == 0;
}
void mqttCallback(char* topic, byte* message, unsigned int len) {
Serial.print("Message arrived on topic: “);
Serial.print(topic);
Serial.print(”. Message: ");
String messageTemp;
for (int i = 0; i < len; i++) {
Serial.print((char)message[i]);
messageTemp += (char)message[i];
}
Serial.println();
}
boolean mqttConnect() {
SerialMon.print("Connecting to ");
SerialMon.print(mqtt_server);
// Connect to MQTT Broker without username and password
boolean status = mqtt.connect(mqtt_server);
if (status == false) {
SerialMon.println(" fail");
ESP.restart();
return false;
}
SerialMon.println(" success");
mqtt.subscribe(Topic_Temperature);
return mqtt.connected();
}
void setup() {
// Set console baud rate
SerialMon.begin(115200);
delay(10);
// Start I2C communication
I2CPower.begin(I2C_SDA, I2C_SCL, 400000);
I2CBME.begin(I2C_SDA_2, I2C_SCL_2, 400000);
// Set modem reset, enable, power pins
pinMode(MODEM_PWKEY, OUTPUT);
pinMode(MODEM_RST, OUTPUT);
pinMode(MODEM_POWER_ON, OUTPUT);
digitalWrite(MODEM_PWKEY, LOW);
digitalWrite(MODEM_RST, HIGH);
digitalWrite(MODEM_POWER_ON, HIGH);
SerialMon.println(“Wait…”);
// Set GSM module baud rate and UART pins
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
delay(10000);
// Restart takes quite some time
// To skip it, call init() instead of restart()
SerialMon.println(“Initializing modem…”);
modem.restart();
// modem.init();
String modemInfo = modem.getModemInfo();
SerialMon.print("Modem Info: ");
SerialMon.println(modemInfo);
// Unlock your SIM card with a PIN if needed
if ( GSM_PIN && modem.getSimStatus() != 3 ) {
modem.simUnlock(GSM_PIN);
}
SerialMon.print(“Connecting to APN: “);
SerialMon.print(apn);
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
SerialMon.println(” fail”);
ESP.restart();
}
else {
SerialMon.println(" OK");
}
if (modem.isGprsConnected()) {
SerialMon.println(“GPRS connected”);
}
// MQTT Broker setup
mqtt.setServer(mqtt_server, 8883);
mqtt.setCallback(mqttCallback);
//*******************************
dht.begin();
}
void loop() {
if (!mqtt.connected()) {
SerialMon.println(“=== MQTT NOT CONNECTED ===”);
// Reconnect every 10 seconds
uint32_t t = millis();
if (t - lastReconnectAttempt > 10000L) {
lastReconnectAttempt = t;
if (mqttConnect()) {
lastReconnectAttempt = 0;
}
}
delay(100);
return;
}
long now = millis();
if (now - lastMsg > 30000) {
lastMsg = now;
float t = dht.readTemperature();
if ( isnan(t) ) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
// Convert the value to a char array
char tempString[8];
dtostrf(t, 1, 2, tempString);
Serial.print("Temperature: ");
Serial.println(tempString);
mqtt.publish(Topic_Temperature, tempString);
}
mqtt.loop();
}
}
====>
=== MQTT NOT CONNECTED ===
Connecting to *****.s2.eu.hivemq.cloudAT+CIPCLOSE=0,1
+CME ERROR: operation not allowed
AT+CIPSSL=0
OK
AT+CIPSTART=0,“TCP”,“***.s2.eu.hivemq.cloud”,8883
+CME ERROR: operation not allowed
Thank you
Best,