Using Emonhub with the emoncms PacketGen module

First, in the guide to install emonhub, found here:

http://emonhub.org/documentation/install/raspberrypi/

The debian package installer is not working. I was able to install the development version of emonhub as described below, but this needs to be prefaced with a "cd ~" to go to your homedir before doing the git clone.

https://github.com/emonhub/dev-emonhub/blob/master/README.md

Then, in the following guide, "Using Emonhub with the emoncms PacketGen module" found here:

  https://github.com/emoncms/emoncms/blob/bufferedwrite/docs/emonhubmod.md

There are some issues with the guide:

1) There is no file called:

  /home/pi/emonhub/src/emonhub_listener.py

Member pb66 let me know the file is now called, "emonhub_interfacer.py"

2) If the "RFM12b Packet Generator" "Send Packet every:" seconds is changed, it doesn't change the transmitting interval of packets. No matter what I set the time to, packets are sent every 5 seconds. How can the interval be changed? And, can custom intervals be available in the future? Packets can be seen by using minicom to monitor the serial port as follows:

minicom -b9600 -D/dev/ttyAMA0

3) Modifying the packet structure to other than default appears buggy. If deleting variables other than glcdspace and time, some data is still transmitted after the variables are deleted. Does emonhub need to be restarted? Seems a restart has no effect.

Thanks to all for these new features being developed.

pb66's picture

Re: Using Emonhub with the emoncms PacketGen module

Hi Tom

With regard to using emonhub with packetgen, it is possible, Trystan kindly wrote a temporary mod prior to the renaming changes which is why I advised you to replace all occurrences of "listener" with "interfacer". It is a work around and is subject to change. However his guide says " We can modify emonhub to poll the packetgen module periodically and send the packetgen packet state over serial to the rfm12/69." this tells us that the data is retrieved by emonhub from packetgen which is why altering the un-used "send packet every" has no effect as the packets are not sent.

In this code you added to emonhub

if now - self._control_timestamp > 5:
    self._control_timestamp = now
    packet = urllib2.urlopen("http://localhost/emoncms/packetgen/rfpacket.json?apikey=APIKEY").read()
    packet = packet[1:-1]
    self._log.debug(self.name + " broadcasting control packet " + packet + "s")
    self._ser.write(packet+"s")

The first line is basically "if more than 5 seconds has passed since this last happened" so if you want to alter how frequently emonhub retrieves the data you can change it here.

As pointed out in my PM and Trystans guide how this is implemented in the future is not yet determined (hence the temp mod) there will be significant change to the way emonhub and emoncms inter-communicate and the control functions in both parties will be built around that connection, 

See if the result is still buggy now you are aware of the interval timing and allow time for packets to filter though to the nodes. if you edit/delete immediately after the packet has just been retrieved it is feasible for it to appear to be delivered after editing/deletion when you consider its route and browser refreshing etc, give it another try with this info and see how you get on.

Again this is a hack and is far from perfect but your participation is appreciated and any feedback can help development.

Just to recap and clarify a couple of your other points that were discussed by PM.  There has been no package installer version developed yet, so there isn't a problem with it as such,, other than it doesn't exist. which is why I directed you to the development version installer.

The guide you refer to is amongst a few pages on the website I experimented with during the early stages of planning and development of emonhub has taken priority over the website, so I will temporarily take the site down to avoid any further confusion.

The development installer is intended to be run from the homedir as this is the normal starting point, As you were installing to the Modules folder of emoncms  I prompted you to use cd to get back to the homedir. I have now altered the script to automatically change the current working directory to the homedir to remove the chance of error, therefore cd is not required regardless of current location.

Paul

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.