Raspberry Pi is more than just a board that you can load a few programs you wrote on your computer onto and have a litte fun; it is a fully fledged computer! We are looking forward to seeing all the fun you're able to have by connecting your Raspberry Pi to your RVR. The processes below can help you get on your feet, no matter what stage of Raspberry Pi use you are at!
Before you can do anything with your RVR and your Raspberry Pi, you'll need to set your Raspberry Pi up with an operating system and configure a few settings. Raspberry Pi's general setup is a very easy step by step process to follow and works just fine for getting your Raspberry Pi up and running quickly.
Getting Your Raspberry Pi RVR-Ready
Gathering Your Tools
The following commands are to be input into your terminal, which you can get to by clicking the icon at the top of your screen:
If you're not working with a freshly set up (ie the previous step) Raspberry Pi, make sure your Raspbian is up to date by running:
sudo apt update sudo apt dist-upgrade sudo apt clean sudo reboot
Next, check what versions of Python are available on your Raspberry Pi(no need to change the version) by running:
We'll be using Python3.7.0, which should be available to you if you have the most recent Raspbian, but it is always good to check 😉
Get the Code
Downloading a Zip File
This method is nice because it allows you to download the files in a way similar to how you are used to downloading anything to your computer. The disadvantage is that it is not very agile, so any time we update the code, you need to go through this whole process again....
To download a zip file of the repo, while still working on your Raspberry Pi, find the repo on GitHub (Python or Node.js/Client.js) and navigate to the green "Clone or download" button, just above the list of files on the right side of your screen. Clicking on it will yield a menu similar to the one in the photo above where, in the lower right corner, you have the option to "Download ZIP".
Once the ZIP file has downloaded, you'll be able to extract it; we recommend choosing the main "
pi" directory to load the code into, so that it is easy to access (and your code will be in the same place as ours, making it easier to follow along with our examples 😉).
Using git to get the code onto your Raspberry Pi is a bit more technical (and requires a free GitHub account), but it is much simpler to update your local code, on your Raspberry Pi, whenever we change it on GitHub (Python or Node.js/Client.js).
To use Git to clone the repo to your computer, you'll, again, use the terminal on your Raspberry Pi. This time, we'll want to
cd into the directory where you would like the RVR Raspberry Pi code to live; for example, we want to just put our code in the pi folder in our home directory and the terminal starts us in the home directory, so we just need to do:
cd stands for "change directory", which allows you to move down a level in your folder structure. If you get an error when you run this, saying that it can't be found, try typing
ls (and then pressing enter) to get your barings of where you are in your folder structure (
ls will print all the files and folders within the folder you are in). Doing
cd ../ will move you up a level in the folder structure, if you are too deep in to access the pi folder 😄
From there, you'll jump into your browser and head over to the GitHub (Python or Node.js/Client.js), where you'll navigate to the green "Clone or download" button, just above the list of files on the right side of your screen. Clicking on it will yield a menu similar to the one in the photo above where, in the lower right corner, you have the option to copy the url in the center of the menu. Once you've copied this, jump back over to your terminal and write:
git clone https://the-url-you-just-copied.com
You may be prompted for your GitHub login information, so make sure you have that handy! It is normal for nothing to display as you type your password, to protect your informaion (safety 3rd!).
Now, any time you want to make sure that you have the most up-to-date version of our code on your Raspberry Pi, you simply need to go to the root directory of the RVR code (if you put yours where we suggested, you should be in pi/raspberry-pi) and run:
Install the Dependencies
In order for our RVR code to work on your Raspberry Pi, there are some dependencies you need to install. Luckily, we compiled them all in a nice little shell script for you to use to do the install. To utilize it, we'll jump back into the terminal and
cd into the folder with the downloaded RVR Raspberry Pi code and down into the dependencies directory; if you put your code where we suggested, getting there from the home directory would look like:
To make the pi dependencies executable (make it so that it works when you run the command after this one), from pi_dependencies, run:
chmod +x pidependencies.sh
Then, you can install the dependencies (which will take a few minutes) by running:
Connecting Your Raspberry Pi to your RVR
Note: Never just kill power to your Raspberry Pi; always shut it down before removing power (unplugging it).
If the Raspberry Pi is oriented so that the USB ports face downwards, then the 3rd (black cable), 4th (yellow cable), and 5th (orange cable) pins from the top in the right column of the Raspberry Pi GPIO, in order, are ground, Tx, Rx.
On the RVR, there are 4 pins next to the USB port. If the RVR is oriented with the topper-release button facing to the right, from left to right, the pins are voltage, ground, Tx and Rx.
To connect these pins, connect ground to ground, and then Tx on the Raspberry Pi to Rx on the RVR, and Rx on the Raspberry Pi to Tx on the RVR. Your Tx and Rx (yellow and orange) wires should be crossed.
While carrying an extra keyboard, mouse and monitor around with you can make you look cool and important 👩🔬 and navigating around a bunch of wires connecting your RVR to them as you drive your RVR can be an awesome challenge 🏎️, one of the great things about the Raspberry Pi computer is that it can be accessed remotely from another device that is on the same network that it is (via SSH). This means that you can drive your RVR around in style with an entirely wireless setup (aside from the cables connecting your RVR to your Raspberry Pi)! 😎
If this sounds like a blast, follow Raspberry Pi's Secure Shell access tutorial to get set up! Note: In addition to enabling Serial Port in Preferences > Raspberry Pi Configuration > Interfaces, you want to disable Serial Console, so that the remote computer can actually reach the Raspberry Pi and send it commands for the RVR.
Once that is configured, you just need to send a few commands for the connection to go through and you'll be able to control your Raspberry Pi-controlled-RVR from your laptop, desktop, or other device!
On Raspberry Pi Monitor (before you disconnect)
The device you want to use to control the RVR must be on the same wifi network as is your Raspberry Pi. This means that you'll need to get your Raspberry Pi connected to the wifi network you'll want to use for this connection before you disconnect it from its monitor/mouse/keyboard.
Additionally, we'll use the IP address of the RVR to SSH into it, so the next thing we'll need to do is gather that information. Get the IP address of the RVR by jumping into your terminal (on your Raspberry Pi) and entering:
Your IP address is often the same, especially as long as you are staying on the same wifi network, but it can change, so, if you are having issues connecting, you can run the above command again (from the Raspberry Pi, with a monitor/mouse/keyboard plugged in) to check if there have been any changes.
Note: It is not a bad idea to run the commands below (in the terminal on your remote machine) and make sure that they work before completely abandoning your Raspberry Pi's monitor/mouse/keyboard setup.
On Remote Computer
Once you run this command, you'll be prompted for the password to your Raspberry Pi. Again, you'll get no indication that your password is being typed as you type it.
You should now get a success message and be able to work in the terminal to control your Raspberry Pi the same way you could when you had a monitor plugged into it. With this being the case, we can
cd into the repo containing the python script for the project we would like to run 😄
Once you have used
cd to get to the directory of the example you'd like to execute, you can run the code using:
Turning Off Your Raspberry Pi
Once you are finished playing with your Raspberry Pi/RVR, make sure to shut down your Raspberry Pi. You can do this using the command:
sudo shutdown now