Credit: UCTRONICS
The purpose of this project is to replace the C language UCTRONICS Raspberry PI Robot Car server that controls the hardware by a Node.js implementation.
The requirements are:
- With the exception of bluetooth remote control, all original features are functional.
- Control over the internet using secure connection is possible.
- Focus is on the server running on Node.js (Although a basic Vue.js UI is provided for demostration purposes).
- Compatibility with UCTRONICS mobile app is not required.
- Open source, of course.
The instructions below assume you already setup your Raspberry PI with Debian, and the following software is already installed. In parenthesis the versions this project has been tested the last time.
- Debian (jester)
- git (2.20.1)
- npm (6.14.5)
- node (v12.8.2)
- vue-cli (4.4.6)
Block diagram
In the block diagram above the green boxes represent the implementaton of this project.
The MJPEG streamer project is used to stream the camera module video feed. Follow the complete instructions in the following link.
MJPEG-Streamer Install & Setup
In order to access the Robot Car application from the internet get a domain name. DuckDNS will provide a duckdns subdomain resolving to your Internet Service Provider IP address.
Once the domain name resolves to your home router external IP address, the router needs to forward traffic on ports 80 and 443 to your Raspberry Pi ip address. The instructions depends on your router. Information, very likely, is available by searching for "port forwarding [your router brand and model]"
In this project we are using NGINX as web server and reverse proxy.
We need a valid certificate to establish a secure connection to the server running on the Raspberry PI.
The instructions below are from certbot.eff.org
sudo apt-get install certbot python-certbot-nginx
sudo apt-get remove apache2
sudo apt-get install nginx
sudo systemctl start nginx
Open a browser and enter: http://raspberry-pi-address
sudo certbot certonly --nginx -w /var/www/example -d example.com -d www.example.com
Note: replace example.com by your domain
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 --nodes
Create a soft link from /etc/nginx/sites-availabe to nginx.conf (from the repo)
cd /etc/nginx/sites-available
sudo ln -s /home/pi/git/pi-robot-car/nginx.conf example.com
Make the site enabled
cd /etc/nginx/sites-enable
sudo ln -s /etc/nginx/sites-available/example.com example.com
https://example.com
To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew all of your certificates, run "certbot renew"
git clone [email protected]:wdmartins/pi-robot-car.git
cd pi-robot-car
npm install
npm start
Use this option for development purposes. Using this option Vue.js starts hot-reload server and you can access it by poiting your browser to the address shown on the screen after compilation finished. Keep in mind when running in this mode NGINX is use only as reverse proxy for the application to established as websocket connection to the back end server.
npm run serve
Use this option for production purposes. Using this option NGINX works as secure webserver and the application can be accessed from the internet by pointing your borser to https://[your duckdns address]
npm run build
./setup.sh
npm run lint