Hi,
I would like to connect an EmonTx v3 to RaspberryPI via serial. I found instructions here but they refer to the Rock-solid-gateway forwarder image. In my case, I would like to the last ready to go image (emonSD-13-08-14.img) that include Emonhub.
I guess that the instruction are sill valid for the emonhub config file and the inittab file. But what should I do regarding the comandline.txt file that is really different ?
Can someone have a look on this ?
Thank's
Eric
Re: Serial link RPI<->EMonTX using Emonhub (emonSD-13-08-14.img)
Hi Eric
The cmdline.txt and inittab ashould already be done on the SD image. These 2 changes are done to any Pi running Raspbian OS that has any software that needs to access the serial port as by default Raspbian uses the serial port for a console. The ' # ' at the begining of the last line in /etc/inittab and ensuring the line in /boot/cmdline.txt does not contain " console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 " free's the serial port for other uses reagrdless of if that's a RFM2Pi or a direct serial connection.
Your cmdline.txt should probably read " dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait " if running the SD image.
In the emonhub.conf you will need to disable the RFM2Pi interfacer, which can easily be done by adding a " # " to the beginning of the "Type" line, this will effectively "comment out" the type and emonHub will not create interfacers that do not specify a type. so that line should be edited so it's
and to create a serial interfacer add a new set of settings to the [interfacers] section where the RFM2Pi settings are something like this
Changing the com_baud as required and adding any datacode etc to the runtimesetting. The 2 ....settings headings must be present even if there are no specific settings.
Paul
Re: Serial link RPI<->EMonTX using Emonhub (emonSD-13-08-14.img)
Thank's Paul !
I will give a try in the coming days.
Eric
Re: Serial link RPI<->EMonTX using Emonhub (emonSD-13-08-14.img)
Hi,
I forgot to reply that it works fine with an EmonTX V3 after modifying the emonTxV3_DirectSerial sketch. As explained also here, the nodeID is missing in that sketch. It makes emonhub suddenly fail (because the first value is a float ? Need to be fixed ?)
Just add Serial.print("10 "); on line 68 of that sketch to set the nodeID to 10.
As explained by Paul in the other thread, no need to modify the datacode section of emonhub
Eric
Re: Serial link RPI<->EMonTX using Emonhub (emonSD-13-08-14.img)
Hi Eric, thanks for letting us know.
With regard to the node id I suppose the 2 trains of thought would be
A) Since under normal circumstances there can be only one device communicating over serial there should be no need for a node id to know where the data come from, however since emonCMS expects a node id and there may well be other nodes connected to same emonhub. A node id would need to be added by emonHub before forwarding to emonCMS, which I guess could be a user setting in emonhub.conf, thus removing the need to edit the sketch to change/add a node id.
B) Adding a node id to the sketch would keep it in line with other OEM payloads so that emonHub etc can process the payload in the same way, this way also has flexibility for a serial connected device to use more than 1 node id for example if it is itself a interface for one or more devices (eg rs485)
Maybe a optional "nodeid" setting in emonhub could work. if a "nodeid" is specified in the serialinterfacer runtimesettings emonhub would use that and assume all serial data is values, alternatively if the user does not specify a "nodeid" it uses the first received byte as the node id. How does that sound ?
Paul
Re: Serial link RPI<->EMonTX using Emonhub (emonSD-13-08-14.img)
Hi Paul,
IMHO, adding a node id to the serial sketch is the best solution. No need to change anything in Emonhub, nor in EmonCMS. Keep it simple !
Did you notice that EMonhub fails whithout error message if the first value of the frame is a float ? Can you make emonhub more robust and/or more explicit.
Eric
Re: Serial link RPI<->EMonTX using Emonhub (emonSD-13-08-14.img)
Hi Eric, I wasn't aware of the float causing a failure, thanks for the heads up. I will certainly look into it, however there are some changes on the horizon (for other reasons) that will mean rewriting this part so I'm not overly concerned right now but will aim to make it as robust as possible.
You're probably right about adding the node id to the sketch being the easier, that was my preference too. I won't totally rule out the "optional node id" just yet though as there are other instances where this could be useful too. For example I have a "weather data" interfacer that requires a node id to be set and when I get around to it the "system data" interfacer inspired by your php script will need one too.
Paul
Re: Serial link RPI<->EMonTX using Emonhub (emonSD-13-08-14.img)
I wondered why I hadn't experienced this myself, so I dug out a couple of my old "serial output" sketches to look at and found in the past I have done things a little differently, When I have converted a sketch for serial output, I have added a function to print the "emontx" typedef struct so that the serial output was identical to what the RFM2Pi would normally output, ie a string of byte values to be reconstructed into real values.
I have added a test for an int between 0 and 31 for to first value in the payload, this will cause emonhub to discard the payload if the first value isn't valid as a node id, This should prevent emonhub failing and output a warning.
https://github.com/emonhub/emonhub/commit/366b3dbb3c2870ef1a2beefcff440e9e6685f98c
Paul