RESOLVED - emonGLCD clock error

After having run my emonGLCD, emonTX and emonbase for the past 8+ weeks without as much as a reset, yesterday I found the emonbase not updating emoncms (online version) so I thought it'd be a good time to update to the latest sketch versions while fixing it.  All went well after making personal tweaks, except for the emonGLCD hour now continually showing 0.  When I upload the old sketch the time displays correctly so I know the emonbase is working as it should.  The minutes are showing correct.

While trying to fix it  I had considered swapping the hours,and minutes around in the bit of sketch:


        RTC.adjust(DateTime(2012, 1, 1, rf12_data[1], rf12_data[2], rf12_data[3]));

        last_emonbase = millis();

 but I wasn't sure which of these referred to what - the older sketch had emonbase.hour emonbase.mins to help me out.  Also the emonbase doesn't appear to send seconds now either (not an issue) so does the three entries as above require this?

My assumption is that I must be doing something wrong as this must be working for everyone else, so any pointers in what to look for would be appreciated.




glyn.hudson's picture

Re: RESOLVED - emonGLCD clock error

 Hi Dennis, 

Trystan has recently overhauled how we retrieve the current time from emoncms. Previously we were extracting the time from the http server responce header everytime data was posted. This worked well but is not ideal if the server is not set to local time. The latest version of emoncms had a local time API. The user can set their local time in emoncms then this time is requested from the emonBase with the following:


 if ((millis()-time60s)>60000)

    time60s = millis(); // reset lastRF timer
    str.print(basedir); str.print("/time/local.json?"); str.print("apikey="); str.print(apikey);
    Serial.println("Time request sent");
    ether.browseUrl(PSTR(""),str.buf, website, my_callback);

The time is then extracted and sent to the emonGLCD with the following (the RF transmission format has been changed):

 else if(line_buf[0]=='t')

    Serial.print("Time: ");
    char tmp[] = {line_buf[1],line_buf[2]};
    byte hour = atoi(tmp);
    tmp[0] = line_buf[4]; tmp[1] = line_buf[5];
    byte minute = atoi(tmp);
    tmp[0] = line_buf[7]; tmp[1] = line_buf[8];
    byte second = atoi(tmp);
    if (hour>0 || minute>0 || second>0)
      char data[] = {'t',hour,minute,second};
      int i = 0; while (!rf12_canSend() && i<10) {rf12_recvDone(); i++;}
      rf12_sendStart(0, data, sizeof data);


This code has been integrated into the latest nanodeRF example. Make sure your posting to the latest verson of emoncms for this new time API to work

rwijbenga's picture

Re: RESOLVED - emonGLCD clock error



I am using the latest version of emoncms, but I can't find the time setting. Where can I set the time in emoncms? And how can I test the time output? On my emonglcd the time is not displayed.



logic's picture

Re: RESOLVED - emonGLCD clock error

 Thanks Glyn

I've now updated all the system to latest sketches and the clock is working perfectly.  I think the issue may have been that I was still using an old emonbase sketch and it would have been posting to



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.