Modbus plugin: controller = "file:///dev/ttyUSB0" does not work!

at the last houres I try to get a connection to a SDM630 device via RS486 via USB-Dongle. The last configuration of telegraf:


  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = "0s"
  hostname = ""
  omit_hostname = false
  debug = true
#  logtarget = "file"
#  logfile = "/var/log/telegraf/telegraf.log"

  database = "telegraf"
  urls = [""]
  username = "telegraf"
  password = "telegraf"

  percpu = true
  totalcpu = true
  collect_cpu_time = false
  report_active = false
  core_tags = false

  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]








# Retrieve data from MODBUS slave devices
  name = "SDM630"
  slave_id = 1
  timeout = "1s"
  controller = "file:///dev/ttyUSB0"
  baud_rate = 9600
  data_bits = 8
  parity = "N"
  stop_bits = 1
  transmission-mode = "RTU"
  debug_connection = true
  configuration_type = "register"

I get every time the same result:

root@sentinel:/etc/telegraf# telegraf -test -config /etc/telegraf/telegraf.conf --debug
2022-09-17T18:39:44Z I! Starting Telegraf 1.24.0
2022-09-17T18:39:44Z I! Available plugins: 222 inputs, 9 aggregators, 26 processors, 20 parsers, 57 outputs
2022-09-17T18:39:44Z I! Loaded inputs: cpu disk kernel mem modbus net netstat processes swap system
2022-09-17T18:39:44Z I! Loaded aggregators: 
2022-09-17T18:39:44Z I! Loaded processors: 
2022-09-17T18:39:44Z W! Outputs are not used in testing mode!
2022-09-17T18:39:44Z I! Tags enabled: host=sentinel
2022-09-17T18:39:44Z D! [agent] Initializing plugins
2022-09-17T18:39:44Z E! [telegraf] Error running agent: could not initialize input inputs.modbus: initializing client failed: invalid protocol 'file' - '' 

All the debug and logging options are complete useless for me! Whats wrong?

telegraf --version
cat /etc/os-release
ls -lah /dev/ttyUSB0
root@sentinel:/etc/telegraf# telegraf --version
Telegraf 1.24.0 (git: HEAD@3c4a6516)
root@sentinel:/etc/telegraf# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION="11 (bullseye)"
root@sentinel:/etc/telegraf# ls -lah /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 18. Sep 12:30 /dev/ttyUSB0
1 Like

And by the way, the user root and telegraf are also member of the dialout group, perhabs not necessary but also not wrong.

I also disabled apparmor on this system, no success! :frowning:


invalid protocol ‘file’ - ‘’

This error comes from here when the file transmission mode is not matched to either “RTU” or “ASCII”. In your case, I believe it is because you have:

transmission-mode = “RTU”

which should be

transmission_mode = “RTU”

1 Like