Newbe here… I’m working on a project that becomes too bloated for Arduino IDE so I decided to see if Platformio is for me.
Small steps. I first did a blink project on the D1 Mini Pro I’m using for this project and that runs fine.
Then I loaded part of the code I use in my project. This compiles and runs fine in Arduino, but I get several errors in Platformio. The compiler complains it cannot find header files and expects different data types for a function. The code for this can be found here:
First of all, the compiler cannot find PolledTimeout.h. That library is part of the core esp8266 library so I would think that if it can find ESP8266WiFi.h it should also find PolledTimeout.h.
Next step I removed all ‘unnecessary’ code so I ended up with this:
#ifndef STASSID
#define STASSID "blah" // set your SSID
#define STAPSK "blah" // set your wifi password
#endif
#define MY_NTP_SERVER "at.pool.ntp.org"
#define MY_TZ "CET-1CEST,M3.5.0/02,M10.5.0/03"
/* Necessary Includes */
#include <ESP8266WiFi.h> // we need wifi to get internet access
#include <time.h> // time() ctime()
/* Globals */
time_t now; // this is the epoch
tm tm; // the structure tm holds time information in a more convient way
void showTime() {
time(&now); // read the current time
localtime_r(&now, &tm); // update the structure tm with the current time
Serial.print("year:");
Serial.print(tm.tm_year + 1900); // years since 1900
Serial.print("\tmonth:");
Serial.print(tm.tm_mon + 1); // January = 0 (!)
Serial.print("\tday:");
Serial.print(tm.tm_mday); // day of month
Serial.print("\thour:");
Serial.print(tm.tm_hour); // hours since midnight 0-23
Serial.print("\tmin:");
Serial.print(tm.tm_min); // minutes after the hour 0-59
Serial.print("\tsec:");
Serial.print(tm.tm_sec); // seconds after the minute 0-61*
Serial.print("\twday");
Serial.print(tm.tm_wday); // days since Sunday 0-6
if (tm.tm_isdst == 1) // Daylight Saving Time flag
Serial.print("\tDST");
else
Serial.print("\tstandard");
Serial.println();
}
void setup() {
Serial.begin(115200);
Serial.println("\nNTP TZ DST - bare minimum");
configTime(MY_TZ, MY_NTP_SERVER); // --> Here is the IMPORTANT ONE LINER needed in your sketch!
// start network
WiFi.persistent(false);
WiFi.mode(WIFI_STA);
WiFi.begin(STASSID, STAPSK);
while (WiFi.status() != WL_CONNECTED) {
delay(200);
Serial.print ( "." );
}
Serial.println("\nWiFi connected");
// by default, the NTP will be started after 60 secs
}
void loop() {
showTime();
delay(10000); // dirty delay
}
This compiles and runs fine in Arduino IDE, but gives the following error in Platformio:
src/main.cpp: In function 'void setup()':
src/main.cpp:45:34: error: invalid conversion from 'const char*' to 'long int' [-fpermissive]
configTime(MY_TZ, MY_NTP_SERVER); // --> Here is the IMPORTANT ONE LINER needed in your sketch!
^
src/main.cpp:45:34: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
src/main.cpp:45:34: error: too few arguments to function 'void configTime(long int, int, const char*, const char*, const char*)'
In file included from /Users/arjen/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WiFi/src/WiFiClient.h:25:0,
from /Users/arjen/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WiFi/src/ESP8266WiFi.h:39,
from src/main.cpp:10:
/Users/arjen/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/Arduino.h:292:17: note: declared here
extern "C" void configTime(long timezone, int daylightOffset_sec,
^
*** [.pio/build/d1_mini_pro/src/main.cpp.o] Error 1
Seems Platformio uses another definition for the configTime() function than the Arduino IDE.
As I understand it Platformio loads the esp8266 libraries when needed, unlike Arduino where it is installed in the Arduino15 folder.
I’m not a very experienced programmer, so I’m probably missing something obvious but I have tried finding what could be wrong for two days now getting nowhere…