Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection timed out #20

Open
peterspijker opened this issue Jan 23, 2021 · 2 comments
Open

Connection timed out #20

peterspijker opened this issue Jan 23, 2021 · 2 comments

Comments

@peterspijker
Copy link

I am trying to communicate with my SDM120-modbus. I am pretty sure I have wired everything correctly (B to 9 and A to 10), but somehow I cannot talk to the SDM120. This is the output I am getting:

ubuntu@ubuntu:~/smartmeter$ SDM120C/sdm120c -a 1 -b 9600 -e -p -q -z 3 -j 20 -d 1 /dev/ttyUSB2 
20210123-20:23:38.858984: SDM120C/sdm120c(32257) debug_flag = 1
20210123-20:23:38.859152: SDM120C/sdm120c(32257) cmdline="SDM120C/sdm120c -a 1 -b 9600 -e -p -q -z 3 -j 20 -d 1 /dev/ttyUSB2"
20210123-20:23:38.859270: SDM120C/sdm120c(32257) szttyDevice: /dev/ttyUSB2
20210123-20:23:38.859373: SDM120C/sdm120c(32257) devLCKfile: </var/lock/LCK..ttyUSB2>
20210123-20:23:38.859472: SDM120C/sdm120c(32257) devLCKfileNew: </var/lock/LCK..ttyUSB2.32257>
20210123-20:23:38.859572: SDM120C/sdm120c(32257) PID: 32257
20210123-20:23:38.859781: SDM120C/sdm120c(32257) Attempting to get lock on Serial Port /dev/ttyUSB2...
20210123-20:23:38.859944: SDM120C/sdm120c(32257) Acquiring shared lock on /var/lock/LCK..ttyUSB2...
20210123-20:23:38.860058: SDM120C/sdm120c(32257) Shared lock on /var/lock/LCK..ttyUSB2 acquired...
20210123-20:23:38.860308: SDM120C/sdm120c(32257) Checking for lock
20210123-20:23:38.860536: SDM120C/sdm120c(32257) errno=0, bRead=2 PID=32257 LckPID=32257
20210123-20:23:38.860704: SDM120C/sdm120c(32257) Checking process 32257 (SDM120C/sdm120c) for lock
20210123-20:23:38.860906: SDM120C/sdm120c(32257) PID: 32257 COMMAND: "SDM120C/sdm120c" LckPID: 32257 LckCOMMAND: "SDM120C/sdm120c" LckPIDcommand "SDM120C/sdm120c" = me
20210123-20:23:38.861006: SDM120C/sdm120c(32257) Appears we got the lock.
20210123-20:23:38.861103: SDM120C/sdm120c(32257) resp_timeout=2000000us
20210123-20:23:38.861209: SDM120C/sdm120c(32257) Libmodbus context open (9600E1)
20210123-20:23:38.861311: SDM120C/sdm120c(32257) Byte timeout disabled.
20210123-20:23:38.861413: SDM120C/sdm120c(32257) New response timeout: 0s, 2000000us
20210123-20:23:38.865284: SDM120C/sdm120c(32257) 1/3. Register Address 30013 [000C]
20210123-20:23:39.366133: SDM120C/sdm120c(32257) ERROR (110) Connection timed out, 1/3, Address 30013 [000C]
20210123-20:23:39.366340: SDM120C/sdm120c(32257) Response timeout gave up after 500634us
20210123-20:23:39.366485: SDM120C/sdm120c(32257) 2/3. Register Address 30013 [000C]
20210123-20:23:39.867357: SDM120C/sdm120c(32257) ERROR (110) Connection timed out, 2/3, Address 30013 [000C]
20210123-20:23:39.867538: SDM120C/sdm120c(32257) Response timeout gave up after 500668us
20210123-20:23:39.867682: SDM120C/sdm120c(32257) 3/3. Register Address 30013 [000C]
20210123-20:23:40.368541: SDM120C/sdm120c(32257) ERROR (110) Connection timed out, 3/3, Address 30013 [000C]
20210123-20:23:40.368763: SDM120C/sdm120c(32257) Response timeout gave up after 500658us
20210123-20:23:40.370568: SDM120C/sdm120c(32257) devLCKfile: </var/lock/LCK..ttyUSB2>
20210123-20:23:40.370722: SDM120C/sdm120c(32257) devLCKfileNew: </var/lock/LCK..ttyUSB2.32257> 
20210123-20:23:40.370848: SDM120C/sdm120c(32257) Clearing Serial Port Lock (32257)...
20210123-20:23:40.371056: SDM120C/sdm120c(32257) Acquiring exclusive lock on /var/lock/LCK..ttyUSB2...
20210123-20:23:40.371282: SDM120C/sdm120c(32257) Exclusive lock on /var/lock/LCK..ttyUSB2 acquired (0) Success...
20210123-20:23:40.371573: SDM120C/sdm120c(32257) cmdLen=15
20210123-20:23:40.371711: SDM120C/sdm120c(32257) cmdLen=15 COMMAND is not null
20210123-20:23:40.371940: SDM120C/sdm120c(32257) errno=0, bRead=2 LckPID=32257 PID=32257 COMMAND='SDM120C/sdm120c'
20210123-20:23:40.372080: SDM120C/sdm120c(32257) errno=0, bRead=-1 LckPID=32257 PID=0 COMMAND=''
20210123-20:23:40.372391: SDM120C/sdm120c(32257) Clearing Serial Port Lock done
NOK
20210123-20:23:40.372705: SDM120C/sdm120c(32257) NOK

The USB-modbus-RS485 device is located on /dev/ttyUSB2 (I checked this with dmesg). Any help would be appreciated!

@peterspijker
Copy link
Author

I have been fiddling a bit more, and after swapping some USB-connections on the Raspberry Pi I seem to be able to retrieve some data from the SDM120:

ubuntu@ubuntu:~/smartmeter$ SDM120C/sdm120c /dev/ttyUSB0 -P N
Voltage: 235.30 V 
Current: 0.31 A 
Power: 0.00 W 
Active Apparent Power: 70.59 VA 
Reactive Apparent Power: -70.51 VAR 
Power Factor: -0.05 
Phase Angle: 0.00 Degree 
Frequency: 50.00 Hz 
Import Active Energy: 6576848 Wh 
Export Active Energy: 0 Wh 
Total Active Energy: 6576848 Wh 
Import Reactive Energy: 1974940 VARh 
Export Reactive Energy: 1492504 VARh 
Total Reactive Energy: 3467444 VARh 
OK

But when I change the baud rate (from the default 2400) it errors in NOK. Any idea why this happens?

@gianfrdp
Copy link
Owner

Hello, have you changed default speed from 2400 to 9600 using parametr -r, after putting meter in programming mode (push front button for 3 sec).
If not, this is the cause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants