thingsboard / thingsboard-client-sdk

Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)
MIT License
160 stars 124 forks source link

Fatal error: PubSubClient.h: No such file or directory #70

Closed edomazzone closed 2 years ago

edomazzone commented 2 years ago

Good evening everyone, I'm trying to use Wemos D1 mini (ESP8266) to send data to Thingsboard. When I try to upload the library example on the board there is the following error:

C:\Users\edoma\Desktop\libraries\thingsboard-arduino-sdk-master\src/ThingsBoard.h:20:10: fatal error: PubSubClient.h: No such file or directory 20 | #include | ^~~~ compilation terminated. exit status 1

I try different versions of the library and I try also to use different versions of the board but the results that I've had are the same. I've also manually deleted the folder and try again but the error doesn't allow me to upload the sketch on the board. Thank you so much for the help.

moe9584 commented 2 years ago

Hi, I found the following solution: https://www.esp8266.com/viewtopic.php?p=74181 This issue is after the installation gone, but another issue arises : ThingsBoard.h:22:49: fatal error: ArduinoJson/Polyfills/type_traits.hpp: No such file or directory The libs have some incompatibilities...

OekoSolveMG commented 2 years ago

You simply have to include PubSubClient which is a seperate library into your project as well. https://github.com/knolleary/pubsubclient/

@moe9584 For your issue that has been fixed with the newest merge on the main branch see issue #66

@imbeacon I think this issue can be closed.

Shayantika-Dhar commented 10 months ago

include

      ^~~~~~~~~~~~~~~~~~

compilation terminated.

i am getting this error but i have not used this library in my code

CODE:

include

include "ThingsBoard.h"

include "DHTesp.h"

include

define CURRENT_VIRMWARE_TITLE "TEST"

define CURRENT_VIRMWARE_VERSION "1.0.0"

define WIFI_SSID "xLayer Technologies S1"

define WIFI_PASSWORD "xlayerinfra2023"

define TOKEN "ESP32-TEST-XLAYER"

define THINGSBOARD_SERVER "thingsboard.cloud"

define SERIAL_DEBUG_BAUD 115200

const int echoPin = 2; // Ultrasonic sensor echo pin const int trigPin = 4; // Ultrasonic sensor trigger pin

const int DHT_PIN = 15;

DHTesp dhtSensor;

WiFiClient espClient;

ThingsBoard tb(espClient);

int status = WL_IDLE_STATUS;

LiquidCrystal_I2C lcd(0x27, 16, 2); byte SymbolDegree[] = { B00110, B01001, B01001, B00110, B00000, B00000, B00000, B00000, };

void InitWiFi() { Serial.println("Connecting to AP..."); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); while (WiFi.status() != WL_CONNECTED) { delay (500); Serial.println("."); } }

void reconnect() { status = WiFi.status(); if ( status !=WL_CONNECTED ) { WiFi.begin(WIFI_SSID, WIFI_PASSWORD); while (WiFi.status() != WL_CONNECTED) { delay (500); Serial.println("."); } Serial.println("Connected to AP"); } }

void setup() { lcd.init(); lcd.createChar(0, SymbolDegree); lcd.backlight(); lcd.setCursor(0, 0); lcd.print("Temperature &"); lcd.setCursor(0, 1); lcd.print("Humidity"); delay (4000); lcd.clear();

Serial.begin(SERIAL_DEBUG_BAUD); Serial.println();

pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT);

InitWiFi(); dhtSensor.setup(DHT_PIN, DHTesp::DHT22); }

int getDistance() { digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW);

long duration = pulseIn(echoPin, HIGH); int distance = duration / 58.2; // Convert duration to distance in centimeters

return distance; }

void displayDistance(int distance) { Serial.print("Distance: "); Serial.print(distance); Serial.println(" cm"); }

void loop() { delay (1000);

 if (WiFi.status() != WL_CONNECTED) {
  reconnect();
}

if (!tb.connected()) {
  Serial.println("Connecting to:");
  Serial.print(THINGSBOARD_SERVER);
  Serial.print(" with token ");
  Serial.print(TOKEN);
  if (!tb.connect(THINGSBOARD_SERVER, TOKEN)) {
    Serial.println("Failed to Connect");
    return;
  }
}

Serial.println("Sending Data...");

int distance = getDistance();

String distanceMessage = "Distance: " + String(distance) + " cm"; tb.sendTelemetryData("Distance", distance); Serial.print("Distance : "); Serial.println(distance);

TempAndHumidity data = dhtSensor.getTempAndHumidity();
tb.sendTelemetryInt("temperature", data.temperature);
tb.sendTelemetryFloat("Humidity", data.humidity);
Serial.print("Temperature : ");
Serial.print(data.temperature);
Serial.print(" Humidity : ");
Serial.println(data.humidity);

lcd.setCursor(0, 0); lcd.print("Temperature :" + String(data.temperature)); lcd.write(0); lcd.print("C");

lcd.setCursor(0, 1); lcd.print("Humidity :" + String(data.humidity) + "%"); tb.loop();

tb.loop();

}

MathewHDYT commented 10 months ago

@Shayantika-Dhar Which library version are you using becuase v0.12.2 should fix this error.

Otherwise you could also go into the Arduino_MQTT_Client and change the include from TBPubsubClient.h to Pubsubclient.h