EmonGLCD Backlight

Loaded latest Solar PV sketch Backlight flashes during load then does not light. LED's and display  show correctly. 

Robert Wall's picture

Re: EmonGLCD Backlight

If you read the sketch, you will see (around line 230) that the backlight brightness is dependent on several factors - time and the light falling on the light-dependent resistor sensor. Check those.

divad's picture

Re: EmonGLCD Backlight

Thanks Robert

Is there a way of changing the time via serial as I am not connected to the internet for real time and I have restarted it 3 times today. This is the first time I have used an Arduino.

David

Robert Wall's picture

Re: EmonGLCD Backlight

If you haven't got the correct time, I would simply take out the 'time' part: 

if ((hour > 22) ||  (hour < 5)) glcd.backLight(0); else 

That will leave the backlight on all night. (And it's probably a good idea to remove the time from the display too, if it tells lies).

If you do want the time displayed and the history to work correctly, you could write an interface to accept serial input, but I think I'd use the spare switches (you do have the emonGLCD? ) - one to increment hours with each press, and another to increment minutes. You could more or less crib the code that changes the page display, incrementing hour and minute instead and feeding the new hour and minute into line 152 (RTC.adjust( ) ) which fairly obviously takes the time as YYYY, M, D, H, M, S.

Robert Wall's picture

Re: EmonGLCD Backlight

Here's a serial input. It's not the most bullet-proof code, you can no doubt improve it dramatically. Input should be in the form H:MM  or  HH:MM

Comment out the block that begins

  if (node_id == 15)

you don't need this - it's the time from the emonBase, then below the block of code that begins

  if (rf12_recvDone())

(which contained the bit you've just commented out) insert this:

    if (Serial.available() > 0) {
        char buffer[10];
        Serial.readBytesUntil('\n', buffer, 6);
        if (buffer[1] == ':')
        {                    // format h:mm
            hour = buffer[0] - 0x30;
            minute = (buffer[2] - 0x30) * 10 + buffer[3] - 0x30;
        }
        else                // format hh:mm
        {
            hour = (buffer[0] - 0x30) * 10 + buffer[1] - 0x30;
            minute = (buffer[3] - 0x30) * 10 + buffer[4] - 0x30;
        }
        if (hour >= 0 && hour < 24 && minute >= 0 && minute < 60)
        {
            RTC.adjust(DateTime(2012, 1, 1, hour, minute, 0));
            last_emonbase = millis();
        }
    }
 

 

divad's picture

Re: EmonGLCD Backlight

Thanks again Robert

I do have the emon GLCD and like the idea of setting the time by use of the buttons and will look into the code to do this then if power fails time can always be reset.

I think this is a facility the emon glcd needs. 

Thanks a lot Robert 

David

 

 

Robert Wall's picture

Re: EmonGLCD Backlight

I'm putting a system together for a friend. That does have net access, and I've implemented a button to add 1 hour (for daylight savings time). I think buttons makes more sense as it doesn't need a laptop & the back off to get at the serial connection. There's not enough free memory to do it automatically on the date!

Comment viewing options

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