Direct connection emonTx V3 3-phase to RaspberryPi

Is it possible to directly connect my emonTX (running latest 3 phase firmware v0.11 which has pulse counting & is ESP module compliant) to my emonPi using jumper leads?

I envision using an AC AC psu for the emonTx and a separate psu for the RPi.

If so how?

What functionality do you need from your emonPi?

Inside the emonPi is an emonTx (more or less) - your problem is it has only 2 current inputs. I don’t think you can have that and a second serial connection, but if you don’t need that and you were to remove that board and move the connections to your emonTx, I think that would work.
It would probably be better to use the same 5 V d.c. supply for both emonTx and emonPi, and use the a.c. adapter only as a voltage monitor.

Thx for the quick response.

My apologies - I’m confused & used the incorrect terminology …

I mean an emonTx (running 3 phase firmware) directly connected to an RPi running emonBase/emonhub/emoncms (the latest emonSD image).

Do you mean connecting the two by their serial ports to transfer the data, rather than using the radio?
Or do you mean sharing the power supply and/or the a.c. voltage monitor, whilst leaving the data to be transferred by radio?

I mean - connecting the two by their serial ports to transfer data thus not using radio.

Re psu’s - agree … use the ac adapter just to monitor voltage. Presumably the 5V dc supply should be connected to the RPi and the emonTx be fed via the appropriate UART pin.

The easy way would be with a USB splitter, but the UART pin, or the connector block would be fine. Check the circuit diagram (Resources) if you are in any doubt - the RF module will die if you feed 5 V into the 3.3 V rail.

That’s what I thought you meant. Substitute the external emonTx (with 4 currents + 1 voltage) for the cut-down internal one that does 2 currents and voltage only. Unless of course you need the current inputs of the emonPi, in which case I think it’s not possible to have two serial inputs to your Pi (but I’m open to correction).

I don’t understand yr ref to two serial inputs.

The emonTx (running latest 3 ph firmware) has UART pins Ground, 5V & Tx. I envision connecting these to the appropriate GPIO pins on a RPi running the latest emonSD image.

What else needs to done to get the data from the emonTx into the RPI’s emonhub/emoncms & logged as time series files in the normal way (ie: inputs logged to feeds).

The RPi would NOT be fitted with a RFM69Pi add-on board.

You wrote that you had an emonPi. What do you really have, a Raspberry Pi or an emonPi?

I have a Raspberry Pi but without the RFM69Pi add-on board fitted

I’ve changed the thread title to reflect the correct name.

See Connect an EmonTx v3 to RaspberryPI via serial | Archived Forum
The picture is missing, I shall flag that and hopefully it will reappear.
A copy of the picture is here: https://wiki.openenergymonitor.org/images/thumb/Emontx_to_pi_serial.JPG/764px-Emontx_to_pi_serial.JPG

Yes, use the emonhub directserial-serialtx3e interfacer. Just add the emonhub config in the [interfacers] section:

[[SerialTx3e]]
     Type = EmonHubTx3eInterfacer
      [[[init_settings]]]
           com_port= /dev/ttyUSB0
           com_baud = 115200
      [[[runtimesettings]]]
           pubchannels = ToEmonCMS,

This should decode the serial output from the latest emonTx-three phase (V0.11.0)

Thanks guys.

I’m NOT using a USB to UART adapter.

I connected 3 jumper leads from an emonTx (running the 3 Ph firmware v0.11) to an RPi – connected as the pic in Robert’s post above – using Rx as the sending pin on the emonTx (plus 5V & GND connected).

I DO NOT have an RFM69Pi add-on board fitted to the RPi.

Via the emoncms page – per Glyn’s suggestion, I added the directserial interfacer and restarted.
But there were no Inputs to emoncms shown on the emoncms page.

/var/log/emonhub/emonhub.log gave the following …
2017-04-15 11:05:59,817 INFO MainThread Creating EmonHubTx3eInterfacer ‘SerialTx3e’
2017-04-15 11:05:59,823 ERROR MainThread [Errno 2] could not open port /dev/ttyUSB0: [Errno 2] No such file or directory: ‘/dev/ttyUSB0’
2017-04-15 11:05:59,824 ERROR MainThread Unable to create ‘SerialTx3e’ interfacer: global name ‘EmonHubInterfacerInitError’ is not defined

