emonTx connecting to arduino IDE using programmer

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.)

Thanks Rob, i think the resetting option could work. Just to clarify the emonbase is connected to the emontx over RF, not directly over serial.

I’d forgotten you’d changed to rf (hardly surprising as, wearing my moderator hat, I read every single post that appears). In that case, the reset button, or remove power, is the only way. The emonTx can physically, but doesn’t in the software, receive anything ever, except to sniff the radio band to check if it’s clear.

Great, thanks Rob.

Hi Rob, the emonTx has stopped communicating again. I’ve asked somebody on site to turn it off and on again, but am concerned this has happened twice within a few days.

Do you know if there is a way to ensure communications (would that be just by connecting directly to the emonbase using one of these cables for example USB to TTL Serial Cable– The Pi Hut ?) I can do that for 2/3 of my emonTx’s

The emonbase is powered using usb. Do you think it would be better to power it using a 3 pin plug? I’m wondering if that is losing power and then not reconnecting to the Tx

What, the emonTx, or the Base, or both? Turning the power off to the Raspberry Pi unnecessarily is definitely a bad idea as it can lead to corruption of the SD Card.

I don’t understand what you mean there. To begin with, what do you mean by “emonbase”? Is it a Raspberry Pi with a RFM12Pi or RFM69Pi https://shop.openenergymonitor.com/rfm69pi-433mhz-raspberry-pi-base-station-transceiver/ attached? That needs a 5 V d.c. USB power supply, it could be from a https://shop.openenergymonitor.com/5v-dc-usb-power-adapter-uk-plug/ or you could use battery-backed supply designed specially for the Raspberry Pi. Eventually, power must come from the mains supply.

Just the emonTx. I’ve had issues switching off the emonbase before!

The pi with the RFM69Pi attached. I’m currently powering it with a usb cable into a usb socket (something like this https://uk.rs-online.com/web/p/plug-sockets/1953564/?cm_mmc=UK-PLA-DS3A-_-google-_-PLA_UK_EN_Fuses_%26_Sockets_%26_Circuit_Breakers_Whoop-_-Plug+Sockets_Whoop-_-1953564&matchtype=&pla-301957763671&gclid=Cj0KCQjwyN-DBhCDARIsAFOELTk00TmmEMknuBN25RXVmOoJb5mZ6AJOWoayX2em5bE_uYk8Wq8EfIEaAlrjEALw_wcB&gclsrc=aw.ds)

I’m looking at getting a PiZero for the other locations in case this keeps happening. Would you recommend getting the WH version with the soldered Header?

Ouch. I don’t think I would trust one of those to power a Pi. They might be OK, and they are probably OK for charging phones overnight, but how clean the 5 V is would be a matter of concern.

However, if re-starting the emonTx only was enough to get it communicating again, then the problem has to be the emonTx end. And the only way I’ve succeeded in locking up an emonTx is with a dodgy power supply - if the power dips far enough to screw up the radio, but not far enough to cause it to reset even though the main sketch has, then it can lock up, because the hardware reset on the radio is not used. If that’s what is happening, then I suggest either powering it with a clean 5 V USB supply, or return to a variant of Plan A, i.e. direct serial connection to the Pi’s GPIO, and disable the radio in the sketch. I can’t vouch for the serial-USB connector. I would expect it to be OK, but I’ve never used one.

Neither am I a Pi Zero expert, @borpin is best placed to advise you on that.

It looks as though re-powering the emonTx hasn’t worked. I’m still not receiving anything through emoncms.org, so maybe it is the emonbase power supply. I have a plug socket available so i’ll try using that instead of the usb option.

I would like to try connecting via serial to the emonbase though as it sounds more robust (although i’ll still have rf connectivity for one of my emonTx’s on site). Can you confirm that the sketch you built doesn’t need any modifications (except switching off rf) when I connect via serial? I’m assuming I can connect per this wiki - EmonTx V3.4 - OpenEnergyMonitor Wiki. It would also be good to understand what I would need to do if i’m connecting to 2x emonTx with a single emonbase. Could I connect one via serial and one via rf or would it be better to do both via rf and have some delay in the signal?

@borpin - Rob, has suggested you might be the right person to speak to regarding PiZero connectivity?? I’m looking to connect a PiZero to an emonTx per this thread 4 CT emonBase using emonTx and Pi Zero W My question is do you know if there will be sufficient power for me to run the PiZero off the emonTx and also use a usb/Ethernet adapter to connectro to the LAN network? Thanks