Node32-W5500-MQTT Problem

Home Forums esp32 Node32-W5500-MQTT Problem

Viewing 2 reply threads
  • Author
    Posts
    • #32550
      zemmo83
      Participant

        Ciao everyone, I have a problem with my prototype. I’d like to implement MQTT over LAN using an ESP32 and a standard W5500 Nano.
        The prototype successfully acquires an IP address via DHCP, but MQTT doesn’t work.
        The code is very simple and minimal.
        I tested the same Ethernet cable with my laptop and I can send MQTT messages without issues.
        Any ideas?

        
        #include <SPI.h>
        #include <Ethernet.h>
        #include <MQTT.h>
         
        byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xAA};
         
        EthernetClient net;
        MQTTClient client;
         
        unsigned long lastMillis = 0;
         
        void connect() {
          Serial.print("connecting...");
          while (!client.connect("TestEsp")) {
            Serial.print(".");
            delay(1000);
          }
         
          Serial.println("connected!");
         
          client.subscribe("/Test");
        }
         
        void messageReceived(String &topic, String &payload) {
          Serial.println("incoming: " + topic + " - " + payload);
         
        }
         
        void setup() {
          Serial.begin(115200);
          Ethernet.init(5); //CS pin 
          Ethernet.begin(mac);
          Serial.print("Local IP : ");
          Serial.println(Ethernet.localIP());
         
        
          client.begin("192.168.1.66", net);
          client.onMessage(messageReceived);
         
          connect();
        }
         
        void loop() {
          client.loop();
         
          if (!client.connected()) {
            connect();
          }
         
        
          if (millis() - lastMillis > 5000) {
            lastMillis = millis();
            client.publish("Node32s", "Test");
          }
        }
        

        Grazie mille

      • #32551
        Renzo Mischianti
        Keymaster

          Hi Zemmo,
          There can be various problems, but I think a good way to do that is to change the library to use the native stack of ESP32, and you can prevent any issues with authentication.
          You can find more info here.

          Integrating W5500 with ESP32 Using Core 3: Native Ethernet Protocol Support with SSL and Other Features

          Could you give us feedback about the result and if the problem continues we are going to look into the problem in depth.

          Bye Renzo

        • #32553
          zemmo83
          Participant

            Thanks for the reply, I’ll try using the library #include <ETH.h>.

        Viewing 2 reply threads
        • You must be logged in to reply to this topic.
        Exit mobile version