EmonTX to Rpi - Direct Serial Connection

Oh, and just for completeness

you could as a 3rd option (should actually be the very first option) just define nothing! Do not have datacodes or datacode defined at all, the default mode for the serial-direct interfacer is “datacode = 0” so by simply commenting out the datacode(s) line would work just fine! That is how emonhub was intended to work, with minimal settings for the user to need to set and plenty of option should they want/need something else, but the project maintainers have opted for foisting all the (duplicated default) settings on the user in an explicit conf file, hence the confusion when looking at many different forum threads and guides as all the settings are there not just the ones pertinent to the application or feature being discussed.

1 Like

I would expect nothing less Brian!

That’ll fix it, yet another option to simplify things :scream: :grinning:

It’s called ‘development’. Without it, we’d still be living in mud huts.

I have an EE background and plenty of experience with all kinds of technology and that only makes me yearn for a simple mud hut even more!!! :rofl:

1 Like

That I believe is your current issue. Looking at the logs I see the data coming in nicely but nothing heading out. Can you show us your emonhub.conf for the mqtt and/or http sections please.

Can you also confirm the pub and sub channels in the serial interfacer settings? These are the internal emonhub channels so your output must be listening to the same channel that your input is publishing to.

You are welcome to that.

This did appeal to me when comparing the two methods, I do admit… so if I get rid of the datacodes and scales lines in the node definition - what happens then? It’ll still need the units definitions I assume (unless they’re built into the input/feed definition)?

I assumed (quite possibly wrongly, without documentation) that the subchannel was simply a secondary output that wasn’t strictly necessary?

Here’s the Interfacers section of the .conf file:

#######################################################################
#######################       Interfacers       #######################
#######################################################################

[interfacers]
### This interfacer manages the EmonTx3 ESP format serial
[[SerialTx3e]]
##     Type = EmonHubTx3eInterfacer
##      [[[init_settings]]]
##           # Un-comment line below if using RS485 adapter
##           #com_port = /dev/ttyRS485-0
##           # default com port if using USB to UART adapter
##           com_port= /dev/ttyAMA0
##           com_baud = 9600
##      [[[runtimesettings]]]
##           nodeoffset = 11
##           # nodeoffet can be used for multiple devices. it will change the nodeID as seen by emonCMS Inputs.
##           pubchannels = ToEmonCMS,

### Plain Text Wired SerialOut Interfacer
[[SerialDirect]]
     Type = EmonHubSerialInterfacer
      [[[init_settings]]]
           com_port = /dev/ttyAMA0   # or /dev/ttyUSB0 or/dev/ttyACM0 etc
           com_baud = 9600              # to match the baud of the connected device
      [[[runtimesettings]]]
           pubchannels = ToEmonCMS,
           nodeoffset = 11

### This interfacer manages the RFM12Pi/RFM69Pi/emonPi module
##[[RFM2Pi]]
##    Type = EmonHubJeeInterfacer
##    [[[init_settings]]]
##        com_port = /dev/ttyAMA0
##        com_baud = 9600 # 38400                        # 9600 for old RFM12Pi
##    [[[runtimesettings]]]
##        pubchannels = ToEmonCMS,
##            nodeoffset = 11
##        subchannels = ToRFM12,

##        group = 210
##        frequency = 433
##        baseid = 5                              # emonPi / emonBase nodeID
##        calibration = 230V                      # (UK/EU: 230V, US: 110V)
##        quiet = true                            # Disable quite mode (default enabled) to enable RF packet debugging, show packets which fail crc
        # interval =  300                         # Interval to transmit time to emonGLCD (seconds)
        

[[MQTT]]

    Type = EmonHubMqttInterfacer
    [[[init_settings]]]
        mqtt_host = 127.0.0.1
        mqtt_port = 1883
        mqtt_user = emonpi
        mqtt_passwd = emonpimqtt2016

    [[[runtimesettings]]]
        pubchannels = ToEmonCMS # RFM12,
        #subchannels = ToEmonCMS,

        # emonhub/rx/10/values format
        # Use with emoncms Nodes module
        node_format_enable = 1
        node_format_basetopic = emonhub/

        # emon/emontx/power1 format - use with Emoncms MQTT input
        # http://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md
        nodevar_format_enable = 1
        nodevar_format_basetopic = emon/

#[[emoncmsorg]]
#    Type = EmonHubEmoncmsHTTPInterfacer
#    [[[init_settings]]]
#    [[[runtimesettings]]]
#        pubchannels = ToRFM12,
#        subchannels = ToEmonCMS,
#        url = https://emoncms.org
#        apikey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#        senddata = 1                    # Enable sending data to Emoncms.org
#        sendstatus = 1                  # Enable sending WAN IP to Emoncms.org MyIP > https://emoncms.org/myip/list
#        sendinterval= 30                # Bulk send interval to Emoncms.org in seconds

uncomment that last line above

I think the problem is that the string you generate needs to start with MSG:value as the TX3 interfacer looks for that - I’ll hold my hand up and say I suggested the change (to stop odd inputs appearing on a reset of the TX as it tried to parse Log messages) but did not update the documentation and no one noticed that this might impact custom FW builds. Docs PR created.

Units are never sent on from emonhub. You do that when you create the feed in emoncms. You could do that with a full JSON output :laughing:.

Assumptions are the mother of all &^%ups.

Emonhub started as a means of decoding RF messages (AIUI) - everything else has been bolted on.

In which section, MQTT?

Just spotted a probably crucial missing comma in the MQTT section:

[[[runtimesettings]]]
        pubchannels = ToEmonCMS # RFM12,
                              ^ here!
1 Like

also nodeoffset isn’t needed here as the nodeid is the first value in the payload, unlike the “emonesp output” that doesn’t identify itself.

The channels are explained in the docs :wink:

Not a lot else to go on, without docs! :wink:

Can you explain in a nutshell what pub and sub channels are all about?

I take it back! I missed that - my apologies!

1 Like

Indeed it is crutial and also easy to omit and even easier to not spot!

That is poor coding, the setting MUST be a list even if it’s only a single item, sorry i didn’t spot that (and I certainly didn’t/wouldn’t code it).

Just created a PR for the docs to try and emphasise that.

I had noted the comma at the end of other places with only a single item and there was one there in the original file, but I pushed the "RFM12, " sideways out of the way with a comment character and added in the “ToEmonCMS” but forgot to add the comma back in…

You can have multiple internal channels eg you have a emontx reporting to your local emoncms, that’s normal and you are using channel “ToEmonCMS”. You could also have another serially connected emonTx (for example) that you only want to report to emoncms.org (not a local emoncms) you could have channel “ToEmonCMSORG” or “ToEmonCMS2” etcany interfacer can publish to any number of internal channels and any interfacer can subscribe to any number of channels so you could arrive a some very complex routing, should you need it. It was included to pursue more control aspects than data collection as generally you want all your data to go to one place.

AMAZING!!! Wish I’d signed up for the forums sooner instead of suffering through thousands of browser tabs and confusing dead ends on the forums and docs…

We have inputs finally! Many thanks everyone!!!

2 Likes