Skip to content

Unable to compile TimeClient straight out of the box #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cthompsonau opened this issue Dec 21, 2018 · 10 comments
Closed

Unable to compile TimeClient straight out of the box #148

cthompsonau opened this issue Dec 21, 2018 · 10 comments
Assignees

Comments

@cthompsonau
Copy link

Sample code doesn't compile for weatherstation. Returns the following error

C:\Users\christopher\Documents\Arduino\libraries\ESP8266_Weather_Station\src\TimeClient.cpp: In member function 'long int TimeClient::getCurrentEpochWithUtcOffset()':

C:\Users\christopher\Documents\Arduino\libraries\ESP8266_Weather_Station\src\TimeClient.cpp:124:67: error: invalid operands of types 'double' and 'long int' to binary 'operator%'

   return round(getCurrentEpoch() + 3600 * myUtcOffset + 86400L) % 86400L;](url)

We are using the default settings.h but something seems simple that we are missing. Any help would be appreciated.


#define UTC_OFFSET +1
struct dstRule StartRule = {"CEST", Last, Sun, Mar, 2, 3600}; // Central European Summer Time = UTC/GMT +2 hours
struct dstRule EndRule = {"CET", Last, Sun, Oct, 2, 0};       // Central European Time = UTC/GMT +1 hour
@wilhelmzeuschner
Copy link

wilhelmzeuschner commented Dec 21, 2018

I have the exact same issue and don't have any had some success trying to fix the error:

return fmod(round(getCurrentEpoch() + 3600 * myUtcOffset + 86400L), 86400L); //Some UI elements flash at roughly 2-3Hz

int temp_value = 86400; int temp_value_2 = round(getCurrentEpoch() + 3600 * myUtcOffset + 86400L); return temp_value_2 % temp_value; //doesn't work either
int temp_value_2 = round(getCurrentEpoch() + 3600 * myUtcOffset + 86400L); int return_temp = temp_value_2 % 86400; return return_temp ; //Seems to work

My problem now is that some UI elements are flashing, as described. This seems to be caused by the missing touch screen in my hardware-setup.
ThingPulse/esp8266-weather-station-color#84

@dmccuskey
Copy link

I had the same error – here was the modification i made which resulted in a successful compilation.

  return fmod(round(getCurrentEpoch() + 3600 * myUtcOffset + 86400L), 86400L);

Refs:

@just-jason
Copy link

just-jason commented Dec 25, 2018

return fmod(round(getCurrentEpoch() + 3600 * myUtcOffset + 86400L), 86400L);
Works for me, thanks for the tip

@marcelstoer marcelstoer self-assigned this Dec 25, 2018
@marcelstoer marcelstoer changed the title Unable to compile app straight out of the box Unable to compile TimeClient straight out of the box Dec 25, 2018
@marcelstoer
Copy link
Member

Not sure which application you compiled and in which environment you tried. I just tested WeatherStationDemoExtended and PlaneSpotterDemo (both use TimeClient) in Arduino IDE and both compile just fine straight out of the box.

@wilhelmzeuschner
Copy link

@marcelstoer I used the Arduino IDE v.1.8.5, the v.2.5.0 (beta2) ESP8266 board definition and selected the WEMOS D1 R2 board.

@just-jason
Copy link

just-jason commented Dec 25, 2018

I had issues when I tried to use the weather station demo. With the edited time client, it worked. I tried using IDE 1.8.3 & 1.8.7 both threw the same errors

@plazmax
Copy link

plazmax commented Dec 25, 2018

Downgrade esp8266 2.5.x beta to 2.4.x stable itll be solved.

@marcelstoer
Copy link
Member

...the v.2.5.0 (beta2)

We've had issues with that before, sigh. While it's true that floating point division does not have a
remainder, hence fmod, it's unfortunate that the ESP8266 Arduino-core team is pushing their betas onto the official release channel.

@marcelstoer
Copy link
Member

We since released Weather Station library v1.6.5 which includes this fix.

@marcelstoer
Copy link
Member

I invite you to comment on esp8266/Arduino#5554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants