emonTx Arduino Shield v2.4 usable to send data to a pi or homeassisant?

Hi Robert

Yeah I have the Rx to the TX and vice versa.

Yeah I also read somewhere that I probably dont need the Rx from the shield, but plugged it in, but will unplug it now, hearing what you have to say.

Is there anything from the snapshots that you can see is wrong?

I still need to plug it all in to the power and put the CT’s on. Will see if it starts gathering data points.

Not sure I have it right, as there are 4 CT’s I can use but only have 2 fields in the feed. As in the pics above.

Swap yellow and green - in Emon Nomenclature, connect TX to TX & RX to RX (yes I know).

You need to configure emonhub to receive the data on the serial input.

Check you are getting data with Miniterm.

Not sure I have it right, as there are 4 CT’s I can use but only have 2 fields in the feed. As in the pics above.

Inputs are created automatically as emoncms detects data sources.

As the Inputs say n/a - Null - it is not currently detecting data.

Once you have the data, you create feeds through creating input processes.

No data in the input means you have not configured emonhub to take the data off the Uno and into the Pi (as I said above).

What I do not know for sure, is what format that data is in - @Robert.Wall may be able to help with that, but connecting to the serial port on the Pi with miniterm will show you what is being received.

I don’t own an Arduino nor a Shield - all I can do is look at the source code in the sketch. That should tell you.
I’ve never seen a description of the format for the various interfacers written down, so I’ve never been sure what is and isn’t acceptable to each.

Hi Guys

I am not worried about the data format, all I need to achieve is getting working feeds into emonPi. The addon for HA does all the heavy lifting from there.

Its very confusing, I have everything plugged in:

Powered Pi
Pi running emonPi
Pi powering UNO 5v and tx to tx connected.
AC Power to Txshield.
CT clamped over single Live wire.

The same screenshots as above. Still all saying n/a…

Here is my .conf config:

### This interfacer manages the EmonTx3 ESP format serial
[[SerialTx3e]]
     Type = EmonHubTx3eInterfacer
      [[[init_settings]]]
           # Un-comment line below if using RS485 adapter
           com_port = /dev/serial0
         #com_port = /dev/ttyRS485-0
         # default com port if using USB to UART adapter
         #com_port= /dev/ttyUSB0
           com_baud = 115200
      [[[runtimesettings]]]
           pubchannels = ToEmonCMS,
### This interfacer manages the RFM12Pi/RFM69Pi/emonPi module
[[RFM2Pi]]
    Type = EmonHubJeeInterfacer
    [[[init_settings]]]
        com_port = /dev/ttyAMA0
        com_baud = 38400                        # 9600 for old RFM12Pi
    [[[runtimesettings]]]
        pubchannels = ToEmonCMS,
        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 = ToRFM12,
        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/

That’s precisely the area where the data format is important. If the format is wrong, the interfacer in emonHub rejects it.

Look at the source code for the sketch you’re running. This is what needs to be sent:

      // ---------------------------------------------------------------------
      // Key:Value format, used by EmonESP & emonhub EmonHubTx3eInterfacer
      // ---------------------------------------------------------------------
      Serial.print(F("MSG:")); Serial.print(emontx.Msg);
        
      if (CT1) { Serial.print(F(",P1:")); Serial.print(emontx.P1); }
      if (CT2) { Serial.print(F(",P2:")); Serial.print(emontx.P2); }

[etc]

Now, I don’t know which sketch you’re using, but the one I looked at on Github hadn’t got that in it. This might well explain the absence of your data.

If yours hasn’t got a block of code that starts off like that, you need to get the default emonTx sketch (not the Shield sketch) and copy that section into yours, bearing in mind you might have different names for some of the variables.

Ah I see what you’re saying.

I don’t have the original sketch. Not sure what is on the UNO currently. I will have to create a new one and upload it and see what happens.
I will look at the wiki and see where the sketches are.

The Shield does not come with a sketch, because there is no processor, so you must have had one at some point.

Post No.7 has a link where you might have downloaded the sketch from. If you did, it’s on your machine somewhere - unless you deleted it. (Don’t do that, you can’t ever get it back from the Arduino.)

Thanks Robert.

Perhaps I leaving out some history where. I bought and set this up years and years ago. I has been sitting in a cupboard, only got it out when I started this thread. So can’t remember what is on the UNO. Will have to config a new sketch and start from scratch.

Ok got the sketch and added you recommendation, but cant get it to compile:

Sketch:

