Hi, I’m trying to do a title project on a ESP32 using a ILI9341 + RTC DS3231, but the result in Platform IO is not the expected.
If I put the same Sketch in arduino IDE it work as expected.
On PlatformIO using only the RTC DS3231 or the ILI9341 it work correctly, but not the 2 together on the same sketch.
This is the sketch:
#include <TFT_eSPI.h>
#include <SPI.h>
#include "Free_Fonts.h"
#include <RTClib.h> // for the RTC
#include <Wire.h>
TFT_eSPI tft = TFT_eSPI();
RTC_DS3231 rtc;
char t[34];
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup()
{
Serial.begin(115200);
Wire.begin();
rtc.begin();
if (rtc.lostPower())
{ // uncomment this line on the second time upload
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
} // uncomment this close curly braces
tft.init();
tft.setRotation(1);
tft.fillScreen(TFT_NAVY);
tft.setTextColor(TFT_SKYBLUE, TFT_SKYBLUE);
//tft.setTextSize(1);
tft.drawRect(0, 20, 107, 100, TFT_SKYBLUE);
tft.drawRect(106, 20, 108, 100, TFT_SKYBLUE);
tft.drawRect(213, 20, 107, 100, TFT_SKYBLUE);
tft.drawLine(0, 220, 320, 220, TFT_SKYBLUE);
}
void loop()
{
DateTime now = rtc.now();
sprintf(t, ", %02d/%02d/%02d and it's %02d:%02d:%02d", now.day(), now.month(), now.year(), now.hour(), now.minute(), now.second());
tft.setFreeFont(FF21);
tft.drawString(t, 0, 1);
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.println(t);
delay(1000);
}
Compiled result in platformIO serial monitor is:
Wednesday, 03/82/2045 and it's 45:161:00
Wednesday, 03/82/2045 and it's 45:161:00
Compiled result in Arduino IDE show is:
Friday, 04/02/2022 and it's 00:55:57
Friday, 04/02/2022 and it's 00:55:58
What I’m doing bad in PlatformIO ?
This is my Platformio.ini
[env:esp32dev]
monitor_speed = 115200
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = TFT_eSPI
adafruit/RTClib
Sorry if my english is not the best