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

Post any 3rd party software here.
awtivy
Posts: 7
Joined: Tue Jun 23, 2015 11:08 am

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

Post by awtivy » Tue Jun 23, 2015 11:31 am

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']))   
mwall
Posts: 140
Joined: Wed Dec 07, 2011 6:25 pm

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

Post by mwall » Tue Jun 23, 2015 2:26 pm

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']))
awtivy
Posts: 7
Joined: Tue Jun 23, 2015 11:08 am

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

Post by awtivy » Tue Jun 23, 2015 2:52 pm

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']))
awtivy
Posts: 7
Joined: Tue Jun 23, 2015 11:08 am

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

Post by awtivy » Tue Jun 23, 2015 3:28 pm

mwall do you have any ideas for passing current through to emoncms via btmon?

Thanks
mwall
Posts: 140
Joined: Wed Dec 07, 2011 6:25 pm

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

Post by mwall » Tue Jun 23, 2015 4:52 pm

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
awtivy
Posts: 7
Joined: Tue Jun 23, 2015 11:08 am

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

Post by awtivy » Tue Jun 23, 2015 5:07 pm

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
awtivy
Posts: 7
Joined: Tue Jun 23, 2015 11:08 am

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

Post by awtivy » Tue Jun 23, 2015 6:05 pm

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
awtivy
Posts: 7
Joined: Tue Jun 23, 2015 11:08 am

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

Post by awtivy » Tue Jun 23, 2015 6:13 pm

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])
awtivy
Posts: 7
Joined: Tue Jun 23, 2015 11:08 am

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

Post by awtivy » Tue Jun 23, 2015 6:32 pm

revised line 3768

Code: Select all

			data.append('%s:%.1f' % (mklabel(osn, 'volts'),p['volts']))
wci68
Posts: 43
Joined: Thu Dec 17, 2015 4:31 pm

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

Post by wci68 » Wed Feb 17, 2016 11:18 pm

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.
Post Reply