#include //Wifi #include //MQTT #include //OLED Library #include //Wifi variables const char* ssid = "FabAcademy"; const char* password = "fabacademy"; IPAddress wemosIP; //IP addres that wemos received //MQTT server const char* mqtt_server = "192.168.4.1"; const int mqtt_port = 1883; WiFiClient espClient; const char* mqttServerStatus = "mqttServerStatus"; PubSubClient MQTTclient(espClient); String wemosListener; //message received from MQTT char* mqttSensorTopic = "mqttSensorListener"; char* mqttOLEDTopic = "mqttOLEDListener"; //MQTT send message unsigned long lastMsg = 0; #define MSG_BUFFER_SIZE (50) char msgReceived[MSG_BUFFER_SIZE]; //OLED const int8_t PIN_SDA = D1; const int8_t PIN_SCL = D2; U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, PIN_SCL, PIN_SDA, U8X8_PIN_NONE); bool initialized = false; void setup_wifi() { delay(10); // We start by connecting to a WiFi network Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } randomSeed(micros()); wemosIP = WiFi.localIP(); Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(wemosIP); } void mqttMessageCallback(char* topic, byte* payload, unsigned int length) { for(int i=0; i