Raspberry Pi or Raspberry Pie

Shay Pema
7 min readJun 5, 2021

When I first heard of raspberry pi in computer terms, I thought it literally meant a raspberry pie that you eat. I had no idea that this small circuit board could be used as a CPU (Central Processing Unit) for a desktop computer or to program a robot.

Now let's dive into the raspberry pi circuit board.

There are many disadvantages and advantages to using raspberry pi for a desktop computer or for a project you are currently working on.

Advantages

One of the main pros is that it can process all types of codes. That is what makes this board very special. Whether it's python, java, or javascript, the raspberry pi can do it all.

Another advantage of this board is that it is basically a portable computer. Although it may be slower than your typical Macbook Pro/Air or Windows PC, it still can function very well. To make it a portable computer, all you need to do is write and download raspbian (raspbian on your SD card which should come with your raspberry pi.

The last main advantage is the speed of the processor. Compared to Arduino which has a controller, the raspberry pi uses a 1.6 GHz processor for the newest version (4B). It does get slower as you progress down the versions but for the most part, it remains faster.

Disadvantages

The raspberry pi board is very susceptible to overheating. Because it does not come with a cooling man or heat-sinks, it takes about 6–7 hours of continuous work to reach 158 degrees Fahrenheit.

The second con is that it's missing a graphics processor. Because it lacks a graphics processor, it must use the main processor to do all the tasks it needs to do which is very inefficient. For people who are into video editing, photo editing, or gaming, a raspberry pi desktop is not the way to go.

The last con is that when using a raspberry pi desktop (mentioned earlier), the computer will be very slow and more difficult to use. Opening too many tabs will cause the board to slow down, and even downloading Netflix or Amazon will require extra codecs.

My Project

Now, let's talk a little bit about my project. My project was a raspberry pi surveillance robot. I used these different parts: raspberry pi 3B, USB camera, power bank, robot chassis with the motors, nine-volt battery, L298 motor driver, female to female jumper wires, soldering iron, and tape.

These parts are essential in running the live stream camera and moving the robot.

Setting Up the Raspberry Pi

The first step in this project was writing on the SD card of the raspberry pi. To do this, you can download Raspbien Pi Imager (check the image below). This will allow you to write on your SD card which will help you in setting up a raspberry pi desktop.

Next, we need to enable SSH on the board, which is where we set it up into a desktop. Make sure the HDMI cable is connected to the monitor and the raspberry pi. Also, connect your keyboard and mouse.

Once you have successfully opened your new raspberry pi desktop, go to the setting menu and enable SSH. SSH stands for secure shell protocol and enabling it means that you can transfer files from one computer to another. In this case, we want to transfer code from our computer to the raspberry pi.

Logging in to PUTTY

Now to actually program the raspberry pi, I used PUTTY Configuration. The commands for running the live stream camera and moving the robot chassis are, of course, different but can all be done through PUTTY.

To log in to PUTTY, you will first need the IP address of your raspberry pi. There are many different ways to do this, but I’ll tell you how I did it. First, plug in an ethernet cable to your raspberry pi and connect it to your main wifi box. Once this happens, you must download Fing. Fing will show you all of the items connected to the wifi network. Locate the raspberry pi device, and it will show you the IP address for it.

Once you do, that type the pi's IP address into the box and make sure SSH is enabled. Then hit enter, and it will take you to a screen that says login and password. The log-in is always pi, and the password, unless you change it, is raspberry.

Finally, this is where we get to the coding for the live stream camera!

Running the Livestream

The very first thing you need to do for this is updating the actual program. If it is not up to date, then certain things will not work the way that they should. To do this you must type sudo apt-get update.

The next step is downloading the software that we are going to use to run the live stream with the camera. The software we are using is Motion. Although many other programs can be used, Motion is one of the easiest. To download motion this using the PUTTY configuration, you would type sudo apt-get install Motion.

Next, connect your USB camera to the raspberry pi and type lsusb in PUTTY. If you see the name of your webcam after you type in lsusb and hit enter, then it is connected.

If you do not see its name then your camera is not compatible with raspberry pi (the name should be under the first line of code).

Next, we have to edit a part of the main motion configuration file. So to access the file we need to type sudo nano /etc/motion/motion. Close to the top of the file, you will see something that says daemon. Make sure that if it is set to off that you turn it on. The daemon runs all the background programs but not the main ones so it needs to be on to efficiently run these applications.

Next scroll to #Live Stream Sever and look under the part where it says stream_port. The value there will either say 8081 or 8080. Change that number according to the port number.

You must also turn stream_host to and webcontrol_local host off to run the live stream camera.

Depending on what type of camera you have (quality-wise) you can change the brightness, max framerate, minimum framerate, and frames per second.

Once you are done click control-x to save all of the changes you made.

Now to restart the motion software type sudo service motion restart. After that typing sudo motion will start the camera live stream.

To see the live stream you want to type your IP address colon 8081 or 8080 depending on which port was used.

Assembling the Robot

After I ran the live stream I assembled the robot. Here is a picture of what connecting the raspberry pi to the L298 motor driver.

If the wires are not connected to slots 6, 7, 11, 13, and 15 then the robot will not function properly. This is because the code that I used for running the robot chassis is aligned with these slot numbers.

After connecting the wires from the raspberry pi to the L298 motor driver, connect the power bank to the raspberry pi and connect the battery to the motor driver. Attached down below is what the final product of the project should look like.

Programming the Robot Chasis

Next, I used the code to run the robot chassis. Basically, I copied this code (check the image below) into IDLE 2 in my raspberry pi desktop programming tab.

Make sure that the code that you copy is saved to the videos section and is named pi_robot. Once it is saved to the video section, to run the program first type cd Videos. This line will access the Videos file of your computer.

Next, you want to type python pi_robot.py. This means that the PUTTY will access the file pi_robot using python. After typing this command, you should control the robot using the arrow keys on your keyboard.

Takeaways

  1. Raspberry pi can be used as a desktop computer but has its advantages and disadvantages.
  2. You can use PUTTY instead of the terminal inside of a raspberry pi desktop.
  3. Motion is software that can be used and downloaded in PUTTY to run a live stream camera.
  4. PUTTY is also able to help you control a robot chassis if you have an l298 motor driver board.

Shay Pema is a 9th-grade student at Cerritos High School. Feel free to reach out to him on LinkedIn!

--

--