Then I started experimenting …
By changing the Serial Interfacer to dev/ttyAMA0 …

The log then showed that a serial port was now open.

There were some Inputs - Nodes 514, 516, 518, 519, 520, 522, 523, 531 & 693 each including 5 keys plus rssi but all with no values (NaN).

And the RFM2Pi has a ‘thread is dead’ problem.

Here’s the log …
2017-04-15 12:14:40,480 INFO MainThread EmonHub emonHub ‘emon-pi’ variant v1.2
2017-04-15 12:14:40,481 INFO MainThread Opening hub…
2017-04-15 12:14:40,483 INFO MainThread Logging level set to DEBUG
2017-04-15 12:14:40,484 INFO MainThread Creating EmonHubTx3eInterfacer ‘SerialTx3e’
2017-04-15 12:14:40,489 DEBUG MainThread Opening serial port: /dev/ttyAMA0 @ 115200 bits/s
2017-04-15 12:14:40,491 DEBUG MainThread Setting SerialTx3e pubchannels: [‘ToEmonCMS’]
2017-04-15 12:14:40,493 DEBUG MainThread Interfacer: Subscribed to channel’ : ch2
2017-04-15 12:14:40,495 INFO MainThread Creating EmonHubJeeInterfacer ‘RFM2Pi’
2017-04-15 12:14:40,499 DEBUG MainThread Opening serial port: /dev/ttyAMA0 @ 38400 bits/s
2017-04-15 12:14:42,503 WARNING MainThread Device communication error - check settings
2017-04-15 12:14:42,504 INFO MainThread Setting RFM2Pi frequency: 433 (4b)
2017-04-15 12:14:43,506 INFO MainThread Setting RFM2Pi group: 210 (210g)
2017-04-15 12:14:44,509 INFO MainThread Setting RFM2Pi quiet: 0 (0q)
2017-04-15 12:14:45,511 INFO MainThread Setting RFM2Pi baseid: 5 (5i)
2017-04-15 12:14:46,514 INFO MainThread Setting RFM2Pi calibration: 230V (1p)
2017-04-15 12:14:47,516 DEBUG MainThread Setting RFM2Pi subchannels: [‘ToRFM12’]
2017-04-15 12:14:47,518 DEBUG MainThread Interfacer: Subscribed to channel’ : ToRFM12
2017-04-15 12:14:47,519 DEBUG MainThread Setting RFM2Pi pubchannels: [‘ToEmonCMS’]
2017-04-15 12:14:47,520 DEBUG MainThread Interfacer: Subscribed to channel’ : ToRFM12
2017-04-15 12:14:47,521 INFO MainThread Creating EmonHubMqttInterfacer ‘MQTT’
2017-04-15 12:14:47,523 INFO MainThread MQTT Init mqtt_host=127.0.0.1 mqtt_port=1883 mqtt_user=emonpi
2017-04-15 12:14:47,526 DEBUG MainThread MQTT Subscribed to channel’ : ToEmonCMS
2017-04-15 12:14:47,529 INFO MainThread Creating EmonHubEmoncmsHTTPInterfacer ‘emoncmsorg’
2017-04-15 12:14:47,531 DEBUG MainThread emoncmsorg Subscribed to channel’ : ToEmonCMS
2017-04-15 12:14:47,633 INFO MQTT Connecting to MQTT Server
2017-04-15 12:14:47,636 INFO MQTT Could not connect…
2017-04-15 12:14:48,740 INFO MQTT Connecting to MQTT Server
2017-04-15 12:14:48,742 INFO MQTT Could not connect…
2017-04-15 12:14:49,845 INFO MQTT Connecting to MQTT Server
2017-04-15 12:14:49,847 INFO MQTT Could not connect…
2017-04-15 12:14:50,950 INFO MQTT Connecting to MQTT Server
2017-04-15 12:14:50,952 INFO MQTT Could not connect…
2017-04-15 12:14:51,103 WARNING MainThread RFM2Pi thread is dead
2017-04-15 12:14:51,304 WARNING MainThread RFM2Pi thread is dead
2017-04-15 12:14:51,507 WARNING MainThread RFM2Pi thread is dead
2017-04-15 12:14:51,738 WARNING MainThread RFM2Pi thread is dead
2017-04-15 12:14:51,940 WARNING MainThread RFM2Pi thread is dead
2017-04-15 12:14:52,055 INFO MQTT Connecting to MQTT Server
2017-04-15 12:14:52,141 WARNING MainThread RFM2Pi thread is dead
2017-04-15 12:14:52,159 INFO MQTT Connecting to MQTT Server
2017-04-15 12:14:52,263 INFO MQTT Connecting to MQTT Server
2017-04-15 12:14:52,268 INFO MQTT connection status: Connection successful
2017-04-15 12:14:52,270 DEBUG MQTT CONACK => Return code: 0
2017-04-15 12:14:52,343 WARNING MainThread RFM2Pi thread is dead
2017-04-15 12:14:52,372 INFO MQTT on_subscribe
2017-04-15 12:14:52,545 WARNING MainThread RFM2Pi thread is dead
2017-04-15 12:14:52,821 WARNING MainThread RFM2Pi thread is dead
2017-04-15 12:14:53,035 WARNING MainThread RFM2Pi thread is dead

