WiFiClient networkClient;

Hi friends,

I'm trying to connect my ESP32 and log data to Tinamous.

the first command in the project is "WiFiClient networkClient; " I don't find any information on what to write in the commando and when verify the project it says "WiFiClient" does not name a type.

Do anyone know what to do? :slight_smile:

  • Frederik

Sounds like a missing library.

The WiFiClient is written with red color, so I think the library is included...

Then post all your code, in code tags.

Here you go :slight_smile:

 // -----------------------------------------------------------------
        // Add the Arduino MQTT library from the library manager
        // See https://github.com/256dpi/arduino-mqtt for more details.
        // This example uses the WiFi101 library as well running on 
        // an Arduino MKR 1000
        // -----------------------------------------------------------------
        // Unsecure (port 1833)
        //WiFiClient networkClient; 
        // SSL based connection (port 8883)
        WiFiSSLClient networkClient; 
        // Specify the buffer size as the default is fairly small.
        MQTTClient mqttClient(2048); 

        void setup() {
          // Ensure your network is connected.
          WiFi.begin(XXX, XXX);

          // replace 'demo' with your Tinamous account name.
          // Connect on port 1883 for UNSECURE connection
          // or use 8883 for SSL secured if your platform supports it.
          // Note the different WiFiClient needs to be used.
          mqttClient.begin(nabofarm.tinamous.com, 8883, networkClient);

          // If you subscribe to to MQTT topics, add the message handler.
          mqttClient.onMessage(messageReceived);
          connect();
        }

        void connect() {
            // Connect as the device "OfficeFans" to the Tinamous account "demo" 
            // using the "OfficeFansPassword" as the password.
            // Username and password should have been set when adding the device through Tinamous devices page.
            if (mqttClient.connect("ClientId-23", "OfficeFans.demo", "OfficeFansPassword")) { 
                // Connected
                return;
            }

            // Handle connection failure.
            // Error code -10 (LWMQTT_CONNECTION_DENIED) is a username/password error.
            if (mqttClient.lastError() == LWMQTT_CONNECTION_DENIED) {
                Serial.println("Access denied. Check your username and password. Username should be 'DeviceName.AccountName' e.g. MySensor.MyHome"); 
            }
        }