Here is the part of the code corresponding to wifi and mqtt:
const char* ssid = "as";
const char password = "vD";
const char username = "";
const char mqttServer = "t****.s***.pt";
unsigned int mqttPort = 1883;
const char* mqttUser = "";
const char* mqttPassword = "";
WiFiClient espClient;
PubSubClient client(espClient);
DFRobotHCHOSensor hcho(SensorAnalogPin,VREF);
void setup() {
Wire.begin();
Serial.begin(115200);
client.setKeepAlive(360);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to the WiFi network");
Serial.println(WiFi.localIP());
client.setServer(mqttServer, mqttPort);
while (!client.connected()) {
Serial.println("Connecting to MQTT...");
if (client.connect("***", mqttUser, mqttPassword )) {
Serial.println("connected");
} else {
Serial.print("failed with state ");
Serial.println(client.state());
delay(2000);
}
}
And this is the result:
