I'm running into this weird problem. My code is working just fine when I upload it to an ESP32 from Arduino IDE. That same code is not working when I upload it using PlatformIO IDE. The same libraries versions are being used on both environments.
I've been reading that in PlatformIO you might have to make use of forward declaration (something that Arduino IDE solves out of the box). I do not know if this is the case. And if it is... I do not know how to apply it.
Can someone help me out with this?
#include <Arduino.h>
#include <DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define DHTPIN 23
#define DHTTYPE DHT11
LiquidCrystal_I2C lcd(0x27,16,2);
DHT dht(DHTPIN, DHTTYPE);
void setup() {
lcd.init();
lcd.backlight();
Serial.begin(115200);
dht.begin();
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.print(F("Humedad: "));
Serial.print(h);
Serial.print(F("% Temperatura: "));
Serial.print(t);
Serial.println(F("°C "));
lcd.setCursor(0,0);
lcd.print("Humedad: ");
lcd.println(String(h));
lcd.setCursor(0,1);
lcd.print("Temp.: ");
lcd.print(String(t));
}
EDIT:
platformio.ini
[env:fm-devkit]
platform = espressif32
board = fm-devkit
framework = arduino
monitor_speed = 115200
upload_port = COM9
lib_deps =
adafruit/DHT sensor library@^1.4.3
adafruit/Adafruit Unified Sensor@^1.1.5
marcoschwartz/[email protected]