P1 Smart meter USB does not save 115200 baud rate correct

Moderator: leecollings

Post Reply
bart59
Posts: 3
Joined: Wednesday 02 November 2016 0:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

P1 Smart meter USB does not save 115200 baud rate correct

Post by bart59 »

(Raspberry PI 3 - version v3.5849 (beta) also same with the stable version

In the "setup" screen for the "P1 Smart Meter" you can select the baud rate (9600 or 115200). I see 3 problems:
1. In the web interface the setting for 115200 is not saved. When returning to this page the setting falls back to 9600
2. When setting the baud rate (either 9600 or 115200), the log shows the message "Error: Webserver: File '/setp1usbtype.webem': No such file or directory (2)"
3. The USB port does not seem to be set at all. My meter sends data at 115200 and all device values stay at 0

I can force the USB port to the right baud rate as follows:
- from a separate terminal window I first installed minicom:

Code: Select all

sudo apt-get minicom
- then I can hook into the same USB port where the P1 cable is attached (USB0) with:

Code: Select all

minicom -b 115200 -o -D /dev/ttyUSB0
- now I see in my terminal window the smart meter data coming in --> at the same time Domoticz sees the same data and the smart meter data is also visible in the device graph
- when I terminate minicom, the data towards Domoticz also stops

I think this must be a bug in some of the core USB functions in Domoticz. Any other suggestions?

Bart
bart59
Posts: 3
Joined: Wednesday 02 November 2016 0:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 Smart meter USB does not save 115200 baud rate correct

Post by bart59 »

I am no longer able to reproduce the problem. It seems to work fine now. I do have another problem that may be related: I have 2 USB devices plugged into my Raspberry: P1 cable and RFXcom tranceiver. With each reboot of the raspberry the allocation of ttyUSB0 and ttyUSB1 is kind of random. This means that if Domoticz is configured to use ttyUSB0 for the P1 cable, the device may show up at ttyUSB1 after the next reboot. This means the P1 connection no longer works. I fixed this using the following procedure:

(see http://unix.stackexchange.com/questions ... tatic-name for more info)

from a terminal window:
1. find out what's on ttyUSB:

Code: Select all

pi@raspberrypi:~ $ dmesg | grep ttyUSB 

[    4.074363] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0
[    4.075590] usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB1
Take not of the node numbers: 1-1.2 and 1-1.3

2. list all attributes of the devices (in my case USB0 and USB1):

Code: Select all

pi@raspberrypi:~ $ udevadm info --name=/dev/ttyUSB0 --attribute-walk
...
pi@raspberrypi:~ $ udevadm info --name=/dev/ttyUSB1 --attribute-walk
...
  looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2':
    KERNELS=="1-1.2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="1.2"
    ATTRS{idVendor}=="0403"
    ATTRS{speed}=="12"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="4"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="90mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="a0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="0"
    ATTRS{bcdDevice}=="0600"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="A1LPXWF"
    ATTRS{version}==" 2.00"
    ATTRS{urbnum}=="179474001"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="RFXCOM"
    ATTRS{removable}=="removable"
    ATTRS{idProduct}=="6001"
    ATTRS{bDeviceClass}=="00"
    ATTRS{product}=="RFXtrx433"
...
Look at tree leaf matching the node name from the prior step. I my case ..../usb1/1-1/1-1.3 en ..../usb1/1-1/1-1.2
The RFXCON and P1 both had the same idVendor (0403) and idProduct (6001), but they had different serial numbers. That part matters, because we are now going to create a new USB device linked to that specific serial number

3. Create a file /etc/udev/rules.d/10-usb-serial.rules with rules for all USB devices in it:

Code: Select all

pi@raspberrypi:~ $ sudo nano /etc/udev/rules.d/10-usb-serial.rules
type the following in the editor and then save the file (ctrl-o) and (ctrl-x):

Code: Select all

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTR{serial}=="P11234567",  SYMLINK+="ttyUSB_P1"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTR{serial}=="RFX1234567",  SYMLINK+="ttyUSB_RFX"
Note: the serial numbers, idVendor and idProduct shown need to be replaced by your ids

4. Load the new rule:

Code: Select all

pi@raspberrypi:~ $ sudo udevadm trigger 


5. Verify what happened:

Code: Select all

pi@raspberrypi:~ $ ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Nov 11 10:29 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 Nov 11 10:00 /dev/ttyUSB1
lrwxrwxrwx 1 root root         7 Nov 11 10:00 /dev/ttyUSB_P1 -> ttyUSB1
lrwxrwxrwx 1 root root         7 Nov 11 10:00 /dev/ttyUSB_RFX1 -> ttyUSB0
As you see we still have the existing USB0 and USB1 devices, but also have 2 symbolic links to devices that are match the right hardware. These symbolic links will be created at each reboot or when the USB device is plugged into an USB port.

6. Now in Domoticz below the Hardware menu change the device for the P1 cable to ttyUSB_P1 and the one for RFXCOM to ttyUSB_RFX1
stlaha2007
Posts: 370
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: P1 Smart meter USB does not save 115200 baud rate correct

Post by stlaha2007 »

Nice, seen at wiki mentioned 'persistant usb devices' however couldn't recall the serial as destinction :-)


Sent from my K00C using Tapatalk
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests