Closed edomazzone closed 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...
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.
^~~~~~~~~~~~~~~~~~
compilation terminated.
i am getting this error but i have not used this library in my code
CODE:
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();
}
@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
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 1I 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.