Emon Tx Shield Pi serial

Hello all

I’m drjim, an ED Consultant. 23 ago I first played with linux on various pentium PC’s, compiled software and then developed an interest in unix workstations, went through loads of Sun/SGI hardware and then had family etc etc. Now I’m playing with arduinos in my spare time!

Last year I made an Arduino/pi pool controller to run pumps/heat on my above ground intex pool. I tell you this not to show off I have a pool, but to suggest I have a clue.

I have a couple of solar panels I want to monitor, and obviously need to keep eye on consumption in general. So I now have a pi with a pulse counter on the gpis which is logging to emoncms on said pi. All great.

Just got a tx shield and soldered it all up. Voltage CT on it, removed 33 ohm resistor from board. 9v AC adaptor from the shop (seems to give 12v). Programmed using arduino IDE it sends values via serial. Approx calibrated the voltage by using multimeter to compare with the number in serial output and adjust calibration number (note 12v from adaptor). Usb serial input now shows…

Node: 6 448.79 247.60 - think I need to look at the voltage cal again, but it started out saying 292 when meter said 243 so this is an improvement!

But although I have this coming in to usb, and I configured a node 6 in the nodes section of emonhub, I can’t seem to get anything to happen from there. I can see my pulse counter on the pi gpio working and logs show this stuff…

2023-01-20 21:08:34,049 DEBUG    USB0       Node: 6 472.19 246.13
2023-01-20 21:08:35,059 DEBUG    Dummy-7    pulse : pulse received -  count: 34
2023-01-20 21:08:35,072 DEBUG    pulse      Data to Post: last_time: 1674248909  time_now: 1674248915
2023-01-20 21:08:35,072 DEBUG    pulse      65 NEW FRAME : 
2023-01-20 21:08:35,073 DEBUG    pulse      65 Timestamp : 1674248915.072000
2023-01-20 21:08:35,073 DEBUG    pulse      65 From Node : 3
2023-01-20 21:08:35,074 DEBUG    pulse      65    Values : [34]
2023-01-20 21:08:35,074 DEBUG    pulse      65 Sent to channel(start)' : ToEmonCMS
2023-01-20 21:08:35,075 DEBUG    pulse      65 Sent to channel(end)' : ToEmonCMS
2023-01-20 21:08:35,168 DEBUG    MQTT       Publishing: emon/3/Pulse 34
LOG LEVEL: DEBUG 

I’ve tried configuring devices inputs etc but nothing seems to come through from the usb. When I pulled the arduino to add the node 6 on the serial line it added a device 567 when I plugged back in with 4 inputs (4 CT inputs on Tx shield??), but couldn’t work out how to get anything to show.

Anyone got any advice as to what I am doing wrong??

Once I’ve done this I need to put a CT on a nodeMCU via MQTT for the solar panel input, so hopefully I’ll figure it soon!

Thanks

Jim

Welcome, Jim, to the OEM forum.

I’ll answer what I can, I need to leave the other points to those who know those areas better.

That’s OK - the 9 V output is on full load, the load the Shield provides is “minimal” - almost nothing. Depending on exactly which adapter you have (UK, EU, US) the output voltage is 11.6 V ±3%, 11.6 V ±5% or 12.0 V ±5% respectively at the nominal mains voltage.
The voltage calibration constant is the mains voltage that would give 1.0 V at the ADC input - this is after the resistive voltage divider on the Shield. The same goes for your c.t. - in this case it’s the current that gives 1.0 V at the ADC input, which in this case is the jack socket.

I’m by no means a RPi expert, but my crib notes say
“Serial USB connection to Raspberry Pi: The address you need to use in emonhub will be /dev/ttyACM0 (assuming this is the first/only arduino connected) instead of the usual /dev/ttyAMA0”
This might help: Multiple emonTX Serial connections - #2 by borpin

Thanks for welcome!

Tried those, I can make it be called something else in the hub log, but can’t quite work out how to get it into an input/feed/graph.

I suspect I managed to get my pulse counter working via luck, and it has run out now…

Not that I understand MQTT, but once emonHub is receiving data and logging it as “MQTT Publishing: …”, then it should automatically appear on the emonCMS Inputs page. There’s nothing you can do in the Inputs page to “fetch” the data. Which Interfacer are you using?

I think the pulses worked because they’re taking a slightly different route.

I appreciate you being awake and taking an interest! I’ve had a couple of beers (home-brew, another hobby) but still trying to work this out.

Here’s my emonhub config… Maybe I’ve got it all wrong.

#######################################################################
#######################      emonhub.conf     #########################
#######################################################################
### emonHub configuration file, for info see documentation:
### https://github.com/openenergymonitor/emonhub/blob/emon-pi/configuration.md
#######################################################################
#######################    emonHub  settings    #######################
#######################################################################