/*
  EmonTx CT123 Voltage Serial Only example
  
  Part of the openenergymonitor.org project
  Licence: GNU GPL V3
  
  Author: Trystan Lea
*/

#include "EmonLib.h"

// Create  instances for each CT channel
EnergyMonitor ct1,ct2,ct3, ct4;

// On-board emonTx LED
const int LEDpin = 9;                                                    

void setup() 
{
  Serial.begin(9600);
  // while (!Serial) {}
  // wait for serial port to connect. Needed for Leonardo only
  
  Serial.println("emonTX Shield CT123 Voltage Serial Only example"); 
  Serial.println("OpenEnergyMonitor.org");
  
  // Calibration factor = CT ratio / burden resistance = (100A / 0.05A) / 33 Ohms = 60.606
  ct1.current(1, 60.606);
  ct2.current(2, 60.606);                                     
  ct3.current(3, 60.606);
  ct4.current(4, 60.606); 
  
  // (ADC input, calibration, phase_shift)
  ct1.voltage(0, 300.6, 1.7);                                
  ct2.voltage(0, 300.6, 1.7);                                
  ct3.voltage(0, 300.6, 1.7);
  ct4.voltage(0, 300.6, 1.7);
  
  // Setup indicator LED
  pinMode(LEDpin, OUTPUT);                                              
  digitalWrite(LEDpin, HIGH);                                                                                  
}

void loop() 
{ 
  // Calculate all. No.of crossings, time-out 
  ct1.calcVI(20,2000);                                                  
  ct2.calcVI(20,2000);
  ct3.calcVI(20,2000);
  ct4.calcVI(20,2000);
    
  // Print power 
  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.println();

   //Serial.print(F("MSG:")); Serial.print(EnergyMonitor.Msg);
        
      if (ct1) { Serial.print(F(",P1:")); Serial.print(emontx.P1); }
      if (ct2) { Serial.print(F(",P2:")); Serial.print(emontx.P2); }
      if (ct3) { Serial.print(F(",P3:")); Serial.print(emontx.P2); }
      if (ct4) { Serial.print(F(",P4:")); Serial.print(emontx.P2); }
    
  // Available properties: ct1.realPower, ct1.apparentPower, ct1.powerFactor, ct1.Irms and ct1.Vrms

  delay(5000);
}

Error:

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

C:\Users\Darryl\Documents\Arduino\emonTx\emonTx.ino: In function 'void loop()':

emonTx:64:42: error: 'emontx' was not declared in this scope

    Serial.print(F("MSG:")); Serial.print(emontx.Msg);

                                          ^~~~~~

emonTx:66:14: error: could not convert 'ct1' from 'EnergyMonitor' to 'bool'

       if (ct1) { Serial.print(F(",P1:")); Serial.print(emontx.P1); }

              ^

emonTx:67:14: error: could not convert 'ct2' from 'EnergyMonitor' to 'bool'

       if (ct2) { Serial.print(F(",P2:")); Serial.print(emontx.P2); }

              ^

emonTx:68:14: error: could not convert 'ct3' from 'EnergyMonitor' to 'bool'

       if (ct3) { Serial.print(F(",P3:")); Serial.print(emontx.P2); }

              ^

emonTx:69:14: error: could not convert 'ct4' from 'EnergyMonitor' to 'bool'

       if (ct4) { Serial.print(F(",P4:")); Serial.print(emontx.P2); }

              ^

exit status 1

'emontx' was not declared in this scope

Nope, I have tried multiple ino sketches. Can get serial output to the serial monitor with correct values. But nothing happening in emonCMS. Does pick anything up in the emonub log, or populate any inputs.

In the emonhub.conf it shows the TXshield, but it doesn’t show it on the inputs page.

Not sure what to try, any suggestions?

I’m afraid you haven’t changed the bit you added to keep it consistent with the rest of the sketch. You need to replace the whole of loop( ) with this:

void loop() 
{ 
  // Calculate all. No.of crossings, time-out 
  ct1.calcVI(20,2000);                                                  
  ct2.calcVI(20,2000);
  ct3.calcVI(20,2000);
  ct4.calcVI(20,2000);
    
/*
  // Print power 
  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.println();

*/
   //Serial.print(F("MSG:")); Serial.print(EnergyMonitor.Msg);
        
      Serial.print(F("P1:")); Serial.print(ct1.realPower); 
      Serial.print(F(",P2:")); Serial.print(ct2.realPower); 
      Serial.print(F(",P3:")); Serial.print(ct3.realPower);
      Serial.print(F(",P4:")); Serial.print(ct4.realPower); 
      //Serial.print(F(",Vrms:")); Serial.print(emontx.ct1.Vrms*100.0); 
      Serial.println();
  // Available properties: ct1.realPower, ct1.apparentPower, ct1.powerFactor, ct1.Irms and ct1.Vrms

  delay(5000);
}

