Page 1 of 2

btmon, emoncms and GEM - Volts, Current, Power Factor

Posted: Tue Jun 23, 2015 11:31 am
by awtivy
Hi there,

Currently have btmon receiving data from the GEM every 10 seconds and uploading it to my locally hosted emoncms every 30 seconds. I would like to get voltage working to be able to calculate live power factor as well as I can't seem to get the GEM to push current data to the Emoncms. I'm currently using "Binary data, 48* channels with NET** values and time-stamp" and have include current in packet on. I tried to follow a guide for SEG to get voltage working but not sure if I've done it right. Is anyone able to confirm my method and help me get the current and volts working through btmon to emoncms?

I added the bottom two lines to the Openenergymonitorprocessor for the voltage

Code: Select all

def process_calculated(self, packets):
        for p in packets:
            osn = obfuscate_serial(p['serial'])
            data = []
            for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_PE_LABELS)):
                data.append('%s_w:%.2f' % (mklabel(osn, c), p[c+'_w']))
            for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_PE_LABELS)):
                data.append('%s_wh:%.2f' % (mklabel(osn, c), p[c+'_wh']))
            for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_PULSE)):
                data.append('%s:%d' % (mklabel(osn, c), p[c]))
            for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_SENSOR)):
                data.append('%s:%.2f' % (mklabel(osn, c), p[c]))
            meter = 'volts'
            data.append('(v_%s %.1f)' % (mklabel(osn, c),p['volts']))   

Re: btmon, emoncms and GEM - Volts, Current, Power Factor

Posted: Tue Jun 23, 2015 2:26 pm
by mwall
try this instead:

Code: Select all

def process_calculated(self, packets):
    for p in packets:
        osn = obfuscate_serial(p['serial'])
        data = []
        for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_PE_LABELS)):
            data.append('%s_w:%.2f' % (mklabel(osn, c), p[c+'_w']))
        for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_PE_LABELS)):
            data.append('%s_wh:%.2f' % (mklabel(osn, c), p[c+'_wh']))
        for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_PULSE)):
            data.append('%s:%d' % (mklabel(osn, c), p[c]))
        for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_SENSOR)):
            data.append('%s:%.2f' % (mklabel(osn, c), p[c]))
        data.append('(v_%s %.1f)' % (mklabel(osn, 'volts'),p['volts']))

Re: btmon, emoncms and GEM - Volts, Current, Power Factor

Posted: Tue Jun 23, 2015 2:52 pm
by awtivy
Seems to be working thanks!

mwall wrote:try this instead:

Code: Select all

def process_calculated(self, packets):
    for p in packets:
        osn = obfuscate_serial(p['serial'])
        data = []
        for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_PE_LABELS)):
            data.append('%s_w:%.2f' % (mklabel(osn, c), p[c+'_w']))
        for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_PE_LABELS)):
            data.append('%s_wh:%.2f' % (mklabel(osn, c), p[c+'_wh']))
        for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_PULSE)):
            data.append('%s:%d' % (mklabel(osn, c), p[c]))
        for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_SENSOR)):
            data.append('%s:%.2f' % (mklabel(osn, c), p[c]))
        data.append('(v_%s %.1f)' % (mklabel(osn, 'volts'),p['volts']))

Re: btmon, emoncms and GEM - Volts, Current, Power Factor

Posted: Tue Jun 23, 2015 3:28 pm
by awtivy
mwall do you have any ideas for passing current through to emoncms via btmon?

Thanks

Re: btmon, emoncms and GEM - Volts, Current, Power Factor

Posted: Tue Jun 23, 2015 4:52 pm
by mwall
awtivy wrote:mwall do you have any ideas for passing current through to emoncms via btmon?
you must make some changes to btmon. the current is reported in bytes 490-585 of the binary packets. so you would have to first extract them from the packet, then include that in the upload data.

if you did it just for emoncms it would mean modify these:

Code: Select all

GEM48PBinaryPacket.channels
GEM48PBinaryPacket.compile
GEM48PTBinaryPacket.channels
GEM48PTBinaryPacket.compile
OpenEnergyMonitorProcessor.process_calculated
then to make it work you must enable 'include current' in the packet configuration on the gem itself.

m

Re: btmon, emoncms and GEM - Volts, Current, Power Factor

Posted: Tue Jun 23, 2015 5:07 pm
by awtivy
That programming would be way over my head :cry: . How long would it take to do?
mwall wrote:
awtivy wrote:mwall do you have any ideas for passing current through to emoncms via btmon?
you must make some changes to btmon. the current is reported in bytes 490-585 of the binary packets. so you would have to first extract them from the packet, then include that in the upload data.

if you did it just for emoncms it would mean modify these:

Code: Select all

GEM48PBinaryPacket.channels
GEM48PBinaryPacket.compile
GEM48PTBinaryPacket.channels
GEM48PTBinaryPacket.compile
OpenEnergyMonitorProcessor.process_calculated
then to make it work you must enable 'include current' in the packet configuration on the gem itself.

m

Re: btmon, emoncms and GEM - Volts, Current, Power Factor

Posted: Tue Jun 23, 2015 6:05 pm
by awtivy
Ok I sacked up and gave it a try,

TBH i'm still waiting on getting the CT's installed (donut style) in our office so I was using the Wattage Simulation for data.

I edited lines

Code: Select all

932
FILTER_CURRENT = 'current'
1756
        elif fltr == FILTER_CURRENT:
            for x in range(1, self.NUM_CHAN + 1):
1800
	for x in range(1, self.NUM_CHAN+1):
			cpkt['ch%d_a' % x] = self._convert(rpkt[487+2*(x-1):487+2*x])
3760
			for idx, c in enumerate(PACKET_FORMAT.channels(FILTER_PE_LABELS)):
				data.append('%s_a:%.2f' % (mklabel(osn, c), p[c+'_a']))
I'm getting 0 values for XXX149_ch1_a through channel 31 then value 33536 of channel 32.
I'm stumped

Re: btmon, emoncms and GEM - Volts, Current, Power Factor

Posted: Tue Jun 23, 2015 6:13 pm
by awtivy
Revised

Code: Select all

	for x in range(1, self.NUM_CHAN+1):
			cpkt['ch%d_a' % x] = .02 * self._convert(rpkt[486+2*(x-1):486+2*x])

Re: btmon, emoncms and GEM - Volts, Current, Power Factor

Posted: Tue Jun 23, 2015 6:32 pm
by awtivy
revised line 3768

Code: Select all

			data.append('%s:%.1f' % (mklabel(osn, 'volts'),p['volts']))

Re: btmon, emoncms and GEM - Volts, Current, Power Factor

Posted: Wed Feb 17, 2016 11:18 pm
by wci68
I have submitted a github pull request for some additions to
  1. Send GEM voltage to OpenEnergyMonitor (emoncms)
  2. Process channel 'current' values from GEM, optionally.
  3. Send channel 'current' values to OpenEnergyMonitor (if processing enabled)
I plan to add optionally the channel 'current' values to RRD and MySQL, at least. However these will take some thought. If the target RRD files or MySQL DB table do not exist this is easy, but if these already exist but were not created with support for the channel 'current' values it is a little more complex.