Hierarchy: Orange Pi
In the previous article on Orange Pi Zero, we showed GPIO pin control using the WiringOP library. For a simple task, this library will serve you well, but for more complicated projects, you would be bothered to get rid of everything. If you have Arduino available, you can connect it to the USB port and take advantage of it. For Arduino, libraries have been written for each integrated circuit you can remember. Therefore, you only have to solve a single problem. How to communicate with Arduino.
We will need the following components:
You can see the USB port in the lower left corner. Connect any Arduino to it. Arduino will automatically appear in the serial port list. You can verify this with the command
ls /dev/ttyA*. If you have the sketch that communicates over the serial port in the Arduino, you can check whether Arduino is sending something using the command
cat /dev/ttyACM0. If you have everything well connected, you should see the same results as in the following picture.
For further communication with the Arduino we will use Node.js. All the necessary information on the use of Node.js on Orange Pi Zero is explained in the previous articles.
We will use the source code I wrote to the previous articles. First, from the GitHub, clone the arduinoslovakia directory with the command
git clone https://github.com/roboulbricht/arduinoslovakia.
Then with command
cd arduinoslovakia/node.js/arduinoserialtest2/node move to the source code directory for Node.js and install the packages with the command
npm install. For the ARM platform, packages are not ready, but Orange Pi Zero compiles them directly from the source code of the
You can then test the list of serial ports with command
node list.js. Our Arduino will appear on
/dev/ttyACM0. In addition to this port, we see three more ports, but they are not interested us now. These ports are on a 26-pin header.
Finally, use the command
node index.js run a program that offers you a selection of the serial port. After selecting the port, the content from Arduino will be posted to the console.
You can write your own program for Arduino and Node.js to control the Arduino. My example for Node.js was just a non-visual, but you can write a webserver in Node.js to control Arduino and Orange Pi Zero through your Internet browser. This manual has been written for Orange Pi Zero, but it will also work well on any Orange Pi model.
The source code is located on the GitHub server.