If you want the voltage, uncomment that line.

You won’t of course get anything through emonHub until the data format is correct, and as it hadn’t compiled, you weren’t sending it the correct format.

Then, in emonhub.conf, you will need to change whichever node it’s appearing as to this (assuming it’s Node 6):

[[6]]
    nodename = emontxshield
    [[[rx]]]
       names = power1, power2, power3, power4
       datacodes = h,h,h,h
       scales = 1,1,1,1
       units = W,W,W,W

If you do send the voltage, you’ll need this instead:

[[6]]
    nodename = emontxshield
    [[[rx]]]
       names = power1, power2, power3, power4,Vrms
       datacodes = h,h,h,h,h
       scales = 1,1,1,1,0.01
       units = W,W,W,W,V

And with a bit of luck (because I don’t have a Shield + Uno to test it on), that should work.

hi --if you get total frustrated you can always try this method – it not wired directly it connect the oemtx via wireles connection to what ever controller you want — Howto --emonTx - Shield ESPEASY and WEMOS R3 UNO
you need a wemos R3 uno/esp and and a oemtxshield

espeasy has a controller for oem to send to it via wireless connection or you can follow say this to a certain degree and send it directly to home assistant

The photo in post no.18 clearly shows there is NO radio fitted. Hence any method that required the radio will not apply.

the radio on the wemos R3 – one would assume since they have home automation software running it connected to router and has access to wireless network

Thanks Robert

Did what you said, can see the data in the serial monitor:
image

But still nothing coming through to emonCMS:

Doestn even show the emonTx Input at all.

Here is my emonhub.conf:

[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/serial0
         #com_port = /dev/ttyRS485-0
         # default com port if using USB to UART adapter
         #com_port= /dev/ttyUSB0
      #     com_baud = 9600
     # [[[runtimesettings]]]
      #     pubchannels = ToEmonCMS,

[[SerialDirect]]
     Type = EmonHubSerialInterfacer
      [[[init_settings]]]
           com_port = /dev/ttyAMA0      # or /dev/ttyAMA0 or/dev/ttyACM0 etc
           com_baud = 9600              # to match the baud of the connected device
      [[[runtimesettings]]]
           pubchannels = ToEmonCMS,

        nodeoffset = 0
        nodename = Serial_Pi

        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 = ToRFM12,
        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

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

[nodes]

## See config user guide: https://github.com/openenergymonitor/emonhub/blob/emon-pi/conf/emonhub.conf

[[5]]
    nodename = emonpi
    [[[rx]]]
        names = power1,power2,power1pluspower2,vrms,t1,t2,t3,t4,t5,t6,pulsecount
        datacodes = h, h, h, h, h, h, h, h, h, h, L
        scales = 1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
        units = W,W,W,V,C,C,C,C,C,C,p

[[6]]
    nodename = emontxshield
    [[[rx]]]
       names = power1, power2, power3, power4,Vrms
       datacodes = h,h,h,h,h
       scales = 1,1,1,1,0.01
       units = W,W,W,W,V

[[7]]
   nodename = emontx4
   [[[rx]]]
      names = power1, power2, power3, power4, vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
      datacodes = h,h,h,h,h,h,h,h,h,h,h,L
      scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1
      units = W,W,W,W,V,C,C,C,C,C,C,p

grrr, about to give up. Data is going out, why can I not see it in emonCMS. So frustrating.

First, for future reference, when posting code or bash output, please put in 3 ‘backticks’ (found at the top left of the keyboard normally) on a line on their own, then the code, then 3 more backticks on a line following the code.

    ```
    code
    ```

If it is something like php you can add a language identifier that after the first 3 backticks so ```php

If you have thge serial data, you are getting close.

What we need now is the emonhub.log output from the start. Do a sudo systemctl restart emonhub.service and post the first 30 seconds of logs.

[edit]
How is this wired? I posted earlier…

On the Pi, open a miniterm session and see if you get serial data (edit for the right port and speed)

miniterm --rtscts /dev/ttyAMA0 115200