### Serial (RS485; RS232)
controller = "file:///dev/ttyUSB0"
baud_rate = 9600
data_bits = 8
parity = "N"
stop_bits = 1
transmission_mode = "RTU"
$ sudo systemctl status telegraf
telegraf[446]: 2021-05-19T06:20:30Z E! [inputs.modbus] Error in plugin
$ sudo telegraf --test
Started and Showed Measurement value without error
If I Start with $ sudo telegraf
telegraf Stared , loaded Input.Modbus and data collection working perfectly.
After reboot the data collection not started automatically. I also tried serial port permission permanent process. Can’t find the solutions for auto start . when I entered manually $sudo telegraf then it will started collection.
I think you should check the permission for the telegraf user to access the tty interface, which is most probably what is preventing telegraf to run: you overcome this limit when you run with sudo, as you have full rights.
I already provided permission for system user ttyUSB0 and it also work well $ telegraf (without sudo) The main problem is the system reboot after the Input.Modbus collection not started.
Anyway, How to provide permission for telegraf user.
The telegraf user is not “pi” but “telegraf”, if you didn’t change it on purpose.
Run this and check which is the user cat /lib/systemd/system/telegraf.service | grep "User"
Added Telegraf user to dialout
$ cat /lib/systemd/system/telegraf.service | grep “User”
User=telegraf
$ sudo adduser telegraf dialout
Adding user telegraf' to group dialout’ …
Adding user telegraf to group dialout
Done.
After reboot the Modbus Collection started automatically.