This project will be a comprehensive tutorial as I learn about
Arduino, Raspbery Pi4, and Wifi-Chips.
This README will be constantly updated as I progress and learn
- Arduino
- Raspberry Pi 4 (Required) | 4GB RAM (2GB min) | 64GB MicroSD (16GB --> 32GB recomended)
- CanaKit with air cooling fan
- NodeMCU 1.0 ESP 12E Module
- PC with OpenSSH Client Windows
- Linux/MAC have a builtin Tool
- VSCode with Remote Development Enabled
Create node server with endpoints for requests from devices
Download Raspian Buster Lite
Unzip the image
The simplest method I found, that had the same desired
outcome as manual tools was balenaEtcher
Simply navigate to the .zip or the .img Raspbian file and
select the MicroSD you wish to create as a bootable
Navigate into the /boot
directory on the MicroSD
and create a ssh
file
- Connect the Power to your Pi
- Connect the LAN cable from your Pi to your home router
- This should be the same router your PC is connected to
Your Pi green LED should blink for at least 5 second
As long as your red LED is solid after this, it mean we are good to go
This is operating system specific
TODO: I will fill this section in once I have proved a reliable solution
We need to now find the IP address of the Pi in our network
First lets query our network for devices
Install nmap
sudo apt install nmap
brew install nmap
Now we need to determine our IP, but more importantly our subnet mask
In terminal type the command
ifconfig
You should get a similar output:
My CIDR is /24
based on my Subnet mask of 255.255.255.0
This shows that my ip range is 192.168.0.0
--> 192.168.0.255
Our Pi must have an IP in that range
Now we need to scan our network to find devices
In terminal type in
sudo nmap -sn 192.168.0.0/24
This will not work without a CIDR value added in
The command does not tell you what is happening
So if you press the up
arrow key it will show
you the scanning progress as shown below
We should get a table of ARP requests with a device with hostname
of Unknown
or RaspberryPi
with an IP associated.
We can now go ahead and SSH into our Pi
The default username is
pi
with a default password of
'raspberry'
In terminal type
ssh pi@
IP_ADDRESS
On my PC I type in
A prompt will display and simply type in the default password
You might be prompted to change your password. Do so now
I like to install the LTS(Long Term Support) version as they are less prone to bugs and latest release
On the pi type in
sudo apt-get install curl
then
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
Change the setup_12.x
to the desired version you required
e.g.
setup_13.x
for version 13
orsetup_14.x
for version 14
then sudo apt-get install nodejs
This will install the PPA desired version of Nodejs
check the node version
node -v
v12.13.1
check the npm version
npm -v
6.12.1
Still in the SSH connection
type the command
mkdir node-app
This creates and empty directory for your node app
type
exit
to stop and logout of the Pi
Open VSCode and press
F1
to open the Command Palette.
Search for and Select
'Remote-SSH: Connect to Host...'
Enter your ssh connection string
pi@_IP_ADDRESS_
You will be prompted for a password, so the password you have set on the pi
is what you enter here
TODO: I will fill this section in once I have proved a reliable solution
You can now edit and configure your server from here.
Select terminal
from the top menu and then select New Terminal
Open File Explorer
from the side menu
Select Open Folder
and select from the dropdown menu that pops up our
node-app
directory and press OK
Re-enter your password
We can now manage our node-app from here without having to using Vi/Vim
and this gives us a familiar interface to create and edit our app
Within the terminal on VSCode let's install git
type in
sudo apt install git
We should now create an ssh key for secure connection to github
(Also so we dont have to enter a username and password everytime)
type in
ssh-keygen -t rsa -b 4096 -C
YOUR_EMAIL_ADDRESS_ON_GITHUB"
Press enter
unless you wish to change the directory the files are generated in
You can default on the next few options by pressing enter
Once you have generated your key. Log in to your Github/Gitlab/Bitbucket account, navigate to the add ssh-key
section.
To see your ssh-key, go back to the pi terminal on VSCode and type
vim ~/.ssh/id_rsa.pub
This will show you your public key
Your ssh-key is now presented.
Using your mouse, select everything in the file
Right-click and copy.
Now paste this key into your SSH-Key on Github/Gitlab/Bitbucket
Enter the desired name. I like to use the Name of the PC + Name of the OS
XavierDesktopUbuntu1804
You have now a secure connection between your Pi and Github/Gitlab/Bitbucket