Serial-Direct connection between Pi and emonTx shield

[ moved from Does the emonTx Shield need an actual Arduino? ]

I’m new to this forum but this topic seems to me beeing read by a lot of experts.
I still have some issues with my monitoring which is built with a TX shield without RF module, 2 CTs - one for the PV and the other for network income - sticked on an Arduino Uno. Communication via serial to a Raspberry PI running mysql, emoncms emonhub, etc. as described in the articles
and emoncms/docs/RaspberryPi at master · emoncms/emoncms · GitHub
I crosschecked several times the settings, but the inputs are still missing in emoncms.
Any idea, how to debug the solution?
Or are there experiences described somewhere with similar setup?
Thank you in advance: László from Hungary

what does your emonHUB config look like?

 sudo nano /etc/emonhub/emonhub.conf

also anything on emonCMS logs?

sudo nano /var/log/emoncms.log

# This interfacer manages the RFM2Pi module
    Type = EmonHubJeeInterfacer
        com_port = /dev/ttyAMA0
        group = 210
        frequency = 433
        baseid = 15

    type = EmonHubSerialInterfacer
        com_port = /dev/ttyAMA0
        com_baud = 9600

emoncms.log is empty. also /var/log/emonhub/emonhub.log

could you try:

sudo screen /dev/ttyAMA0 9600

use if you dont have screen , CTRL+A and then D to exit screen :wink:

sudo apt-get install screen

see if you get any serial output from the emonTX, also you might wanna remove the [[RFM2Pi]] block since you don’t have it :slight_smile:

Installed screen , after running:blank screen.
Also removed RFM2PI block, nothing changed, seems the serial connection is not working properly. I will check and come back with the results.
Need some time, because I have to do some reorganisation around the fuse box before I can reach the HW.

seems like so :frowning:

maybe someone else has ideas :smiley:

There could be HW issues as well. I’m not a soldering champion, so everything is possible.
My main goal was to find ways or procedures for debugging. You did your part, thank you very much for that.
I now know, that serial port of RBPI doesn’t get any data from TX shield/Arduino.
Helped me further in the investigations.

How do you have the Arduino Uno & emonTx shield connected to the Pi?
The Pi is not 5v safe and the emonTx sheild’s serial lines are connected directly to the attached Arduino’s serial lines, normally the Arduino is running at 5v and not suitable for a “serial-direct” connection with the Pi’s 3.3v GPIO without some level shifting.

Do you have a USB serial adapter? if so test the serial output of the Arduino+shield. If it’s ok, there is a possibility the Pi’s serial rx line is damaged.

You can test the Pi’s serial port by carefully linking the rx and tx pins together with a link wire or 2pin jumper link etc. With the pins linked you can open a serial terminal like Minicom and anything you write to the serial port should be echoed back to the terminal.

To connect the 5v Arduino+sheild serial lines to the Pi’s 3.3v serial lines you will need to connect via a level shifter or you can add a voltage divider between the Adrduino/shields tx line and the Pi’s rx line in much the same way as is used to communicate with a 3.3v RFM module (when fitted) see the schematic for details. Or if your Uno has a USB port, you can use that to hook up to the Pi without any level shifting and point the EmonHubSerialInterfacer at /dev/ttyUSB0.

As I’ve read in this description RBPIs 5V input will be shifted to 3.3V by the Arduino HW.
But : indeed, arduino and PI have USB connections.
How do I set the emonhub.conf settings for the USB-connection?

That page is all about connecting an emonTx, not an emonTx shield. The emonTx is operating entirely at 3.3v, although “5v powered” there is an on-board 3.3v voltage regulator and all levels are 3.3v.

Try using a usb connection with something like

    type = EmonHubSerialInterfacer
        com_port = /dev/ttyUSB0
        com_baud = 9600

changed emonub.conf to USB, still no entries in input table. Is there something else what has to be changed?

Are you using the latest sketch as the serial baud has changed to 115200, this can be confirmed by looking in the sketch.


What sketch have you installed to the Arduino?
Have you confirmed there is a serial output over USB?
Is it in the right format of space separated variables with a leading node id?
Is the serial baud of that sketch 9600? I only carried that over from your previous post.

