Setting Up Your First Raspberry Pi
Setting Up Your First Raspberry Pi
Learn how you can set up your first Raspberry Pi in this tutorial.
Join the DZone community and get the full member experience.Join For Free
Wow! You have a Raspberry PI in your hand, which is basically a small computer. When you have something that has the power to compute things, you can call it a computer right? Have you ever imagined a computer without math? A Raspberry Pi can do many things in real life, but the performance will be less impressive when you compare your laptop/computer with a Raspberry Pi. But it is not meant to be compared with that. There are many cases where a Raspberry Pi can do the things you want perfectly. In this post, we are not going to cover those; instead, we will be going through how you can set up your Raspberry Pi. Let’s get started then.
I wanted to connect a Bluetooth iBeacon to a Raspberry Pi, and as an initial step, I had to configure the Raspberry Pi. So I just thought to write this article while I am doing the configuration. I hope you will find it useful.
- Raspberry Pi
- SD card
- Internet connection
- Ethernet, if your Raspberry PI supports wifi, you can skip this.
Setting Up the RaspberryPi
Before you continue to this step, please make sure that you have all the mentioned prerequisites.
Formatting an SD Card
I am a person who likes to start everything from scratch, so as a first step, we are going to format our SD card. You can use the normal Format option that your Operating System offers. I always use the tool called SD Card Formatter. You can easily download the tool from the Internet. Once you have it installed, open the tool and select the SD card to be formatted.
SD Card Formatter
Installing the Raspbian Operating System
The Raspbian is the official operating system of the Raspberry Pi, which you can easily download and mount to your SD card. There are two versions of Raspbian that you can potentially install: one is the full version and the other is the Lite version. I will install the Lite version now, as it requires a smaller amount of space when compared to the full version. But remember, if you are using the Lite version, you may have to handle the SSH on your own, but it is not as tough as you might think.
You will get a zipped folder once you download the Raspbian and you should extract the same. Once you do that, you can see the image of Raspbian. Now, it is time to write this image to your SD card. To do so, we will have to install an application called Etcher. Etcher is a graphical SD card writing tool; with Etcher, you don’t even need to unzip the file to flash it to your SD card. It supports Mac OS, Windows, and Linux.
Once you have downloaded the Etcher, open the tool and select the image you want to flash and click Flash. Booom! Isn’t that simple?
Flashing Content to SD Card
Once the flashing is done, you should be able to see the Raspian OS content on your SD card.
The SSH, (Secure Socket Shell) or Secure Shell, is a protocol that gives us the provision to connect to a computer in a secure way over an unsecured network. In our case, we need to connect to our Raspberry Pi, which is connected to our LAN or WLAN network, from our laptop/computer. To enable the SSH, you need to create a file called ssh without extension. There are many ways you can do that, but I usually will just go to the drive or folder I need to create the file and perform the following command.
- D:\>echo > ssh
Connect Raspberry Pi to the Network
Once the SSH is enabled, we can eject the SD card from our computer and place it in our Raspberry Pi, and then, you need to connect your Raspberry Pi to your local network. I am going to connect the same by using a LAN cable. Once it is done, you can power on your Raspberry Pi, just plug your adapter and plug the other end to the Raspberry Pi. Please note that there are no On/Off buttons on the Raspberry Pi. Please make sure that the lights are blinking once you have connected the power source.
Connect Your Raspberry Pi From Your Computer
As we have connected our Raspberry Pi to our network already, we can just use any SSH client and connect to it easily. But remember, we need either the Host name or the IP address of our Raspberry Pi to connect to the same. To connect, I am going to use a tool called PuTTy. The PuTTy is an open-source SSH and Telnet client. You can download that from the PuTTy website.
Now, we need to find out the IP address of our Raspberry Pi; to find this, I am using a tool called Nmap. The Nmap or Network Mapper is an open-source utility for network discovery and many other things. If you want to learn more about Nmap, I recommend you to read about it here.
You can also find the IP address of your Raspberry Pi by logging in to your router gateway. To do so, you should have the credentials with you. For now, let’s stick with Nmap. Open the command prompt once you have installed the Nmap and type ipconfig, which results in all of your configuration of IP. To find the IP addresses of all the resources, you need to use the preceding command.
- nmap -sP 192.168.2.0/24
This will give you an output similar to below.
- Starting Nmap 7.70 ( https://nmap.org ) at 2018-11-15 15:32 W. Europe Standard Time
- Nmap scan report for 192.168.2.63
- Host is up (0.0020s latency).
- MAC Address: B8:27:EB:00:B3:60 (Raspberry Pi Foundation)
Here, 192.168.2.63 is your Raspberry Pi IP address. Now, you can go ahead and connect to the same by opening the PuTTy tool again. Please make sure that you have selected the option SSH and the port number is 22; for other options, the port numbers are different. Once you are done entering the details, just click on the button Open.
You will also get a security warning as you are trying to connect to a different computer, as we are sure about the IP address of the computer (Raspberry Pi) we are going to connect to, and moreover, we are the owners of the same; we don’t need to worry about it. Just click Yes. Now, it will ask you to login to your Raspberry Pi, where you need to give the username as pi and password as raspberry.
Now, you will see a message, shown below, saying that you have successfully logged in to your Raspberry Pi. You will also get a warning to change the password of the user pi.
Log in to the raspberry pi
You can either do that by using the command password or by using the raspi-config command. The rasp-config command will give you an option to set some other additional configurations too.
Configuring raspberry pi
Wow! Congratulations. Now, you have a small, lightweight, functioning computer in your hand, which is nothing but the Raspberry Pi. To summarize the things we have done in this article, we have done the following:
- Formatted the SD card
- Flashed the Raspbian OS to SD Card
- Added SSH
- Found the IP address of the Raspberry Pi
- Connected to the Raspberry Pi over SSH
- Logged in to the Raspberry Pi
- Changed the Raspberry Pi configuration
Your Turn. What Do You Think?
Thanks a lot for reading! In the next article, we will install Node JS on our Raspberry PI and connect an iBeacon to it over Bluetooth. Did I miss anything in this article? And, did you find this post as useful? Please let me know in the comments below.
Published at DZone with permission of Sibeesh Venu , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.