Package name: node-red-contrib-andinox1
This page details how to use the Andino X1 node. For a setup tutorial on Node Red for the Raspberry Pi and documentation on how to install custom nodes, please refer to Installing Node-Red on the Raspberry Pi
The Andino X1 node is a custom node that handles messages from the Andino X1 board and enables communication with the Andinopy TCP socket or the Arduino controller.
This node allows for easy control of the OLED display of Andino IO boards via Node-Red. The node needs the Andinopy python library to be installed to work correctly, since it uses the Common Andino Protocol to communicate with the Atmel controller. For instructions on how to do so, please refer to Andinopy: Setup and Usage.
Your Raspberry Pi also has to have Node-Red set up. To do so, please follow the guide Installing Node-Red on the Raspberry Pi or use the Andinopy setup script.
Note: If you are using an Andino X1 board, this node can also be run without using Andinopy. This, however, is not recommended due to a loss of flexibility. If you want to do so anyway, instead of the TCP in/TCP Out nodes refered to in this guide, Serial In/Serial Out nodes need to be used. Here, use a Baud Rate of 38400, 8 data bits, no parity bit and 1 stop bit. DTR, RTS, CTS and DSR can all be left on Auto. The correct serial port for the microcontroller is /dev/ttyAMA0.
First, drag the node into the main panel in Node Red. When double clicking on the Andino X1 node, it can be set to one of three modes: Events, Relay 1 and Relay 2:
When in Events mode, the node's input must be connected to a TCP In node. When in Relay 1 / Relay 2 mode, the node's output must be connected to a TCP Out node.
The TCP nodes establish a connection to the Andinopy TCP socket, which in turn communicates with the Andino X1/Andino IO firmware.
In the node properties, the TCP In node has to be set to Connect to port 9999 (by default). Enter localhost as the hostname. In the Output section, select stream of and String. All the other flields can be left blank.
The TCP Out node has to be set to Connect to port 9999 (by default). Enter localhost as the hostname. All the other flields can be left blank and the close connection after every message and decode Base64 message checkboxes should be unchecked.
Note: You can download and add the examples to your Node-Red install by simply uploading this .json file in your Node-Red interface (or copying its contents). To do so, press Ctrl + i in your Node-Red web UI, then either paste the file content or upload the file.
For testing purposes, the AndinoX1 node can be wired up to inject nodes that are set to output a boolean value. The Andino X1 node is set to either Relay 1 or Relay 2 mode and conntected to a TCP out / serial out node on its output side.
To read the values of the inputs of the andino boards, the node can be connected to a TCP in / Serial In node on its input side. For testing purposes, this example connects two debug nodes on the output side that print the current value of the input (either 1 or 0) as well as the pulse number to the debug screen.
(Andino X1 version with 2G or 4G modem required)
In combination with the SMS processing nodes flows can be created to do specific tasks when receiving an SMS message. In this case, if the SMS content is on or off and switches the relay on or off respectively.
This example uses the reading SMS automatically example from the Andino SMS documentation but processes the message further instead of printing it to the debug screen.
After receiving the SMS content from the Process SMS node, we use a function node modify the message payload. This function node sends out true if the message payload is on and false if the message payload is off. The function node contains the following code:
if(msg.payload == "on"){
msg.payload = true;
}else if(msg.payload == "off"){
msg.payload = false;
}else{
msg = null;
}
return msg;
The function node output is then processed by the AndinoX1 node as described in the Controlling the relays example.