VEZ Parking aims at helping users find parking efficiently
This assumes you have a Raspberry PI W and and SD card ready and will be connecting to the Raspberry PI over SSH
Setting up Linux
- Download the latest verision of Raspbian Stretch Lite
- Download balenaEtcher
- Open up balenaEtcher then select the Raspbian ISO and SD to flash to
Setting up SSH
- With the SD card still plugged in to your computer, navigate to its
boot
directory - Create and empty file with no extenstion, name it
ssh
Setting up USB ethernet Use this link
Setting up WIFI (optional)
- In the same
boot
directory create a file calledwpa_supplicant.conf
- Add these config settings, just change the
ssid
&psk
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid="Your network SSID"
psk="Your WPA/WPA2 security key"
key_mgmt=WPA-PSK
}
At this point you should be ready to connect to the hardware so long as you computer is on the same WIFI network you set on the .conf file. Plug in the SD card to the PI and then connect to it.
Note: I use a Mac so I know it will resolve the DNS correctly by using raspberrypi.local on a small network. If working with multiple devices insert the IP address after the @. Also I'm not sure what additional steps are required for PC to connect at the moment.
On a Mac
- Open up a terminal
- Enter
ssh [email protected]
On a PC
- Use Putty or Win10 SHH
- enter
ssh pi@IP
Note: Serial Connection may also be an option
At this point you should be able to connect to the Raspberry pi using SSH
sudo apt install git
Then follow this link to set up SSH keys
At this point you should be able to SSH into the Raspberry PI W and execute comands.
- Copy the download link for the latest LTS ARMv6 Node.js binary from here
- Execute the following commands to download, extract, and install
wget https://nodejs.org/dist/vX.X.X/node-vX.X.X-linux-armv6l.tar.xz # use the download link copied earlier
tar -xf node-vX.X.X-linux-armv6l.tar.xz # vX.X.X should be the version you dowload above
sudo mv node-vX.X.X-linux-armv6l /usr/local/node
cd /usr/bin
sudo ln -s /usr/local/node/bin/node node
sudo ln -s /usr/local/node/bin/npm npm
node -v # Verifying that the Node.js install worked
npm -v # Verifying that the npm install worked
Now that we have node and npm installed we are able to install other JavaScript packages to help get us up and running. There are three we need to get the HC-SR04 to work:
- johnny-five (JavaScript platform for Robotics & IOT)
- raspi-io (helps johnny-five work with raspberry pi)
- pi-io (helps johnny-five use proximity sensors on the pi)
Note: use these commands if starting from scratch ()
mkdir project-folder # make a folder to work in
cd project-folder
npm install johnny-five raspi-io pi-io
Note: use this if downloading code from vez repo (currently no code exist so use above method to start)
git clone https://github.com/lelopez-io/vez-parking-iot.git
cd vez-parking-iot.git
npm install # this installes the packages in package.json
Note: we must restart the PI after installing raspi-io
While in the project folder create a new file using the command touch proximity.js
then save the following code to that file.
Note: we are only using pi-io in this case since raspi-io thows an error when trying to use the .Proximity function.
const five = require('johnny-five');
const PiIO = require('pi-io');
const board = new five.Board({
io: new PiIO()
});
board.on('ready', () => {
const proximity = new five.Proximity({
controller: PiIO.HCSR04,
triggerPin: 'GPIO18',
echoPin: 'GPIO24'
});
proximity.on("change", function() {
console.log("cm: ", this.cm);
});
});
Note: all files that access GPIOs must be ran using sudo
sudo node proximity.js