# Check Device Connection Status Via Scripting

**URL:** <https://forum.inductiveautomation.com/t/check-device-connection-status-via-scripting/34169>\
**Category:** General Discussion\
**Created:** [April 23, 2020, 6:00pm UTC](https://forum.inductiveautomation.com/t/check-device-connection-status-via-scripting/34169 "2020-04-23T18:00:09Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 23, 2020, 7:38pm UTC](https://forum.inductiveautomation.com/t/check-device-connection-status-via-scripting/34169/2 "2020-04-23T19:38:07Z")

</div>

One way: [system.device.listDevices()](https://docs.inductiveautomation.com/display/DOC80/system.device.listDevices)

Another path:

```auto
[System]Gateway/Devices/DeviceName/Status

```

Third way (and best, IMO): use a heartbeat.

> [@How to detect PLC failure](http://forum.inductiveautomation.com/t/how-to-detect-plc-failure/25631/7):
>
> Hi All, Thanks for the reply. I am using a bit of code in PLC to go 1,0 every sec when the PLC is healthy. . Then I am using an expression tag with the following expression - if(hasChanged({[.]PLC\_Heartbeat}),1,0) This tag is set as an alarm to flag up when the heartbeat is not healthy and I have set it to a ‘clock’ scan class. I have tested it and this seems to be working fine with following errors - Any minor/major PLC faults. PLC network/comms error. Connecti…

---

_[View the full topic](https://forum.inductiveautomation.com/t/check-device-connection-status-via-scripting/34169)._