[hub]
    ### loglevel must be one of DEBUG, INFO, WARNING, ERROR, and CRITICAL
    loglevel = DEBUG
    autoconf = 1
### Uncomment this to also send to syslog
# use_syslog = yes
#######################################################################
#######################       Interfacers       #######################
#######################################################################

[interfacers]
    ### This interfacer manages the RFM12Pi/RFM69Pi/emonPi module
    [[EmonPi2]]
        Type = EmonHubOEMInterfacer
        [[[init_settings]]]
            com_port = /dev/ttyAMA0
            com_baud = 38400
        [[[runtimesettings]]]
            pubchannels = ToEmonCMS,
            subchannels = ToRFM12,



           

    [[usb0]]
        Type = EmonHubOEMInterfacer
        [[[init_settings]]]
            com_port = /dev/ttyUSB0
            com_baud = 9600
        [[[runtimesettings]]]
            pubchannels = ToEmonCMS,
            
           
    [[pulse]]
    Type = EmonHubPulseCounterInterfacer
    [[[init_settings]]]
        pulse_pin = 16
        # bouncetime = 2
        # rate_limit = 2
    [[[runtimesettings]]]
        pubchannels = ToEmonCMS,
        nodeoffset = 3


    [[SPI]]
        Type = EmonHubRFM69LPLInterfacer
        [[[init_settings]]]
            nodeid = 5
            networkID = 210
        [[[runtimesettings]]]
            pubchannels = ToEmonCMS,
    
    
    [[MQTT]]
        Type = EmonHubMqttInterfacer
        [[[init_settings]]]
            mqtt_host = 127.0.0.1
            mqtt_port = 1883
            mqtt_user = emonpi
            mqtt_passwd = emonpimqtt2016
        
        [[[runtimesettings]]]
            pubchannels = ToRFM12,
            subchannels = ToEmonCMS,
            
            # emonhub/rx/10/values format
            # Use with emoncms Nodes module
            node_format_enable = 0
            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/
            
            # Single JSON payload published  - use with Emoncms MQTT
            node_JSON_enable = 0
            node_JSON_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
            sendnames = 1    # Send full input names (compression will be automatically enabled)
            interval = 30    # Bulk send interval to Emoncms.org in seconds

#######################################################################
#######################          Nodes          #######################
#######################################################################

## See config user guide: https://github.com/openenergymonitor/emonhub
## If autoconf is enabled above, node configuration will automatically
## populate based on templates listed in available.conf

[nodes]



[[6]]
    nodename = emonTxShield
    firmware =emonTxShield
    hardware = emonTxShield
    [[[rx]]]
        names = power1, Vrms
        datacode = h
        scales = 1,0.01
        units =W,V

I think it might be because I have the word Node in the serial message, plus it has a startup message that might confuse matters. Off to adjust the arduino code!

I don’t think this data is in a format that the Interfacer is recognising.

Try a valid JSON String.

Also include a nodename in the runtimesettings for USB0

      [[[runtimesettings]]]
           nodename = your_nodename

Took the word out, decided to add a power factor on the end while editing, it’s now just sending numbers.

Still not recognising it.

This is the serial print bit of my arduino code. How do I change that to send json?

// Serial.print("Node: “);
Serial.print(nodeID);
Serial.print(” “);
Serial.print(ct1.realPower);
Serial.print(” “);
// Serial.print(ct2.realPower);
// Serial.print(” “);
// Serial.print(ct3.realPower);
// Serial.print(” “);
// Serial.print(ct4.realPower);
// Serial.print(” “);
Serial.print(ct1.Vrms);
Serial.print(” ");
Serial.print(ct1.powerFactor);
Serial.println();

If you look at the Inputs page of emonCMS, top right is a link to Input API Help. On there are examples of the acceptable formats.

In the last post of this topic I quoted above, there are also examples of the formats the various Interfacers accept.

I deleted all the feeds/inputs/devices I had configured for this , and when I restart emonhub I get a set of three inputs with a node id of emontx. No data. I’m going to remove the node id 6 from my serial config and see what happens.

What does emonhub.log tell you?

Working

All the serial config etc was done as per the examples, I just changed it to be an emonHubSerialInterfacer instead of OEMinterfacer. Clearly the OEM doesn’t want to speak serial at the moment. It should according to the docs but clearly didn’t understand the message coming through. Being new I won’t say it’s a bug, but it could be.

Next step is to configure feeds/graphs and get my nodeMCU running on the solar input.

Thanks for help so far guys!

Jim

1 Like