Once you know the serial output is present, correct and at what baud you can hook it up to the Pi with some confidence that there is a serial output to be found.

What OS are you running on the Pi? /dev/ttyUSB0 assumes 2 things, firstly that the OS is Raspbian (or similar) not Ubuntu (or similar) so it could be dev/ttyS0 and that it is the only device and the maybe even first time plugged in since the Pi booted. The /dev/ addresses are allocated dynamically at boot and the in order that additional devices are added so it could be /dev/ttyUSB1 or 2 etc if there are other devices or you have unplugged and plugged it in again.

You can see all/any usb or serial devices by using this at the commandline

ls -la /dev/{tty{AMA,S,USB},serial}*

Once you have established the address of the connected device you can edit emonhub.conf to point at the device (com_port =) and use the correct baud (com_baud = ).

At this point you can take a look in emonHub’s logs to confirm all is going to plan and the serial input is being received ok.

If using the emonSD image you will need to create a [nodes] entry for this device as the local emoncms is connected via MQTT and numeric nodeids and input index’s are ignored.

Thank you, Paul, I will do this recommendations.
At the first look they are very heplpful, hope, I can report back with a success.
But actually I’m under way, so it may take some time.

OS is Raspbian GNU/Linux 8 (jessie)
Sketch is likely the same as described in the article 'TX to RPI via serial).
ls command shows something strange to me, but may be you can decode it:

[email protected]:/home/laci# ls -la /dev/{tty{AMA,S,USB},serial}*
ls: /dev/ttyS* no access: No such file or directory
ls: /dev/ttyUSB* no access: No such file or directory
lrwxrwxrwx 1 root root          7 dec   29 08:05 /dev/serial0 -> ttyAMA0
crw-rw---- 1 root dialout 204, 64 dec   29 08:05 /dev/ttyAMA0

total 0
drwxr-xr-x  4 root root   80 dec   29 08:05 .
drwxr-xr-x 15 root root 3360 dec   29 11:15 ..
drwxr-xr-x  2 root root   60 dec   29 08:05 by-id
drwxr-xr-x  2 root root   60 dec   29 08:05 by-path

no, it seems to be an older one, uses 9600.
I will change it, but not in this year anymore. :slight_smile:
Thank you all and wish you a Happy New Year!

The output from ls suggests there is nothing connected to the USB ports. does your device show up with lsusb ? Unless it is obvious to pick out from the list you may need to run lsusb twice, once with it connected and once without to spot the difference.

First you need to confirm the device is working!!!

Go back to the Arduino IDE and check the serial output.

Arduino IDE shows reliable outputs every appr.5 secs.
USB connected back to RPI lsusb output:

[email protected]:/home/laci# lsusb
Bus 001 Device 004: ID 2341:0243 Arduino SA
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514
Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Good, what format is the data output?

Good, so the Arduino is recognised as a USB device, we just can’t find it. Can you try another ls search for serial devices using

sudo ls -la /dev/{tty{ACM,AMAS,USB},serial}*

The search command has been amended to include “ACM” devices as I have seen this used in places, but I have never used a USB Arduino to know for sure what it shows up as. If it still isn’t found then you will need to do a wider search before and after “connecting Arduino” using sudo ls -la /dev/* and find the difference.

Still similar:

[email protected]:/home/laci# sudo ls -la /dev/{tty{ACM,AMAS,USB},serial}*
ls: /dev/ttyAMAS* no access: no such file or directory
ls: /dev/ttyUSB* no access: no such file or directory
lrwxrwxrwx 1 root root         7 jan    3 20:17 /dev/serial0 -> ttyAMA0
crw-rw---- 1 root dialout 166, 0 jan    3 20:17 /dev/ttyACM0

total: 0
drwxr-xr-x  4 root root   80 jan    3 20:17 .
drwxr-xr-x 15 root root 3320 jan    3 20:17 ..
drwxr-xr-x  2 root root   60 jan    3 20:17 by-id
drwxr-xr-x  2 root root   60 jan    3 20:17 by-path

But i’ve found two other entries in ‘by-id’ and ‘by-path’ directories:

[email protected]:/home/laci# ls /dev/serial/by-*


How should I address them in emonhub.conf - if one of them is the right one? Simple with the path of the files?