… and continuing several times per second thereafter

Do you guys have any further suggestions?

I’m clutching at straws …

Should I just delete the RFM2Pi interfacer from the emonhub config?

I’ve tried changing the firmware file emonTxV3_4_3Phase_Voltage.ino - changing line 165 from RFM69CW to SERIALOUT but it made no difference.

I noticed that lines 117 to 123 have a slightly different content for Node 11 to that in the emonhub config file – should I use this instead?

Any other suggestions?
Thanks

I don’t know my way around emonHub, so I can’t help with the dead thread. I suspect that you are correct in that deleting the interfacer will remove the problem, but I’m not certain.

You do need to define SERIALOUT (that will turn off human-readable output that confuses emonhub)

However, the Node description in emonhub.conf must match the data coming from your emonTx. As the sketch stands, it sends only data for the active temperature sensors (if there are any), and in their wisdom, whoever specified the config file decided that 6 would always be used.
The best way to correct this is to adjust Node 11 in emonhub.conf to match the number of active temperature sensors that you have. The easy way is to change line 487 in the sketch and the block it controls to read:

if (numSensors)
{  

        {```
     ```Serial.print(' ');```
     ```Serial.print(emontx.temp[j]);```
```        } ```
<strike>``   }``&nbsp;&nbsp;</strike>

[This is in the block ```    #if defined SERIALOUT && !defined EMONESP``` ]

[Edit - I've spotted another Gotcha - the pulse count isn't handled properly for the case where the serial output goes to a non-human!  <strike>I'm working on it.</strike>
Now V.11:
<a class="attachment" href="/uploads/default/original/2X/b/b0c3c01db071e39cd82ff6df4860d5224884336f.zip">emonTx_3Phase_Voltage.zip</a> (14.0 KB)  ]

Robert many thx for yr efforts …
I already have and am using V0.11

emonTxV3_4_3Phase_Voltage.zip (10.8 KB)

Would you pls make yr changes to this and create V0.13

Thx again

Oops - I mean V0.12

I don’t understand that - the current version before today was V.10

I got it from here …

https://github.com/openenergymonitor/emontx-3phase

I, as the originator of the sketch, worked from my master copy. That has obviously been edited by someone else.

Robert - here’s where I’m currently at …

Using the .ino file you sent but with SERIALOUT substituted in line 165

Just one CT connected plus AC adapter plus pulse sensor

The RFM2Pi interfacer deleted from the emonhub config

This interfacer used instead …

[[SerialTx3e]]
Type = EmonHubTx3eInterfacer
[[[init_settings]]]
com_port= /dev/ttyAMA0
com_baud = 115200
[[[runtimesettings]]]
pubchannels = ToEmonCMS,

With Node 11 following yr suggestion (except datacodes rather than datacode) …

[[11]]
nodename = 3phase
[[[rx]]]
names = powerL1, powerL2, powerL3, power4, Vrms, pulse
datacodes = h,h,h,h,h,L
scales = 1,1,1,1,0.01,1
units =W,W,W,W,V,p

The result in the log is …

2017-04-16 22:02:15,837 INFO MainThread EmonHub emonHub ‘emon-pi’ variant v1.2
2017-04-16 22:02:15,838 INFO MainThread Opening hub…
2017-04-16 22:02:15,838 INFO MainThread Logging level set to DEBUG
2017-04-16 22:02:15,839 INFO MainThread Creating EmonHubTx3eInterfacer ‘SerialTx3e’
2017-04-16 22:02:15,842 DEBUG MainThread Opening serial port: /dev/ttyAMA0 @ 115200 bits/s
2017-04-16 22:02:15,843 DEBUG MainThread Setting SerialTx3e pubchannels: [‘ToEmonCMS’]
2017-04-16 22:02:15,844 DEBUG MainThread Interfacer: Subscribed to channel’ : ch2
2017-04-16 22:02:15,846 INFO MainThread Creating EmonHubMqttInterfacer ‘MQTT’
2017-04-16 22:02:15,847 INFO MainThread MQTT Init mqtt_host=127.0.0.1 mqtt_port=1883 mqtt_user=emonpi
2017-04-16 22:02:15,850 DEBUG MainThread MQTT Subscribed to channel’ : ToEmonCMS
2017-04-16 22:02:15,851 INFO MainThread Creating EmonHubEmoncmsHTTPInterfacer ‘emoncmsorg’
2017-04-16 22:02:15,853 DEBUG MainThread emoncmsorg Subscribed to channel’ : ToEmonCMS
2017-04-16 22:02:15,952 INFO MQTT Connecting to MQTT Server
2017-04-16 22:02:15,955 INFO MQTT connection status: Connection successful
2017-04-16 22:02:15,957 DEBUG MQTT CONACK => Return code: 0
2017-04-16 22:02:16,058 INFO MQTT on_subscribe
2017-04-16 22:02:22,497 WARNING MainThread SerialTx3e thread is dead
2017-04-16 22:02:22,699 WARNING MainThread SerialTx3e thread is dead

However, minicom reports …

Welcome to minicom 2.7

OPTIONS: I18n
Compiled on Jan 12 2014, 05:42:53.
Port /dev/ttyAMA0, 17:41:08

Press CTRL-A Z for help on special keys

11 589 0 0 0 25744
11 619 0 0 0 25800
11 582 0 0 0 25893

Current & voltage sensors are reporting but the pulse sensor is not 

Now if I shutdown and just substitute a temp sensor for the pulse sensor and change Node 11 accordingly to …

[[11]]
nodename = 3phase
[[[rx]]]
names = powerL1, powerL2, powerL3, power4, Vrms, temp1
datacodes = h,h,h,h,h,h
scales = 1,1,1,1,0.01,0.1
units =W,W,W,W,V,C

SerialTx3e thread is still dead however Minicom now reports …

Welcome to minicom 2.7

OPTIONS: I18n
Compiled on Jan 12 2014, 05:42:53.
Port /dev/ttyAMA0, 22:18:55

Press CTRL-A Z for help on special keys

11 602 0 0 0 25891 217
11 615 0 0 0 25886 217
11 599 0 0 0 25923 217
11 607 0 0 0 25921 217

Current, voltage & temp sensors are all reporting 

In summary …

The pulse sensor is not reporting.

And the format of reports in general seems unacceptable to emonhub.

What is the significance of the leading 11 in the reports? Could the body be buried there?

Thx for yr support

Looking at the new sketch file the pulse count has not been added to the print outputs, so that would make sense.

The temp sensor values are added to the serial prints dynamically based on how many temp sensors are found at startup, so this would be as expected too.

Just needs adding to the serial print blocks in the sketch.

AFAIK this interfacer takes full human readable values rather than byte values that require decoding so the use of datacodes shouldn’t be needed. Try using “datacode = 0” in the node definition. I have no experience of this interfacer and have not studied the code so I cannot say if the names and scales are used, I would guess not.

That is the node id, it informs emonhub and emoncms were it originated.

Unfortunately the “thread is dead” message is the result of an unhandled fatal error, that message should never be seen and it only exists in the code to ensure threads do not disappear silently, it offers no insight into what caused it, further debugging will probably involve adding some log “checkpoint” entries to the code unless something is found in the settings.

Try datacode = 0 in the node definition.