emonGLCD - debugging basic issues


I've just soldered together my emonGLCD and running the tester sketch. It is certainly not a complete failure but there are a couple of things I'd like to ask about.

1. When the screen says Green LED it is in fact red, does this mean I have the LED the wrong way round?

2. The switches part of the display seems very confused, It seems to switch between blank and Up, pressing the bottom switch will say Down and it returns to its previous value afterwards. Pressing the middle one says Up. Pressing the top one says Enter. Any ideas?

3. The light level seems to read 0 the majority of the time, Covering the sensor will spike it up momentarily but it returns to 0 without me removing my finger, any ideas?



TrystanLea's picture

Re: emonGLCD - debugging basic issues

Hello Matt, Yes it sounds like your LED's are the wrong way around, but that doesnt really matter as you can switch them in software, for example in the tester sketch the digital pins that control the color is defined like this:

const int redLED=9;               // Green tri-color LED
const int greenLED=6;                // Red tri-color LED

Just switch them around.

The bottom one should say down when pressed and return to blank

The middle one should say up when pressed and return to blank

The top one should say enter when pressed and return to blank.

Again you can switch these around if you wish by changing the digital pin numbers:

const int enterswitchpin=15;        // digital pin of enter switch - low when pressed
const int upswitchpin=16;           // digital pin of up switch - low when pressed
const int downswitchpin=19;         // digital pin of down switch - low when pressed

To set the top push button to be up and middle to be enter set enterswitchpin = 16 and upswitchpin = 15

The light level on my test emonglcd here in a room lit by daylight is currently 925 dropping to 720 when lightly shaded with my hand. Could there be accidental solder bridge affecting your LDR? I also have the LDR pointing up and out of the case. 




Robert Wall's picture

Re: emonGLCD - debugging basic issues


Have you got the correct resistor for R6 (the one closest to S1 & S2 - brown-black-orange, see the build guide)?  It could also be a bad joint on the LDR.

[I recommend you leave the LEDs as they are, and change the software. If you try to unsolder them, you risk damaging the PCB and there's no harm in swapping the pin numbers in the software and no risk of damage to the PCB.]

mattdale77's picture

Re: emonGLCD - debugging basic issues

Should both the LEDs flash the same colour? Currently they only flash red, no green ever. I'll try swapping in the software tomorrow though and see what happens.

I have the LDR pointing up out of the case but don't have the back  on yet anyway. Definitely no solder bridge, probably my best soldering on the whole board for that. I bought all the parts from Trystan and followed the build guide right up until the point where it says not to attach the LCD properly until all is working, as I'd already jumped ahead and fitted it.

MartinR's picture

Re: emonGLCD - debugging basic issues

You can see from the circuit diagram that the 2 LEDs are connected in parallel so they will always show the same colour.

If the green LED doesn't come on when you run the test script then clearly you have a hardware fault somewhere. Swapping the outputs in software won't solve this.

mattdale77's picture

Re: emonGLCD - debugging basic issues

My LEDs alternate, never both on at the same time, even swapping the constants in the test script they are still only red and alternating

When it says RED LED on the screen the left LED is lit in red, when it says GREEN LED the right LED is lit in red

LDR still shows 0

The switches part of the display seems to be quite random, looking at both the display and the serial monitor, the lowest (Down) button seems to operate correctly, the top one seems to be a bit intermittent and the middle one works when I press it but after I let go it acts like it is still pressed for a time

Robert Wall's picture

Re: emonGLCD - debugging basic issues

If you get  a red LED on each side alternately, it means that the RED and GREEN outputs are working correctly, but the right LED is inserted the wrong way round. You'll have to unsolder it. As MartinR says, the two LEDs are wired in parallel, so because the red LED works on a lower voltage than the green, it is starving it of current and the green on the other side is not lighting.

Unsoldering the LED: I suggest you get a soldering iron with a wide chisel bit and melt all 3 joints simultaneously, then pull the LED out while the solder is still molten. You'll need a clamp or someone to hold the board while you do it. Then suck or wick the solder out of each hole in turn. Take care not to overheat the PCB. If you can't do it on the first few attempts, you might need to destroy the LED in situ and remove the remains of the wires from the holes one at a time. Then get a replacement LED.

LDR: What voltage do you read across the LDR itself? I see about 0.4 V when facing a window, about 2 V when well shaded but not completely covered. Look at the circuit diagram - there are only the two components, the LDR and R6 plus the analogue input, so very little to go wrong. The processor input pin has gone into the socket correctly and not folded underneath?

Switches: This sounds like a mechanically dodgy switch. Does it feel and sound the same as the good one?



mattdale77's picture

Re: emonGLCD - debugging basic issues

I'll turn the LED around later.

It seems to be over 3.2V which would imply that it is not doing much resisting at all. The processor is seated correctly and all pins where they should be. I'll try to lift the LCD and check the solder underneath but I'm pretty sure it's fine

All the switches feel the same

MartinR's picture

Re: emonGLCD - debugging basic issues

Good diagnosis work on the LEDs Robert, great bit of reasoning there.

Robert Wall's picture

Re: emonGLCD - debugging basic issues

I wouldn't even try to get the LCD out unless there is absolutely no alternative, there is a great risk of writing off the pcb and the display. But why do you want to do that? I can't see that it would help.

What does the display show if you short the LDR - it should go to 1023. If you have a multimeter that applies a very low voltage on the resistance ranges (check the manual), then you could try to measure the LDR in situ. As a guide, I measured about 2 kΩ in good light and about 20 kΩ when well shaded.

Again, you should be able to get your meter on the switches - the contacts are the two pins nearest the board edge. You can probably test those in situ too, if your meter responds fairly quickly on the resistance ranges.

mattdale77's picture

Re: emonGLCD - debugging basic issues

Made some progress now. I damaged the LED while removing it but the remaining one now flashes red and green.


Strangely the LDR now seems to have come to life and a reasonable percentage of the time seems to behave as expected. But the display regularly goes to zero for a while no matter what the lighting condition. 

The top switch now displays Enter on the display when pressed, however it does not immediately go off and Enter often just pops up randomly on the display whether the button is pressed or not.

The middle now seems to perform as expected

The bottom button comes on as expected but seems to take some time to notice that it is no longer pressed

Robert Wall's picture

Re: emonGLCD - debugging basic issues

"But the display regularly goes to zero..."

What provokes that? Anything specific that you've noticed?

Switches: Can you measure the voltage on the common connection between the switch and the 10 kΩ pull-down resistor for each switch? You should see a steady 0 V normally, and a steady 3.3 V while the switch is pressed.
Remember it does take the sketch a short time to run around the main loop, measuring temperature, writing to the display, etc so the switches won't respond instantaneously, mine tells me it takes 820 ms to run through loop( ) from top to bottom, inside the loop it takes 38 ms between reading the switches and writing the state to the display and refreshing the display. So it could be about 858 ms between the switch moving and the display changing, if you just catch the worst case, and 38 ms best case.

mattdale77's picture

Re: emonGLCD - debugging basic issues

I've not noticed anything repeatable, sometimes covering the LDR it goes to 0 and doesn't raise when the cover is removed. Sometimes it just does it all on its own.

The delay in the display updating was several seconds. I'll check those voltages tomorrow and also check with the serial output and see if this picks up the response any faster

Comment viewing options

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