# How to close Firmata (Johnny5) serial connection safely?

**URL:** <https://discourse.nodered.org/t/how-to-close-firmata-johnny5-serial-connection-safely/36778>\
**Category:** Industrial\
**Created:** [30 November 2020 23:43 UTC](https://discourse.nodered.org/t/how-to-close-firmata-johnny5-serial-connection-safely/36778 "2020-11-30T23:43:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [30 November 2020 23:43 UTC](https://discourse.nodered.org/t/how-to-close-firmata-johnny5-serial-connection-safely/36778/1 "2020-11-30T23:43:15Z")

</div>

I think that the Johnny5 component has a bug.

- If clicking Deploy, the current Board connections do not close properly, so after deployment they can not reconnect.  
Even the enhanced, [new version](https://flows.nodered.org/node/node-red-contrib-johnny5).

I'm searching a way to place a manual "Close USB0" script ... or even better (if it's possible) a "Close ALL".

This code does not seem to work:

```auto
var io = new IOPlugin();
io.ClosePort(board.port);

```

[ClosePort function link...](https://github.com/rwaldron/io-plugins#serialcloseportid)

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [30 November 2020 23:45 UTC](https://discourse.nodered.org/t/how-to-close-firmata-johnny5-serial-connection-safely/36778/2 "2020-11-30T23:45:06Z")

</div>

```auto
[{"id":"a15c94d6.413a78","type":"script","z":"2c9fbd1d.903c7a","name":"Disconnect USB0","func":"var io = new IOPlugin();\nio.ClosePort(board.port);","board":"ccc3d062.a2ca8","noerr":0,"x":280,"y":520,"wires":[[]]},{"id":"1014ea7c.ee9dde","type":"inject","z":"2c9fbd1d.903c7a","name":"DoIt!","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":520,"wires":[["a15c94d6.413a78"]]},{"id":"ccc3d062.a2ca8","type":"ioplugin","z":"","name":"RedonyNanoFirmata USB0","username":"","password":"","boardType":"firmata","serialportName":"/dev/ttyUSB0","connectionType":"local","mqttServer":"","pubTopic":"","subTopic":"","tcpHost":"","tcpPort":"","sparkId":"","sparkToken":"","beanId":"","impId":"","uuid":"","token":"","sendUuid":"","samplingInterval":"500"}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [29 January 2021 23:45 UTC](https://discourse.nodered.org/t/how-to-close-firmata-johnny5-serial-connection-safely/36778/3 "2021-01-29T23:45:22Z")

</div>

Closed on 29 January 2021 23:45 UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
