# RPI Serial hangups

**URL:** <https://discourse.nodered.org/t/rpi-serial-hangups/7398>\
**Category:** General\
**Created:** [30 January 2019 16:57 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398 "2019-01-30T16:57:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [30 January 2019 16:57 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/1 "2019-01-30T16:57:25Z")

</div>

I have an intelligent home security system connected to my Raspberry Pi via rs232 to /dev/tty/AMA0 using serial in and out nodes within Node-Red. Communication is fine for about a week and then either the in or out node stops communicating. Each time I resolve it by stopping and restarting Node-Red.  
I cannot find any logs and have have no idea how to diagnose what is causing this. Buffer overflow?  
Can anyone help me.  
thanks.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [30 January 2019 17:32 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/2 "2019-01-30T17:32:12Z")

</div>

You can't find any logs? Or you can't find a log that helps to suggest what is happening?  
If it's the former and you have installed node-RED following the suggested method on [https://nodered.org/docs/hardware/raspberrypi](https://nodered.org/docs/hardware/raspberrypi) then the script will have installed the command `node-red-log`

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 January 2019 17:41 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/3 "2019-01-30T17:41:18Z")

</div>

Also, when you say you restart node-red, is that exactly what you do or are you rebooting or what? How are you restarting node red?  
It might also be useful if, in a terminal you run

```bash
node-red-stop
node-red-start

```

and copy/paste the result here. You can copy from the terminal using Ctrl-Shift-C

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [30 January 2019 17:59 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/4 "2019-01-30T17:59:37Z")

</div>

node-red-log produces "command not found"  
I installed all Node red via Pete Scargill's script.  
Colin I have tried all measures including a full reboot and have found that stop- and restart of node red is enough to sort it for a few days. The terminal during restart all looks normal.  
edit \*\*\* the last few lines are new. I will sort that. I don't think it is relevant.

Start Node-RED

