# Error in modbus-plugin: "serial: timeout"

**URL:** <https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221>\
**Category:** Telegraf\
**Created:** [January 4, 2022, 3:51pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221 "2022-01-04T15:51:19Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ehninchr](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ehninchr/32/7317_2.png) [@Ehninchr](https://community.influxdata.com/u/Ehninchr)\
**Post date:** [January 4, 2022, 3:51pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/1 "2022-01-04T15:51:20Z")

</div>

Hello all,

I have a problem with the telegraf “modbus-plugin” running on windows with an serial connection (com2)… when running the configuration I always will get the error “serial: timeout”.

I’m in contact with the support of the manufacturer of the modbus-device and I got the manual for the modbus connection - so the settings should be correct (slave-ID and the adresses for the holding register). I also checked the serial connection with a ping 127.0.0.1 successfully. but still I got the following errors

- [agent] Starting service inputs
- [inputs.modbus] trying to read holding@110[1]…
- [inputs.modbus] Error in plugin: serial: timeout
- [agent] Stopping service inputs

what confuse me a little bit, is in the manual from the manufacturer the example for a request from the master to read a register. He added a table for that (see below). I don’t know if that could help me in telegraf or if telegraf in the background will make it in that way.  
 ![grafik](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/c/c2f5c9b6a65ec4193b2d40e8f2ef3dc2d366b446.png)

Below there is the config I’m using for the modbus-plugin

```auto
[[inputs.modbus]]
  ## Connection Configuration
  ## Device name
  name = "heatgenerator"

  ## Slave ID - addresses a MODBUS device on the bus
  ## Range: 0 - 255 [0 = broadcast; 248 - 255 = reserved]
  slave_id = 110

  ## Timeout for each request
  timeout = "2s"

  ## Maximum number of retries and the time to wait between retries when a slave-device is busy.
   busy_retries = 2
   busy_retries_wait = "100ms"

  ## Serial (RS485; RS232)
   controller = 'file:///COM2'
   baud_rate = 9600
   data_bits = 8
   parity = "N"
   stop_bits = 1
   transmission_mode = "RTU"

  holding_registers = [
    { name = "Temperature", byte_order = "AB", data_type = "FLOAT32", scale= 0.1, address = [110]},
  ]

  [inputs.modbus.tags]
  influxdb_database="heat"

```

would be great if someone from the community could support me on that topic

Greetings  
Ehninchr

---

<div class="post-metadata">

**Author:** ![jpowers](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jpowers/32/8569_2.png) [@jpowers](https://community.influxdata.com/u/jpowers)\
**Post date:** [January 4, 2022, 9:44pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/2 "2022-01-04T21:44:45Z")

</div>

Hi,

> [@Ehninchr](#):
>
> ` controller = 'file:///COM2'`

This is not what I would have expected for the controller path. I would have expected something like `file:///dev/ttyS2` or similar for COM2 serial port.

Can you run `ls -l /dev/tty*` and see what tty devices show up.

Thanks

---

<div class="post-metadata">

**Author:** ![Ehninchr](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ehninchr/32/7317_2.png) [@Ehninchr](https://community.influxdata.com/u/Ehninchr)\
**Post date:** [January 5, 2022, 9:39am UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/3 "2022-01-05T09:39:38Z")

</div>

Hello Jpowers,

thank you very much for your reply… but I work with Windows and not with Linux operating system. I followed a description I saw in a other topic in the community… may you have other idea?!

 ![grafik](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/2/2db43b57f7c6c733d7d1c884e0fe3e6f309e0bca.png)

> [@Telegraf modbus plugin serial port connection problem](https://community.influxdata.com/t/telegraf-modbus-plugin-serial-port-connection-problem/22169):
>
> Hello. I’m test telegraf with modbus rtu in windows. but there is error code in windows command. usb port number is com7. error message 2021-10-21T06:04:20Z E! [inputs.modbus] Error in plugin: The system cannot find the path specified. This is modbus.conf [[inputs.modbus]] name = “witmotion” slave\_id = 80 timeout = “1s” controller = “file:///dev/ttyUSB07” baud\_rate = 9600 data\_bits = 8 parity = “N” stop\_bits = 1 transmission\_mode = “RTU” holding\_registers = [ { name = “angle\_x”…

---

<div class="post-metadata">

**Author:** ![popey](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/popey/32/7472_2.png) [@popey](https://community.influxdata.com/u/popey)\
**Post date:** [January 5, 2022, 2:48pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/4 "2022-01-05T14:48:19Z")

</div>

Have you tried just using `controller = 'COM2'`? What happens in that case?

---

<div class="post-metadata">

**Author:** ![Ehninchr](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ehninchr/32/7317_2.png) [@Ehninchr](https://community.influxdata.com/u/Ehninchr)\
**Post date:** [January 5, 2022, 3:54pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/5 "2022-01-05T15:54:37Z")

</div>

Hello popey,

I tried… but there is a failure message called "Error running agent: could not initialize input inputs.modbus: initializing client failed: invalid controller “COM2”

Greetings  
Ehninchr

---

<div class="post-metadata">

**Author:** ![jpowers](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jpowers/32/8569_2.png) [@jpowers](https://community.influxdata.com/u/jpowers)\
**Post date:** [January 5, 2022, 3:55pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/6 "2022-01-05T15:55:11Z")

</div>

Hey,

Had a couple other suggestions come in from folks more familiar with Windows. In addition to popey’s suggestion above can you try first enabling `debug_connection = true` to get some additional data. Then try some combination of the following controller settings?

```auto
controller = 'file://com2'
controller = 'file://COM2'

```

Assuming you know for sure that it is in fact com2 that you need to use.

---

<div class="post-metadata">

**Author:** ![Ehninchr](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ehninchr/32/7317_2.png) [@Ehninchr](https://community.influxdata.com/u/Ehninchr)\
**Post date:** [January 5, 2022, 4:01pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/7 "2022-01-05T16:01:01Z")

</div>

Hello Jpowers,

I’m sure that its the com2 (verified also with the mainboard manual). I’m very happy for your ideas what I can test!!

About your last suggestion, I tested both variants and all will bring me the failure message “Error in plugin: The system can’t find the Path” and after that the input is stopped.

Greetings  
Ehninchr

---

<div class="post-metadata">

**Author:** ![Ehninchr](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ehninchr/32/7317_2.png) [@Ehninchr](https://community.influxdata.com/u/Ehninchr)\
**Post date:** [January 5, 2022, 4:14pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/8 "2022-01-05T16:14:02Z")

</div>

> [@jpowers](#):
>
> `debug_connection = true`

Hey,  
I also checked the “debug\_connection = true” and I received the following information  
 ![grafik](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/0/08f76f0ca21bc133b55cfa971f3ccd2f95f31fb8.png)

comparing the send message with the table above in my first post, telegraf send exactly what is listed there for each single byte.

When I asked the support from the manufacturer of the device, they told me I should ping the device. I wondered if that will work also for a serial connection, but they confirmed me that. Do you have knowledge about that and can you confirm this?

Greetings  
Ehninchr

---

<div class="post-metadata">

**Author:** ![jpowers](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jpowers/32/8569_2.png) [@jpowers](https://community.influxdata.com/u/jpowers)\
**Post date:** [January 5, 2022, 4:18pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/9 "2022-01-05T16:18:37Z")

</div>

I do not know your device or any information about it. Their comment about needing to ping is not something I understand. You may want to ask for clarification about the ping, if that is required before the device shows up?

Let’s see if it even shows up as a serial connection. In powershell, can you run the following:

```auto
[System.IO.Ports.SerialPort]::GetPortNames()

```

That should print something like: `COM1` or some additional devices.

---

<div class="post-metadata">

**Author:** ![Ehninchr](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ehninchr/32/7317_2.png) [@Ehninchr](https://community.influxdata.com/u/Ehninchr)\
**Post date:** [January 5, 2022, 4:22pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/10 "2022-01-05T16:22:18Z")

</div>

for the power shell request

```auto
[System.IO.Ports.SerialPort]::GetPortNames()

```

I got the following reply  
COM1  
COM2  
COM3

COM3 is an Virtual COM Port I use for a other device. And Com1 is free and COM2 is used for modbus connection

---

<div class="post-metadata">

**Author:** ![jpowers](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jpowers/32/8569_2.png) [@jpowers](https://community.influxdata.com/u/jpowers)\
**Post date:** [January 5, 2022, 4:30pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/11 "2022-01-05T16:30:11Z")

</div>

ok excellent to confirm that the device exists 🙂

Can you try one more thing, can you increase the timeout value in your telegraf config to something larger? like 15 seconds?

My other idea was to suggest you try connecting to the device with Putty or some other client to see if it can connect.

---

<div class="post-metadata">

**Author:** ![Ehninchr](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ehninchr/32/7317_2.png) [@Ehninchr](https://community.influxdata.com/u/Ehninchr)\
**Post date:** [January 5, 2022, 4:41pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/12 "2022-01-05T16:41:51Z")

</div>

I tried to increase the timeout value to 15 sec… but the problem is still there.

I connected with Putty to the device, but see only the empty screen. I tried to type the bytes “6e 03 00 6e 00 01 ec 88” but nothing was visualized in the putty view.  
 ![grafik](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/1/171643e5dbd4f4d30931b45f9450cf8dfcba6f7d.png)

---

<div class="post-metadata">

**Author:** ![OranMZT](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/oranmzt/32/11554_2.png) [@OranMZT](https://community.influxdata.com/u/OranMZT)\
**Post date:** [December 2, 2022, 4:36pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/13 "2022-12-02T16:36:51Z")

</div>

Hi Ehninchr,

We’re you ever able to fix this issue?

---

<div class="post-metadata">

**Author:** ![Ehninchr](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ehninchr/32/7317_2.png) [@Ehninchr](https://community.influxdata.com/u/Ehninchr)\
**Post date:** [December 6, 2022, 8:00pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/14 "2022-12-06T20:00:44Z")

</div>

Hello OranMZT,

no I was not able to get it run… my modbus device is an old control and I’m not sure if the failure is on this side. From the telegraf skript I tried everything

Greetings  
Ehninchr

---

<div class="post-metadata">

**Author:** ![OranMZT](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/oranmzt/32/11554_2.png) [@OranMZT](https://community.influxdata.com/u/OranMZT)\
**Post date:** [December 7, 2022, 11:16am UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/15 "2022-12-07T11:16:23Z")

</div>

HI Ehninchr,

I chased this up on the InfluxDB slack and had my issue request addressed on github. Sven was nice enough to create a fix thats available here :[fix(inputs.modbus): Fix Windows COM-port path by srebhan · Pull Request #12339 · influxdata/telegraf · GitHub](https://github.com/influxdata/telegraf/pull/12339)

Cheers,  
Oran

---

<div class="post-metadata">

**Author:** ![srebhan](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/srebhan/32/8572_2.png) [@srebhan](https://community.influxdata.com/u/srebhan)\
**Post date:** [December 8, 2022, 2:37pm UTC](https://community.influxdata.com/t/error-in-modbus-plugin-serial-timeout/23221/16 "2022-12-08T14:37:48Z")

</div>

@Ehninchr if you see a problem with the modbus plugin and your device, please open an issue on our [GitHub project](https://github.com/influxdata/telegraf/) so we can chase it down. 🙂
