Raspberry Pi IoT Server

In the following steps we will create a Rasbperry Pi IoT Server with Nodejs, Express, Socket.io, Nginx, PM2 and Dataplicity as a secure VPN tunnel.

Pic

Hardware - I have no affiliation find cheapest price

Raspberry Pi
IoT Relay

Overview

Video

Download OS and Boot Pi

Video
https://www.raspberrypi.org/downloads/

Install NodeJS

Video
https://www.nodesource.com/
https://github.com/nodesource/distributions

GPIO Test

Video

Clone Git Repo / Test LED and Relay

Video

git clone https://github.com/prichardsondev/RaspberryPiServer.git
cd RaspberryPiServer
npm i
node app.js

Install NginX & Test

Video

 sudo apt-get install nginx
 sudo rm /etc/nginx/sites-enabled/default
 sudo nano /etc/nginx/sites-available/node

server {
    listen 80;
    server_name localhost;

    location / {
        proxy_set_header   X-Forwarded-For $remote_addr;
        proxy_set_header   Host $http_host;
        proxy_pass         "http://127.0.0.1:3000";
    }
}
 sudo ln -s /etc/nginx/sites-available/node /etc/nginx/sites-enabled/node  
 sudo service nginx restart

Install Dataplicity.com

Video
https://www.dataplicity.com/

Install PM2

Video

 sudo npm install pm2 -g  
 pm2 start app.js  
 pm2 startup
 

run script from 'pm2 startup'

pm2 save