For this installation we will be setting up two VMs, one that has a GUI (Graphical User Interface) and one without a GUI. The VM without a GUI will run the P5.SerialServer as well as an Apache Web Server. The VM without a GUI will access the Web Server though a web browser. Both VMs will be running the CentOS 7 distribution although the VM with a GUI could be running any Linux distribution that has a GUI.
In this guide I will show you how to install VirtualBox, CentOS 7 on both of the VMs, Node.js, P5.SerialServer and a HTTPD Apache Web Server on the VM without a GUI.
To download VirtualBox go to:
Choose the OS host that you are using. For this example, I am on a mac running the Mojave OS so I will choose the OS X hosts.
Drag the .dmg file to your desktop for ease of use, then double click the icon to start.
Now double click the package icon to start the installation process.
Click Continue. If prompted enter the username and password of the account you are signed into.
Go back to the .dmg file and double click the Applications folder icon
Double click the VirtualBox icon to start VirtualBox.
We will now create a NAT Network where both VMs will be able to communicate with one another.
Now go to your VirtualBox and select the preferences tab
Select the Network tab
Click the green NIC with the plus to create a NAT Network.
If you have previously created a NAT Network then you should either rename it or edit the IP address of the subnet by pressing the green NIC with the orange gear. The default settings for the NAT Network will be sufficient enough for this guide to work
Click OK to continue.
To install the ISO for both the Terminal Only VM and the VM with the GUI go to:
Then select the DVD ISO
Select any of the links in the top section. Some links may take longer than others so try the different mirrors for different speeds.
Drag the .iso file to your desktop for ease of use.
At the VirtualBox welcome screen click the New tab to create the VM.
Enter the name of your VM. If you enter CentOS then the Type and Version should auto update to Linux and Red Hat (64-bit). Click Continue.
Select the amount of memory (RAM) you want your VM to use
Click Create to create a virtual hard disk.
Select a Hard Disk File Type. VDI is suitable for this installation. Then Click Continue.
Select the storage on physical hard disk type. Dynamically allocated is suitable for this installation. Then Click Continue.
Select the size and location of the hard disk. 8GB is more than enough for just the Node.js installation, if you are planning to do more with this VM then expand the size of the hard disk. Then Click Create.
After the VM is created select the Network option.
Under the Adapter 1 header select NAT Network in the Attached to: drop down list. The Name should update to the Nat Network you created previously.
Under the Advanced arrow set Promiscuous Mode: from Deny to Allow All. Then click OK to finish.
Now Start the VM.
After pressing start you will be prompted to select an .ISO file. Click the file folder to find the .ISO. From the previous steps, the .ISO file is on the desktop.
After selecting the file press Start to continue.
Now instead of going through those steps again we can just create a clone of the VM. This clone will have the right parameters to work for the CentOS with a GUI. If you want to create the VM again follow Step 2-4.
Rename the GUI VM to whatever you wish. Then click Continue.
Select a Clone type then continue. If you want to preserve disk space a Linked Clone would help but I will be using a Full Clone.
Now go back to the running VM and use the arrow keys to select the Install CentOS 7 option, then press enter to Continue.
Wait for the installer to launch the select your language options. Then click Continue.
Select the Installation Destination tab.
Nothing needs to be done in this section so click done.
Then select Begin Installation.
Click on User Creation to create an Administrator user.
A root password does not have to be set if the User Account is an administrator. Make sure the check box is marked and then fill out the Full Name, User Name and Password.
Wait for the installation to be completed then click Reboot to get into the OS.
Enter the username and password you just made in Step 7.
Then connect the Arduino Uno to your host machine and then to your VM.
Go back to the VM welcome screen and start the GUI VM.
Now follow all the parts in Step 6 but DON'T press Begin Installation. Instead click on the Software Selection tab.
Then select the GNOME desktop to create an environment with a GUI. Then click Done to continue.
Now select Begin Installation.
Now follow Step 7.
Click the License Information tab and accept the License.
Make sure the check box is marked and then press Done.
The click Finish Configuration.
Sign in to your account.
Select your language and the click Done.
In the CentOS VM without a GUI, you first need to enable the dhclient by entering the following command in the terminal:
This will allow your VM to get an IP address and internet connectivity
Then update the OS by entering:
sudo yum -y update
Install the repository by entering first:
sudo yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_10.x | sudo -E bash -
Now install Node.js by entering:
sudo yum install -y nodejs
If Node.js installed correctly then the following commands should produce the same results.
In the terminal application type the following to install SerialPort:
sudo npm install serialport --unsafe-perm -g
Wait for the download to complete.
In the terminal application type the following WS:
sudo npm install ws -g
Wait for the download to complete.
In the terminal type the following P5.SerialServer:
sudo npm install p5.serialserver --unsafe-perm -g
Wait for the download to complete.
Change your directory to the following by typing:
To find which port the Arduino Uno is connected to. The device should end in ACM.
To find the IP address of this VM.
In a text editor (I will be using nano) open the sketch.js file and change the port name and SerialPort to what is listed above.
sudo nano sketch.js
Use the command below to install nano.
sudo yum install -y nano
Exit and Save.
Then edit the index.html file and remove the ../../lib/ from the fifth line by entering:
sudo nano index.html
Save and Exit.
To access this P5.SerialServer you will have to host the p5serial on a Web Server.
Install HTTPD by entering:
sudo yum install -y httpd
After installation allow ports 80 (http) and 8081 (p5serial) through your firewall
sudo firewall-cmd --add-port=80/tcp --permanent
sudo firewall-cmd --add-port=8081/tcp --permanent
sudo firewall-cmd --reload
Then start and enable the HTTPD service
sudo systemctl start httpd
sudo systemctl enable httpd
Then change into the html directory by using the command:
Now copy the echo folder into the current directory by entering:
sudo cp -r /usr/lib/node_modules/p5.serialserver/examples/echo .
Be sure to include the period.
Then copy the p5.serialport.js file into the echo folder using the following command
sudo cp /usr/lib/node_modules/p5.serialserver/lib/p5.serialport.js echo
Once in the echo folder type the following to start the p5.serialserver:
The server should launch.
If you are not already in the echo folder enter the command:
Now in the VM with a GUI, start a terminal and enter
This will enable your VM to get an IP address and internet connectivity
Start up the Firefox browser and enter the IP address of the VM with no GUI. If your web server is running you should get this screen.
Then add /echo at the end of the IP in the search bar and you should have the P5.SerialServer page updating
After your installation of Node.js an error may occur or an installation might go wrong and that could cause your Node.js to not work as intended. Rather than uninstalling and reinstalling Node.js or making a brand new VM, we can create Snapshots of the VM after the Node.js download and now if an issue arises you can restore your VM to a previous state.
Make sure the VM that you want a snapshot of is shutdown. In the Vm without a GUI enter:
Now go to the VirtualBox Manager and click on the three dotted list and then select Snapshots.
Now select Take to take a Snapshot.
Choose a name for your Snapshot and the Press OK. I will be keeping the default.
Now if you need to restore back to the Snapshot created then select the name of the Snapshot and then press Restore.
Now that you have a Snapshot (and you know how to create them) in place you can alter the VM and if any problems occur you can restore back to a previous Snapshot.