Once Node-RED has started, point a browser at [http://10.0.0.50:1880](http://10.0.0.50:1880)  
On Pi Node-RED works better with the Firefox or Chrome browser

Use node-red-stop to stop Node-RED  
Use node-red-start to start Node-RED again  
Use node-red-log to view the recent log output  
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot  
Use sudo systemctl disable nodered.service to disable autostart on boot

To find more nodes and example flows - go to [http://flows.nodered.org](http://flows.nodered.org)

# Starting as a systemd service. Started Node-RED graphical event wiring tool. 30 Jan 17:49:37 - [info] Welcome to Node-RED

## 30 Jan 17:49:37 - [info] Node-RED version: v0.19.4 30 Jan 17:49:37 - [info] Node.js version: v8.11.1 30 Jan 17:49:37 - [info] Linux 4.14.71-v7+ arm LE 30 Jan 17:49:43 - [info] Loading palette nodes 30 Jan 17:49:51 - [info] Dashboard version 2.13.0 started at /ui 30 Jan 17:49:52 - [info] Settings file : /home/pi/.node-red/settings.js 30 Jan 17:49:52 - [info] HTTP Static : /home/pi/.node-red/public 30 Jan 17:49:52 - [info] Context store : 'default' [module=memory] 30 Jan 17:49:52 - [info] User directory : /home/pi/.node-red 30 Jan 17:49:52 - [warn] Projects disabled : editorTheme.projects.enabled=false 30 Jan 17:49:52 - [info] Flows file : /home/pi/.node-red/flows.json 30 Jan 17:49:53 - [info] Server now running at [http://127.0.0.1:1880/](http://127.0.0.1:1880/) 30 Jan 17:49:53 - [warn]

## Your flow credentials file is encrypted using a system-generated key. If the system-generated key is lost for any reason, your credentials file will not be recoverable, you will have to delete it and re-enter your credentials. You should set your own key using the 'credentialSecret' option in your settings file. Node-RED will then re-encrypt your credentials file using your chosen key the next time you deploy a change.

30 Jan 17:49:53 - [info] Starting flows  
30 Jan 17:49:54 - [info] [tcp out:telnet] connecting to localhost:7072  
30 Jan 17:49:59 - [info] [tcp out:telnet] connecting to localhost:7072  
30 Jan 17:50:13 - [info] Started flows  
30 Jan 17:50:13 - [info] [sqlitedb:c37d97a8.1b07c8] opened /home/pi/dbs/iot.db ok  
30 Jan 17:50:13 - [info] [sqlitedb:c37d97a8.1b07c8] opened /home/pi/dbs/iot.db ok  
30 Jan 17:50:13 - [info] [sqlitedb:c37d97a8.1b07c8] opened /home/pi/dbs/iot.db ok  
30 Jan 17:50:13 - [info] [sqlitedb:c37d97a8.1b07c8] opened /home/pi/dbs/iot.db ok  
30 Jan 17:50:13 - [info] serial port /dev/ttyAMA0 opened at 9600 baud 8N1  
30 Jan 17:50:13 - [info] [mqtt-broker:fc8b5c33.494e8] Connected to broker: mqtt://127.0.0.1:1883  
30 Jan 17:50:13 - [info] [tcp out:telnet] connected to localhost:7072  
30 Jan 17:50:13 - [info] [tcp out:telnet] connected to localhost:7072  
30 Jan 17:50:13 - [info] [mqtt-broker:7326ac84.630d14] Connection failed to broker: mqtt://localhost:1883  
30 Jan 17:50:28 - [info] [mqtt-broker:7326ac84.630d14] Connection failed to broker: mqtt://localhost:1883  
30 Jan 17:50:43 - [info] [mqtt-broker:7326ac84.630d14] Connection failed to broker: mqtt://localhost:1883  
30 Jan 17:50:58 - [info] [mqtt-broker:7326ac84.630d14] Connection failed to broker: mqtt://localhost:1883

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 January 2019 21:44 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/5 "2019-01-30T21:44:52Z")

</div>

Are you sure that `node-red-log` is not found? If so then that must be a difference between Pete Scargill's script and the official one from [https://nodered.org/docs/hardware/raspberrypi](https://nodered.org/docs/hardware/raspberrypi)  
Instead you should be able to use  
`sudo journalctl -f -n 100 -u nodered -o cat`  
Assuming that works then maybe the best thing is to wait till it fails again and see what is in the log, if anything.

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [30 January 2019 23:25 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/6 "2019-01-30T23:25:46Z")

</div>

Colin thanks, that command does provide some info. Next time it hangs I'll try it.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [31 January 2019 07:56 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/7 "2019-01-31T07:56:55Z")

</div>

I’d also suggest asking Pete to update his script to include the node-red-log command

---

<div class="post-metadata">

**Author:** ![fragolinux](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fragolinux/32/1137_2.png) [@fragolinux](https://discourse.nodered.org/u/fragolinux)\
**Post date:** [31 January 2019 19:16 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/8 "2019-01-31T19:16:02Z")

</div>

i'm "responsible" of newer additions to Peter's script, and from last december going on we moved to official nodered install script for that part... Peter's one will just be suspended while the official one is run, then after completing will just continue installing Peter's usual collection of nodes... nothing more, take a look at line 797: [https://bitbucket.org/snippets/scargill/qexexb/the-script-2019#script.sh-797](https://bitbucket.org/snippets/scargill/qexexb/the-script-2019#script.sh-797)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 January 2019 21:16 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/9 "2019-01-31T21:16:43Z")

</div>

@muggins Are you using `node-red-stop` and `node-red-start` to stop and start node-red?

What does the command  
`ls /usr/bin/node-red*`  
show?

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [31 January 2019 21:41 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/10 "2019-01-31T21:41:44Z")

</div>

pi@atticPI:~ $ ls /usr/bin/node-red\*  
/usr/bin/node-red /usr/bin/node-red-start  
/usr/bin/node-red-pi /usr/bin/node-red-stop

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 January 2019 22:00 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/11 "2019-01-31T22:00:54Z")

</div>

Well that's very odd. What does  
`cat /lib/systemd/system/nodered.service`  
give. In case you don't know you can copy out of the terminal window using Ctrl-Shift-C.

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [31 January 2019 22:15 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/12 "2019-01-31T22:15:50Z")

</div>

pi@atticPI:~ $ cat /lib/systemd/system/nodered.service

# systemd service file to start Node-RED

[Unit]  
Description=Node-RED graphical event wiring tool  
Wants=network.target  
Documentation=http://nodered.org/docs/hardware/raspberrypi.html

[Service]  
Type=simple

# Run as normal pi user - change to the user name you wish to run Node-RED as

User=pi  
Group=pi  
WorkingDirectory=/home/pi

Nice=5  
Environment="NODE\_OPTIONS=--max\_old\_space\_size=256"

# uncomment and edit next line if you need an http proxy

#Environment="HTTP\_PROXY=my.httpproxy.server.address"

# uncomment the next line for a more verbose log output

#Environment="NODE\_RED\_OPTIONS=-v"  
#ExecStart=/usr/bin/env node $NODE\_OPTIONS red.js $NODE\_RED\_OPTIONS  
ExecStart=/usr/bin/env node-red-pi $NODE\_OPTIONS $NODE\_RED\_OPTIONS

# Use SIGINT to stop

KillSignal=SIGINT

# Auto restart on crash

Restart=on-failure

# Tag things in the log

SyslogIdentifier=Node-RED  
#StandardOutput=syslog

[Install]  
WantedBy=multi-user.target  
pi@atticPI:~ $

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 January 2019 22:20 UTC](https://discourse.nodered.org/t/rpi-serial-hangups/7398/13 "2019-01-31T22:20:38Z")

</div>

Well everything looks ok except that you are missing node-red-log. I have no idea how that might come about.
