Node-RED provides a low cost user interface option for controlling the CTR2 HMI. In addition to providing local control it also provides remote control capabilities via almost any web browser. When coupled with SonoBus to handle two-way audio transport, you have a pretty complete remote station control system. Node-RED allows you to add additional functionality to your remote station by simply adding addition flows created by other users.

Node-RED can be run from almost any PC, from the latest Windows PC to the Raspberry PI 3. I installed it on my old Mac-Mini running Linux, on my station server, and on several Raspberry Pis. The only requirement is the PC must have a serial port. On most PCs this is usually provided by a USB serial adapter such as this one from Adafruit. On the Raspberry Pi you can use the serial port on pins 6, 8, and 10 on the GPIO bus to connect directly to the Local Display pins on the HMI board without a USB serial adapter.

Node-RED doesn’t provide great controls for tuning your radio. I had to resort to push buttons and a slider instead of clicking on the frequency digits or the FFT display. However, this can be remedied if you connect an external encoder to the DISP jack on the front of the HMI. While you’re at it you can also also wire up a USB-RS232 adapter to connect the HMI to your PC instead of using the internal Local Display header described above. Instructions to do this can be found here.

To install Node-RED, download and install if from the Node-RED web site. I highly suggest going through their tutorials on what Node-RED is and how to work with it.

Once you have Node-RED running, add the following Nodes from the Palette Manager (the node-red node is already installed):

Required Nodes for CTR2 Flows

I’m still pretty new to the Node-RED ecosystem, so forgive me if I didn’t do everything “by the book”. I learn by doing and I’m sure I’ll be changing things around in the future as I learn more.

The CTR2 Node-RED flows (i.e. program) are LARGE – over 1900 objects! I don’t recommend just importing them into the existing flows you may already have running because it is a real pain to remove them if you decide it’s not for you.

INSTALL CTR2 NODE-RED FLOWS

To install just the CTR2 flows, use this process:

  1. Navigate to the {user folder}/.node-red/ folder and rename the existing flows.json file to something like flows_old.json. This file contains the current flows you have installed.
  2. Download and unzip the CTR2 Node-RED flows from the Node-RED Download post. Copy the flows.json file to your {user folder}/.node-red/ folder. It will become the default flow when you restart Node-RED.
  3. Once this has been done, stop and restart Node-RED from the terminal. This is done using the following commands in Debian Linux. For other OS flavors use their commands to stop and start the Node-RED service.

sudo systemctl stop nodered

sudo systemctl start nodered

Navigate to {pc IP address}:1880 in your browser to open the Node-RED IDE. The CTR2 flows should appear.

NOTE: To remove the CTR2 flows from Node-RED, just delete the flows.json file in the {user folder}/.node-red/ folder and rename the original flow back to flows.json.

SETTING THE COM PORT

The first item of business is to edit the serial port assigned to the Serial In and Serial Out nodes.

If you’re running Node-RED on a Windows PC you can find the serial port assigned to your USB TTL serial adapter in the Device Manager (right click the Windows logo). For Linux PCs the USB adapter will probably be called /dev/ttyUSB0. On a Raspberry Pi the serial port on the GPIO bus (pins 6, 8, and 10) is /dev/ttyS0.

Double click on the Serial In node in the upper left corner of the Comm Rx tab. This will open the Node Properties window. Click the Edit button to edit the properties.

Change the Serial Port to match the port your PC mapped to the serial adapter. Leave the Settings at 115200 baud, 8 data bits, no parity, and 1 stop bit. Also, leave the Input settings to Split Input after 3 ms and deliver binary buffers.

Click the Update button to update the serial port. Next, open the Serial Out node on the far right side of the Comm Rx tab and put the same settings on this node.

Once the serial port settings have been changes, click the Deploy button to send your updated flows to Node-RED on your PC. If all goes well a small green square labeled connected will appear next to the serial nodes.

CONNECTING THE HMI TO NODE-RED

Once you have the flow updated it’s time to connect your USB adapter to CTR2‘s HMI. To do this, simply connect the TD, RD, and Ground wires from your USB adapter to the TD, RD, and GND pins on CTR2‘s Local Display header. This header is located to the right of the ESP8266 socket on the front of the board.

WARNING! Do not connect the +5VDC pin on the USB adapter to the +5VDC pin on the HMI! This will backfeed +5VDC into your PC if the HMI’s micro-USB port is connected to your PC.

If you’re using a Raspberry Pi to host Node-RED you don’t need a separate USB-TTL adapter, you can connect the HMI‘s Local Display port directly to the serial port on the Raspberry Pi’s GPIO bus. Here’s a simple schematic for this connection.

CTR2 DASHBOARD ON NODE-RED

To open the CTR2 dashboard navigate to {pc IP address}:1880/ui. The Initialize page should open. Just click the Initialize CTR2 button to start using CTR2.

LOGIN

I’ve included a Login flow that supports multiple user logins. Each user has their own user name and password (maintained in the {user folder}/node-red/CTR2_Users.txt file). I use this feature for my Node-RED demo. This tab is disabled in the published flow.

You can play with the dashboard without the HMI connected to get a feel for the interface. This allows you to test drive the system before building the boards. Be forewarned that if you don’t have it connected to a CTR2 HMI many of the options won’t show up properly.

73, Lynn