No Vrms reading from emonTx v2

I’ve uploaded emonGLCD again (the size of the file looks about right at 23.5kB

My_emonGLCD_17-3-2019_1.ino (23.5 KB)

Where is “MegunoLink.h”? I don’t recognise that name.
Are there other files in the same directory as My_emonGLCD_17-3-2019_1.ino that appear as tabs in the IDE?

MegunoLink is a serial plotter to replace Arduino serial & “MegunoLink.h” is the library used to intercept IDE serial commands from the sketch it plays no other part in the sketch so can be commented out. Sorry forgot to upload other files
The other files in the emonGLCD folder are as below:

display.ino (8.6 KB)
serial.ino (1.2 KB)

Where do you see the voltage? I can’t find anything in the file that processes the voltage nor draws it on the screen.

But I’ve found out why the pushbuttons didn’t work for you on my debugger sketch - you’ve got the GLCD where the buttons work in the opposite sense. So to get your sketch working, I’ve had to change this:

       int S1=!digitalRead(enterswitchpin); //low when pressed
       int S2=!digitalRead(upswitchpin);    //low when pressed
       int S3=!digitalRead(downswitchpin);  //low when pressed

(i.e. invert the signal from the switch - to get my debugger sketch buttons to work, you must do the same, it’s at lines 176-178-180)
(And I’ve had to comment all the “plot” code.)

So, what do you want to do about the voltage? It needs to added to the screen somewhere.

[Edit]
Did you add the comment " //(int)cval1 resets string to empty? "
Because it’s not true. cval1 is a variable of type float (i.e. decimal), “(int)” is a cast - it strips away the decimal fraction to leave it as a whole number, an integer.
so if I write:

float MyFloat =  123.456;
int MyInt = (int)MyFloat * 2;

MyInt gets the value 246

So far I’ve only tried listing Vrms on the serial port; I haven’t tried plotting it yet because I couldn’t produce a value other than 0V

My S1 (top) switch works OK as is??? It shows current time & filename

It will do - but your emonGLCD and mine are different revisions of the pcb. So your sketch works on your GLCD but not on mine, and my sketch works on my GLCD but not on yours.

I still don’t understand why data from emonTx transmits to emonGLCD EXCEPT Vrms as it is part of the emonTx payload PayloadTX

I added “//(int)cval resets string to empty?” to the line:
“itoa((int)cval,str,10);”
because the same ‘str’ was used for ‘consuming’, ‘gen’ & ‘grid’

But the point is, although it was part of the payload struct at both ends, the two structs were different sizes, and it wasn’t in the same place.

The struct(data structure) assembles those integer (2 byte) variables into a single entity, in that order, that is 14 bytes long. They travel over the air as single pieces of data, like links in a chain, coming out in the GLCD in the same order, and in the same relative place. In the GLCD sketch, you need a matching struct to get the right pieces into the right variables. The struct you had didn’t stretch as far as Vrms, it was only 8 bytes long, so to get ‘Vrms’ into the GLCD, it needed to be in the position where ‘app2’ is in the emonTx sketch. So although all the data was being received by the GLCD, ‘Vrms’ wasn’t in the right place.

This is how I’ve changed it:

//---------------------------------------------------
// Data structures for transfering data between units
//---------------------------------------------------
typedef struct { int power1, power2, power3, sp1,  sp2,    sp3,  Vrms; } PayloadTX;    
// These map to{ int power1, app1,   power2, app2, power3, app3, Vrms; }
//power1 = grid, power2 = not used, power3 = solar, Vrms = nains voltage consuming = grid + solar
PayloadTX emontx; 

So you can see there that ‘power1’ appears as itself, and ‘power2’ comes out as ‘power3’. If you ever put a value into ‘app1’ in the emonTx, it will appear as ‘power2’ in the GLCD, likewise ‘app2’ will appear as ‘sp1’, ‘power3’ will appear as ‘sp2’ & ‘app3’ will appear as ‘sp3’. And finally, ‘Vrms’ is available (as itself) and appears in the sketch. Temporarily, I’ve put it on the clock page until you tell me where it wants to go.

It’s quite OK to use the same name for something that’s transient and only required for a brief period. As soon as you use it the next time and write a new value to it, as you do with ‘itoa( )’, the previous contents are overwritten and gone forever. There’s no need to try to “erase” it.

Thanks Robert I think I understand; Vrms was mapped to position 7 in emonTx but mapped to position 4 in emonGLCD.
Is that correct?

I’ve uploaded a graphic of MegunoLink for you to see what it does. I find it easier to use than ‘inputs’ & ‘feeds’ in emoncms (which I’m still struggling to get working properly)

Just upload your amendments to emonGLCD, Vrms now displays. I think I might put on main page of emonGLCD to replace the temp reading (which is hopelessly inaccurate because it picks up internal heat of emonGLCD)

Yes, that’s it. The position and size of the variables in those structures is the key.

My cure for that is to put the sensor on the end of some wire, so that it’s at the bottom rather than the top.