Serial input to emoncms fails

Hi

I have attached an arduino directly to the PI's serial port and want to show the data in Emoncms, but something is not working correctly.Using the current PI image 8.2.8

In minicom I get the following input on the PI:

10 39 20 3435
10 39 20 3435
10 39 20 3445

but in the log  tail -f /var/log/emonhub/emonhub.log it complains

2014-12-07 16:05:17,907 WARNING 62 RX data length: 3 is not valid for datacode h

I was reading that the input format was NodeID value1 value2 value3, but apperently there is something wrong.

What I'm I missing?

Thanks

Kim

pb66's picture

Re: Serial input to emoncms fails

The core of the problem is that emonHub is expecting an even number of values (excluding node id) because it is expecting only integers in "byte pairs".

I can't tell if you have set any datacode(s) settings in emonhub.conf, but I would hazard a guess that you may still be using the [[RFM2Pi]] intefacer which defaults to expecting ints because of the established standard.

If that is the case you can resolve it by either changing the interfacer "Type" to EmonHubSerialInterfacer (and remove the "rfm settings"), create a new serial interfacer instead or by simply specifying "datacode = 0" in either the [[RFM2Pi]][[[runtimesettings]]] or the [nodes][[10]]. The datatype of a "Serial" interfacer is 0 by default so will not need to be specified if you change Types.

See Serial link RPI<->EMonTX using Emonhub (emonSD-13-08-14.img) & Emon v3 Direct Serial for more info.

Paul

haden's picture

Re: Serial input to emoncms fails

I haven't changed anything in the config file other than change to debug.

the current settings are:    

datacode = h
datacodes = l, h, h, h,
So what is h and stand for?

I can see in the other links you provided that the config file is different. so based on this settings what should I put in?

Kim

pb66's picture

Re: Serial input to emoncms fails

Hi Kim

The "out of the box" emonHub settings are intended for the RFM2Pi rather than an alternative serial device, the "RFM2Pi" interfacer can be used by changing some settings etc or the "proper" way to do it would be to add the required settings to create a "Serial" interfacer that doesn't have all the RF settings. adding these details

    [[SerialDirect]]
            Type = EmonHubSerialInterfacer
            [[[init_settings]]]
                    com_port = /dev/ttyAMA0
                    com_baud = 9600
            [[[runtimesettings]]]

To the [interfacers] section in emonhub.conf and adding a "#" to the "Type" line of the [[RFM2Pi]] interfacer like this " # Type = EmonHubJeeInterfacer " to disable it, will get you up and running.

You shouldn't need to set any datacodes as the serial interfacer passes data as is, no decoding etc.

For a explanation of the datacode(s) see the emonHub development - increase in scope of values over rfm network  thread, the [nodes][[99]] settings in emonhub.conf are just an example (hence the out of range node id 99) "datacode = h" tells emonhub to expect an unspecified number of signed ints from node 99, so as long as the number of (data) bytes is even emonhub will decode the incoming payload as a string of ints, where as "datacodes = l, h, h, h" defines a fixed payload structure of 1long and 3ints so emonhub will only process the payload if it is 10bytes (4 + 3*2). Normally only datacode or datacodes would be specified but datacode will be ignored if datacodes is present.

Until recently all OEM RF sketches only used ints so the "RFM2Pi" interfacer uses a default datacode of "h" for compatibility.

Paul

Comment viewing options

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