emonTx connecting to arduino IDE using programmer

Very easily.

The line/statement you need will look a bit like
Serial.print((int)(realPower1+realPower2+realPower3+0.5));
if you’re using the serial port & programmer. (+realPower4 if you wish)

Then don’t send, or don’t use, the individual powers. If you choose not to send them, then you might need to change emonHub and exclude those from that Node. (If the output disappears when you remove the unwanted data, you need to change emonhub.conf.)

hmmm. Is this going into the ‘emonTx_3Phase_PLL’ tab? I’m not sure how to include that. Is it in this section:

In terms of sending the individual powers, i’ll try to just select the node_id linked to the combined power output and leave the rest.

Yes - into the main file, that’s the one that has the same name as the directory it’s in.

I think I’ve lost the plot - I don’t understand that. The Node ID refers to the identity of the emonTx and “ALL” the data you’re sending from it.

I use the api to pull the data through in Node-Red. So i’ll just use the node id (https://emoncms.org/feed/aget.json?id=1 - in this case ‘1’) for the feed that has all 3 powers combined.

I think i meant to say ‘Feed ID’, not ‘Node ID’

That makes sense now.
You can of course add the inputs in the input processing in emonCMS and save to a feed, but doing it in the sketch guarantees that all three powers come from the same sampling interval. That might not be the case when summing in emonCMS.

I’ve not had a need to set up NodeRed, so I’ve no idea what it needs.

Hello again @Robert.Wall Would you mind just clarifying how I need to edit the code. Is it from:

Serial.print((int)(realPower1+0.5) + (int)(realPower2+0.5));   // These for compatibility, but whatever you need if emonHub is configured to suit. 
Serial.print(F(" 0.0 "));

To

Serial.print((int)(realPower1+realPower2+realPower3+0.5) );   // These for compatibility, but whatever you need if emonHub is configured to suit. 
Serial.print(F(" 0.0 "));

Can I just leave the rest of the section as it is?

Thanks again

I’ve lost track of what you have.

You need to put it in the correct section for the output format and the mains system have you selected.
(The sketch works for pretty much all combinations - set up by the choices you made at the top of the sketch, which then select which bits to use.)

If you’ve asked for SERIALOUT (space-separated values) then it needs to go in the section selected by

but if you’ve asked for EMONESP (Key:value pairs) then it needs to go in the section selected by

#if defined EMONESP && !defined SERIALOUT

As you’re not too far from me, I presume you have a 3-phase, 4-wire system. So inside that selection, you need to put (or edit) that line NOT in the 3-wires section.
(What you have there is a straightforward if – then – else, the “if” being if you’ve got a 3-wire system, which I think you won’t have, therefore you want the ‘else’ case or put it in past the end, which means ‘both’.)
So you can put it in the #else clause, or you can put it after the #endif
You can leave the variables you don’t need (especially if you’re likely to need the individual values in the future, or if you’ll never need those on their own, you can safely delete them.

Now i’m really confused!

I haven’t made any changes to the PLL sketch that you suggested I use. It seems to be working ok whereby i’m getting values for the three phases that look about right. I have gone through the options and them seem ok for my system.

I haven’t selected SERIALOUT or EMONESP. I’m using RFM69CW. Does this mean I can’t request the values to be added together?

Now it’s my turn to be confused. The thread is titled " emonTx connecting to arduino IDE using programmer" and that implies a serial wired connection via the programmer. Are you saying that isn’t what you’re doing, and haven’t been doing throughout?

Either way, if you want, you can change ALL the outputs to send only the sum, or the sum as well as the individual numbers. The reason behind doing the sum in the emonTx and sending it as one value, and not doing the sum in emonCMS, is (and I think I mentioned this earlier), you can have the situation where the Pi takes its time doing the maths in between doing other stuff, and ends up adding readings from two sets of results - 10 s apart. If you can live with that, there’s nothing you need to do. The ‘proper’ way is to add the numbers from a set of readings all done over the same period, which is what adding them in the emonTx does.

Sorry Robert, you are right i have connected the emonTx to arduino to get the right Sketch on there. I’m now using the emonTx with an emonbase to record data. This is over RF.

I’m now trying to figure out how to combine the three phases into a single output, but was lazy and didn’t start a new thread for this discussion. Sorry about that.

I can’t figure out how to change the outputs to send only the sum. I think i’ll just sum them either in emoncms or in node-red

Actually, it’s probably easier for me that you kept the same thread, but I wish you’d said “Now I want to do it with the RFM” (or something like that).

It’s still the same principle, but slightly more involved. I’m assuming you want both the individual values and the sum of the powers.

At the top, at line 49 for emonhub.conf, you’re going to want this:

    [[[rx]]]
        names = power1, power2, power3, power4, sumPower, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulsecount
        datacodes = h, h, h, h, h, h, h, h, h, h, h, h, L
        scales = 1,1,1,1,1,0.01,0.01,0.01,0.01,0.01,0.01,0.01,1
        units =W,W,W,W,W,V,C,C,C,C,C,C,p

Line 306, add the extra power:

typedef struct { int power1, power2, power3, power4, sumPower, Vrms, temp[MAXONEWIRE] = {UNUSED_TEMPERATURE,UNUSED_TEMPERATURE,
                  UNUSED_TEMPERATURE,UNUSED_TEMPERATURE,UNUSED_TEMPERATURE,UNUSED_TEMPERATURE};
                  unsigned long pulseCount; } PayloadTx; 

At lines 842-3, where you have

  emontx.power4=(int)(realPower4+0.5);
  emontx.Vrms=(int)(Vrms*100+0.5);

you need to insert (before, after or in between, it doesn’t matter)

  emontx.sumPower=(int)(realPower1+realPower2+realPower3+realPower4+0.5);

(OK, you can leave off realPower4 if you don’t want it in the sum.)

Don’t be too alarmed if the individual powers don’t add to the sum - it’s rounding. The individual powers are rounded on their own, but summed before rounding and the sum is separately rounded.

Thank you @Robert.Wall i’ve edited my Sketch based on your (very clear) instructions and will test on Monday.

Looks to be working perfectly @Robert.Wall. Just need to get the other two EmonTXs online now. thanks again for your help.

If sending by r.f., I think you’re aware that you need to make sure each emonTx sends using a different NodeID.
If one is connected serially, you can give it a Node ID offset in emonHub - which in effect means the default value of 0 can be increased to put it onto one of the pre-programmed definitions in emonHub. e.g. the original NodeID sent by the emonTx serially was 15, to move it to 17:

(N.B. - use the correct interfacer!)

Thanks Rob, i have set each EmonTx to use a different nodeID (15, 16 & 17) I’ve also updated the config file for each one to reflect this.

Hi Rob, I hope you don’t mind me asking in this thread, but do you know if the emonTx can be used with higher amp supplies. I’m interested in connecting to a 250A 3phase connection for example. If i get CT clamps that will fit can the emonTX cope with that? I read a comment of yours that explained you would need to adjust the sketch for a 200A CT clamp, Thanks

Basically, you can use any c.t. you like, but with minor changes:

If you get a c.t. that does NOT have a 50 mA output at the rated current (or at the maximum current you’re going to see, if less), then you must change the burden resistor, and
You will need to change the calibration.

There’s a list of c.t’s that have large wire windows (the opening the current carrying conductor passes through), as well as rated currents higher than 100 A, on the “Use in N.America” page in learn.

The detail is: the ADC input is a voltage, 1.1 V rms maximum. You need a burden, either internal, external or the two in parallel, to give that voltage at the maximum current you’re interested in. You change the maths with the calibration constant so that the right numbers come out. That constant is the current that will give you 1 V rms across the burden (± errors in the ADC reference).

Hi Rob,

(Change of topic)

I just had a quick look on the community tab and couldn’t find anything on ‘inactive’ feeds that helped. Do you know how to test a feed/make it active again?

Its been like this for about a week now.

Thanks

I ended up connecting directly to the emonTx and running the serial monitor. That seemed to kick things back to life and its now active and sending data to emoncms.

This is a concern though. Is it possible to do a remote reboot via the emonbase to get it up and running again?

The only way is to send it data.

But why your data stopped, I’ve no idea. You can reboot the emonTx physically by pressing the reset button, which might be the only way if it’s not communicating. The real question, and there’s probably no way of knowing, is did the emonTx stop transmitting or did the base stop receiving? I’ve never had an emonTx not send serial data (unless it was finger trouble in the code), and I’ve never had one connected serially except to a computer to program it, so I can’t really help. If you do have 2-way comms with it from the base, then of course you can send it the configuration and calibration commands, but there isn’t a plain “reboot” one, the only one is “r” which wipes all the custom settings and restores it to the “out-of-the-box” state. (Which would be OK to use if you transferred the calibration constants etc into the code and recompiled the sketch.)