Hi Good Afternnon guys,
i dk why i already put mosquitto broker in services done open the cmd but still cant compile in arduino... My project is doing ESP32 Wroom DE Module
Got idea to resolve my problem?
If your sketch does not compile then no, the ESP32 will not be connected to WiFi unless you previously uploaded a sketch that does connect
Stop messing about and post your MQTT sketch and tell us whether you have installed the PubSubClient library and, if so, how you did it
There is not much point in posting a link to a video when the problem is with the code on
your
project, particularly the video has nothing to do with PubSubClient on the ESP32
WiFiClient espClient;
PubSubClient client(espClient);
long currentTime, lastTime;
int count = 0;
int test = 1;
int sample = 2;
int counter = 3;
char messages[20];
// WIFI CONNECT
void setupWifi(){
delay(100);
Serial.println("Conneting to ");
Serial.println(ssid);
Serial.print("Connected to ");
Serial.println(ssid);
// MQTT CONNECT
void reconnect(){
while(!client.connected()){
Serial.print("\nConnected to ");
Serial.println(broker);
if(client.connect("MHMQTT",brokerUser, brokerPassword)){
Serial.print("\nConnected to ");
Serial.println(broker);
client.subscribe(inTopic);
} else {
Serial.println("Try to connnect again");
delay(4500);
// DATA SUBSCRIBE
void callback(char* topic, byte* payload, unsigned int length){
Serial.print("Received messages; ");
Serial.println(topic) ;
for(int i=0; i<length; i++){
Serial.print((char)payload[i]);
Serial.println();
if ((char)payload[0] == '1') {
digitalWrite(BUILTIN_LED, LOW);
Serial.println("True");
client.publish(outTopic2,"True");
// Turn the LED on (Note that LOW is the voltage level
// but actually the LED is on; this is because
// it is acive low on the ESP)
} else {
digitalWrite(BUILTIN_LED, HIGH);
Serial.println("False");
client.publish(outTopic2,"False");
// Turn the LED off by making the voltage HIGH
//configure wifi and get IP address
setupWifi();
IPAddress myIP = WiFi.begin();
Serial.print("AP IP adress: ");
Serial.print(myIP);
client.setServer(broker,****);
client.setCallback(callback);