- Raspberry Pi Initial Setup
- SSH Setup for Windows
- Download the GitHub Repo
- Download Required Python Packages
- Connect the Sensors
- Raspberry Pi 3b+
- Micro SD Card
- Pi Traffic Light - Amazon
- Ultrasonic Distance Sensor HC-SR04 - Amazon
- PIR Motion Sensor HC-SR501 - Amazon
- Jumper Wires
- Resistors
- Raspberry Pi 3b+
- Micro SD Card
The steps below describe how to set up a Raspberry Pi for the first time, and enable SSH. SSH allows you to remotely connect to the Raspberry Pi from another computer. This allows you to develop/troubleshoot on your Pi without needing to connect keyboards and monitors.
For easy installation, use the NOOBS package from the Raspberry Pi website.
For more advanced installation, follow the instructions here.
After saving to the SD Card, put the SD card into the Raspberry Pi and boot it. Follow the on-screen instructions for installing Raspbian and configuring your WiFi, timezone, language, etc.
First, check the default IP address settings for your network. Boot the RPI, open the terminal and type ip a
.
The IP address of your RPI should be listed under the eth0 header (if connected to ethernet), or the wlan0 header (if using WiFi). It should look something like this: 198.168.0.XXX. The default IP format is the first three sets of numbers. For many networks, it will look like 198.168.0.XXX. On my network, the last "0" is a "7" (i.e. 198.168.7.XXX). When you're following the instructions in the link below, be sure to use your network's standard IP format. For example, the instructions below assume the IP is 192.168.0.XXX. However, in my case, I need to use 192.168.7.XXX.
The official instructions for setting up a static IP address are here.
Be sure to follow the "Testing" instructions in the above link, by rebooting your Pi and confirming the correct IP address is set.
The latest Raspbian distributions, by default, do not allow for SSH. To enable it, do the following:
- Type
sudo raspi-config
in a terminal. - Select
Interfacing Options
. - Select
SSH
- Select
Yes
>Ok
>Finish
The above is adopted form the official instructions here.
First, confirm that the Pi can be reached over the network. Type cmd
into the program search bar, and open the Windows command line.
In the command line, type ping 198.168.0.XXX
, using the static IP address you selected in "Step 2" above. If you get a network response, then the Pi can be reached.
Next, Download PuTTY and WinSCP.
PuTTY allows us to SSH into the Pi. WinSCP is a file transfer program that allows us to transfer files to the Pi remotely over the home network.
Open PuTTY, and put the static IP you set up in the Host Name (or IP address)
box (do not include the /24
at the end of the IP you set up... e.g. if you followed the official instructions exactly, you would enter 192.168.0.2
here). Keep the port as 22. Select SSH
as the connection type.
To save the IP address for future reference, you can enter a name under Saved Sessions
and click Save
. Then, whenever you open PuTTY, you can select the name, click Load
and then Open
.
Click Open
to estable an SSH connection. The default username is pi
, and the default password is raspberry
. If you changed the password on the Raspbian setup, be sure to use that password. If the machine connects without an error, then SSH is set up correctly.
Open WinSCP, and enter the static IP you used above, keep the Port as 22, and enter the username pi
, and either the default password raspberry
or the new password if you changed it. Click Save
if you'd like to save the IP address for future reference. When you connect, you should be able to see the files and folders on the Pi. You can use this to transfer files onto the Pi remotely.
Open PuTTY, and establish an SSH connection with the Pi.
To download the scripts from this repository, in the PuTTY SSH window, type the following:
git clone https://github.com/reowen/Park-Assist.git
This will create a folder called "Park-Assist" in your home directory with all of the scripts for this project.
The traffic light uses the RPi.GPIO library. To install this on your Pi, use PuTTY to SSH into the Pi. After connecting, type the following:
pip install RPi.GPIO
You'll see "Successfully install RPi.GPIO" if it worked.
The official documentation for the Python modules for the light is here.
The official connection documentation is here. For the Pi 3B+, we connect to GPIO pins 9, 10, and 11, and a corresponding grounding wire. To do this position the Pi with the HDMI plug facing towards you (so the USB plugs are to the right on the board, and the GPIO pins are at the back). Then, on the front row of GPIO pins, count 7 pins from the right, and place the light to the left of the 7th pin, with the lights pointing away from you. If that description is confusing, refer to the GPIO pin reference image above, and play around with positioning the light until you can get it working.
For wiring and mounting the light in my garage, instead of directly placing the lights on the GPIO pin board, I used female-to-male jumper wires and mounted the lights through the wires.
A diagram of the motion sensor is here (viewed from the bottom):
Run jumper wires, connecting the GND (ground) pin on the sensor to pin number 6 on the Pi, connect the power sensor pin to pin #4 on the Pi, and the output pin (middle pin on the sensor), to pin #8 on the Pi (GPIO14). See the pin reference image above.
Some more documentation on connecting this sensor can be found here.
Some good info on connecting the sensors is here.