Raspberry Pi

Hope that you should have gone through the initial raspberry pi setup as given in our previous tutorials : – )
Raspberry Pi 3 B+ have a total of 40 GPIO pins

Above image properly mentions pin configuration of the Raspberry Pi 3 B+, now explaining it briefly –

  1. Voltage Pins – Two 5V ( pin 2 and 4 ) pins and two 3V3 ( pin 1 and 17 ) pins are present on the board, as well as a number of ground pins i.e 0V ( pin 6,9,14,20,25,30,34 and 39 ) which are unconfigurable. The remaining pins are all general purpose 3V3 pins, meaning outputs are set to 3V3 and inputs are 3V3-tolerant.
  2. Outputs – A GPIO pin designated as an output pin can be set to high (3V3) or low (0V).
  3. Inputs – A GPIO pin designated as an input pin can be read as high (3V3) or low (0V). This is made easier with the use of internal pull-up or pull-down resistors. Pins GPIO2 and GPIO3 have fixed pull-up resistors, but for other pins this can be configured in software.
  4. More – As well as simple input and output devices, the GPIO pins can be used with a variety of alternative functions, some are available on all pins, others on specific pins.
    1. PWM (pulse-width modulation)
      • Software PWM available on all pins
      • Hardware PWM available on GPIO12, GPIO13, GPIO18, GPIO19
    2. SPI
      • SPI0: MOSI (GPIO10); MISO (GPIO9); SCLK (GPIO11); CE0 (GPIO8), CE1 (GPIO7)
      • SPI1: MOSI (GPIO20); MISO (GPIO19); SCLK (GPIO21); CE0 (GPIO18); CE1 (GPIO17); CE2 (GPIO16)
    3. I2C
      • Data: (GPIO2); Clock (GPIO3)
      • EEPROM Data: (GPIO0); EEPROM Clock (GPIO1)
    4. Serial (UART)
      • TX (GPIO14); RX (GPIO15)

You can also visit : for more detailed Information

Blinking LED using GPIO pin –

Step 1 – Connections

Here we will be using GPIO 21 or pin no. 40 to make the LED blink. Ground ( 0V) at pin 39 will be used to provide ground with a resistance ( 270,330,1k ohm )  in series to LED. Make connection by referring the Diagram below –

Step 2 – Writing Python code on Python 3(IDLE)

  • Open Python 3 (IDLE) in your Raspberry Pi

  • Now Create a new file. And add the code import RPi.GPIO as GPIO # Importing GPIO library
import time
LedPin = 40 # Defining pin40 as LedPin

def setup():
 GPIO.setmode(GPIO.BOARD) # Numbers GPIOs by physical location
 GPIO.setup(LedPin, GPIO.OUT) # Set LedPin's mode is output
 GPIO.output(LedPin, GPIO.HIGH) # Set LedPin high(+3.3V) to turn on led
def blink():
 while True:
  GPIO.output(LedPin, GPIO.HIGH) # led on
  time.sleep(1) # keeping it in previous state for 1 sec
  GPIO.output(LedPin, GPIO.LOW) # led off
  time.sleep(1) # keeping it in previous state for 1 sec

def destroy():
 GPIO.output(LedPin, GPIO.LOW) # led off
 GPIO.cleanup() # Release resource

if __name__ == '__main__': # Program start from here
   except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will be executed.
&nbsp; &nbsp;destroy()<code></code>

Save the code as

  • Now open the terminal and type sudo python , such command is used to run any python file via terminal
  • You can press “Ctrl+C” to stop the program.



Hi, Welcome to your first Graphical User Interface(GUI) tutorial with Tkinter in Python to control GPIO’s of Raspberry Pi. In this tutorial, you will learn how to create a simple GUI using Tkinter.

Before getting started let us explain you some terms –

What Is A Graphical User Interface (GUI) ?

GUI is a graphical desktop app that helps you to interact with the computers. Here we will be creating GUI in Raspberry Pi which will be used to interact with its GPIO.

All the apps that we run on a computer are a type of GPIO.

  • GUI apps like Sudoku, Chess, Solitaire, etc.., are games that you can play.
  • GUI apps like Chrome, Firefox, Safari, etc.., are used to surf the Internet.

What Is Tkinter ?

Tkinter is an inbuilt Python module used to create simple GUI apps. It is the most commonly used module for GUI apps in the Python. You don’t need to worry about installation of the Tkinter module as it comes with Python default.


Step 1 – Making connections

  • Make connections as shown in the diagram below.

  • Here we will control Output for pins GPIO26 (Pin 37) and GPIO20 (Pin38) and will connect anode of the LED’s to them.
  • Pin no. 39 is used to provide ground.

Step 2 – Entering Code 

  • Open the python IDLE in Raspberry Pi and create a new Python file and enter the following code.
#This code has been written by
#visit for more information

from Tkinter import * #importing Tkinter Library
import tkFont
import RPi.GPIO as GPIO #importing GPIO library

GPIO.setmode(GPIO.BOARD) #setting up the GPIO pins
GPIO.setup(37, GPIO.OUT) #setting pin37 as output pin
GPIO.output(37, GPIO.LOW) #setting pin37 as LOW initially
GPIO.setup(38, GPIO.OUT) #setting pin38 as output pin
GPIO.output(38, GPIO.LOW) #setting pin38 as LOW initially

win = Tk() #setting up window from Tk() naming win

myFont = tkFont.Font(family = 'Helvetica', size = 36, weight = 'bold') #setting up font naming myfont

def led1ON(): #defining function led1ON
print("LED1 button pressed") #to be printed on terminal
if GPIO.input(37) :
GPIO.output(37,GPIO.LOW) #setting pin37 to low
led1Button["text"] = "LED 1 ON" #text for led1Button

GPIO.output(37,GPIO.HIGH) #setting pin37 to high
led1Button["text"] = "LED 1 OFF" #text for led1Button

def led2ON():
print("LED2 button pressed")
if GPIO.input(38) :
GPIO.output(38,GPIO.LOW) #setting pin38 to low
led2Button["text"] = "LED 2 ON" #text for led2Button
GPIO.output(38,GPIO.HIGH) #setting pin38 to high
led2Button["text"] = "LED 2 OFF" #text for led2Button

def exitProgram():
print("Exit Button pressed")
GPIO.cleanup() #Quitting program

win.title("My GUI") #title for window
win.geometry('800x300') #Dimensions of the window

exitButton = Button(win, text = "Exit", font = myFont, command = exitProgram, height =2 , width = 6) #setting button naming exitbutton 
exitButton.pack(side = BOTTOM) #button position for exitbutton #commanding to button to exitProgram

led1Button = Button(win, text = "LED 1 ON", font = myFont, command = led1ON, height = 2, width =8 ) #setting button naming led1Button, y=50) #button position for led1Button #commanding to button to led1ON function

led2Button = Button(win, text = "LED 2 ON", font = myFont, command = led2ON, height = 2, width =8 ) #setting button naming led2Button, y=50) #button position for led2Button #commanding to button to led2ON function

mainloop() #commanding mainloop for starting main loop



  • Working of each command mentioned in the corresponding comment.
  • Now save the program. We are saving it as gui_project python file.
  • Now open terminal and type command sudo python and press Enter.

  • Now the window naming My GUI will open up as shown.

  • Now you can control the pins with this graphical user interface. If you have touch display, you can also use it by touch.
  • Now you can yourself explore the world of GUI from Tkinter. For more help on tkinter visit :


In this tutorial we will be Designing a Graphical panel through which we will be able to control all the 21 GPIO’s of Raspberry Pi as an Input or Output Pin.

Credits for the program – scotty3785, Original code link – click here

Step 1 – Programming the Raspberry Pi

  • Open the python IDLE in Raspberry Pi and create a new Python file and enter the following code.
#This code has been published by 
#visit for more information

import sys

  from Tkinter import *
  from tkinter import *

import RPi.GPIO as pi
import math
#import tkSimpleDialog

class LED(Frame):
"""A Tkinter LED Widget.
a = LED(root,10)
current_state = a.get()"""

   def __init__(self,master,size=10,**kw):
      self.size = size
      self.state = LED.OFF_STATE
      self.c = Canvas(self,width=self['width'],height=self['height'])
      self.led = self._drawcircle((self.size/2)+1,(self.size/2)+1,(self.size-1)/2)
   def _drawcircle(self,x,y,rad):
       """Draws the circle initially"""
       return self.c.create_oval(x-rad,y-rad,x+rad,y+rad,width=rad/5,fill=color,outline='black')
   def _change_color(self):
       """Updates the LED colour"""
       if self.state == LED.ON_STATE:
       self.c.itemconfig(self.led, fill=color)
   def set(self,state):
       """Set the state of the LED to be True or False"""
       self.state = state
   def get(self):
       """Returns the current state of the LED"""
       return self.state

## Future Functionality
##class gpioEdit(tkSimpleDialog.Dialog):
## """Dialog to be expanded to support advanced gpio features like
## - Pull Up / Pull Down Resistor Config
## - Debounce"""
## def __init__(self, master,gpio):
## top = = Toplevel(master)
## if gpio.isInput():
## title = "Edit Input: %s" %(str(
## else:
## title = "Edit Output: %s" %(str(
## l = Label(top,text=title)
## b = Button(top, text="Submit", command=self.submit)
## l.grid(row=0)
## b.grid(row=1)
## def submit(self):
## print("Submitted")

class GPIO(Frame):
   """Each GPIO class draws a Tkinter frame containing:
   - A Label to show the GPIO Port Name
   - A data direction spin box to select pin as input or output
   - A checkbox to set an output pin on or off
   - An LED widget to show the pin's current state
   - A Label to indicate the GPIOs current function"""
   gpio_modes = ("Passive","Input","Output")

   def __init__(self,parent,pin=0,name=None,**kw): = pin
      if name == None: = "GPIO %02d" % (
         ##Future capability
         ##self.bind('<Double-Button-1>', lambda e, s=self: self._configurePin(e.y))
         self.parent = parent
         self.state = False
         self.cmdState = IntVar()
         self.Label = Label(self,
         self.mode_sel = Spinbox(self,values=self.gpio_modes,wrap=True,command=self.setMode)
         self.set_state = Checkbutton(self,text="High/Low",variable=self.cmdState,command=self.toggleCmdState)
         self.led = LED(self,20)
         self.current_mode = StringVar()

         function = self.getPinFunctionName()
         if function not in ['Input','Output']:
            self.mode_sel['state'] = DISABLED

## def _configurePin(self, y):
## """Future capability to setup pull up/down"""
## new = gpioEdit(self.parent,self)

    def isInput(self):
       """Returns True if the current pin is an input"""
       return (self.mode_sel.get() == "Input")

    def setMode(self):
        """Sets the GPIO port to be either an input or output
       Depending on the value in the spinbox"""
       if (self.mode_sel.get() == "Input"):
       elif (self.mode_sel.get() == "Passive"):

    def getPinFunctionName(self):
        pin =
        functions = {pi.IN:'Input',
        return functions[pi.gpio_function(pin)]

## Future Functionality
## def setPullUp(self,pullup):
## """Defines the GPIO as having a pull up resistor so the input
## state is inverted when read
## setPullUp(True) - Pin is pulled up
## setPullUP(False) - Pin is not pulled up"""
## self.pullup = pullup

   def toggleCmdState(self):
      """Reads the current state of the checkbox, updates LED widget
      and sets the gpio port state."""
      self.state = self.cmdState.get()

   def updatePin(self):
      """Sets the GPIO port state to the current state"""

   def updateLED(self):
      """Refreshes the LED widget depending on the current state"""

   def updateInput(self):
      """Updates the current state if the pin is an input and sets the LED"""
      if self.isInput():
         state = pi.input(
         self.state = state

class App(Frame):
   def __init__(self,parent=None, **kw):
      self.parent = parent
      self.ports = []
     ## Get the RPI Hardware dependant list of GPIO
     gpio = self.getRPIVersionGPIO()
     for num,(p,r,c) in enumerate(gpio):

   def onClose(self):
       """This is used to run the Rpi.GPIO cleanup() method to return pins to be an input
       and then destory the app and its parent."""
       except RuntimeWarning as e:

    def readStates(self):
        """Cycles through the assigned ports and updates them based on the GPIO input"""
        for port in self.ports:

    def update(self):
        """Runs every 100ms to update the state of the GPIO inputs"""
        self._timer = self.after(100,self.update)
   def getRPIVersionGPIO(self):
       """Returns the GPIO hardware config for different Pi versions
       Currently supports layout 1 and 3"""
       gpio1 = ((0,0,0),
       gpio2 = ((2,0,0),
       gpio3 = ((2,0,0),
   if pi.RPI_REVISION == 3:
      gpio = gpio3
      self.parent.title('Raspberry Pi GPIO - A+/B+/2B+')
   elif pi.RPI_REVISION == 2:
        #Change this when I know the pins on RPi GPIO Version 2
        gpio = gpio2
        self.parent.title('Raspberry Pi GPIO - A/B Rev2')
   elif pi.RPI_REVISION == 1:
        self.parent.title('Raspberry Pi GPIO - A/B')
        gpio = gpio1
        self.parent.title('Raspberry Pi GPIO - Unknown Version')
        ##Assume same config as A+/B+/2B+
        gpio = gpio3
        return gpio

def main():
    root = Tk()
    root.title("Raspberry Pi GPIO")
    a = App(root)
    """When the window is closed, run the onClose function."""

if __name__ == '__main__':
  • Now save the program. We are saving it as python file.

Step 2 – Running the program and Understanding the GUI panel

  • Now open terminal and type command sudo python to run the program.
  • A panel window will open up like this –

  • From here you can set the status of any GPIO pin from the Corresponding drop down menu as Passive, Input or Output.
  • If you have selected Output, then you will have to mark or unmark the corresponding High/Low box to make the Pin Low or High
  • If you have selected Input, then the low Input will show the the Red colour and if input is high, it will show  Green Colour.

Now you can Explore the more of a GUI with Tkinter.

For more on tkinter you can visit –

In this tutorial we will be Using Ultrasonic Sensor (SR-04) with Raspberry Pi –

Step 1 – Connections

  • Here we will be using GPIO24 as Trigger pin and GPIO25 as Echo pin.
  • For this, connections will be as shown –

  • We have to connect echo pin in a Voltage Divider, made by 330Ω and 470Ω as Shown.

Step 2 – Working on Code –

  • Create a new file in IDLE and write the code as given
  • The Code for the Following will be –
#This code is Written by
import RPi.GPIO as GPIO
import time


#set GPIO Pins

#set GPIO direction (IN / OUT)

def distance():
&nbsp;&nbsp;&nbsp;&nbsp;# set Trigger to HIGH
&nbsp;&nbsp;&nbsp;&nbsp;GPIO.output(GPIO_TRIGGER, True)

&nbsp;&nbsp;&nbsp;&nbsp;# set Trigger after 0.01ms to LOW
&nbsp;&nbsp;&nbsp;&nbsp;GPIO.output(GPIO_TRIGGER, False)

&nbsp;&nbsp;&nbsp;&nbsp;StartTime = time.time()
&nbsp;&nbsp;&nbsp;&nbsp;StopTime = time.time()

&nbsp;&nbsp;&nbsp;&nbsp;# save StartTime
&nbsp;&nbsp;&nbsp;&nbsp;while GPIO.input(GPIO_ECHO) == 0:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StartTime = time.time()

&nbsp;&nbsp;&nbsp;&nbsp;# save time of arrival
&nbsp;&nbsp;&nbsp;&nbsp;while GPIO.input(GPIO_ECHO) == 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StopTime = time.time()

&nbsp;&nbsp;&nbsp;&nbsp;# time difference between start and arrival
&nbsp;&nbsp;&nbsp;&nbsp;TimeElapsed = StopTime - StartTime
&nbsp;&nbsp;&nbsp;&nbsp;# multiply with the sonic speed (34300 cm/s)
&nbsp;&nbsp;&nbsp;&nbsp;# and divide by 2, because there and back
&nbsp;&nbsp;&nbsp;&nbsp;distance = (TimeElapsed * 34300) / 2

&nbsp;&nbsp;&nbsp;&nbsp;return distance

if __name__ == '__main__':
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while True:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dist = distance()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print ("Measured Distance = %.1f cm" % dist)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Reset by pressing CTRL + C
&nbsp;&nbsp;&nbsp;&nbsp;except KeyboardInterrupt:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("Measurement stopped by User")
  • Now save this as python file as
  • Open terminal and type command sudo python and press Enter.
  • Now you will get Realtime reading by Ultrasonic Sensor on the terminal.

  • You can press Ctrl+C any time to stop the program.

Hope that you would have liked it. For any Querry, you can leave a comment below : – )




In this tutorial, we will get to learn about installing any official OS for any model of Raspberry Pi-

The officially available OS for Raspberry Pi as on Official Website

  • Ubuntu MATE
  • Snappy Ubuntu Core
  • Windows 10 IoT Core
  • OSMC ( Open Source Media Centre )
  • LibreELEC ( Just enough OS for KODI )
  • PiNet

In this, we will be installing LibreELEC in our Raspberry Pi

Hardware Required

Raspberry Pi Board ( any ), Class 10 MicroSD Card with its adapter to insert it in Laptop ( 16 GB ), Power supply to power the Rapberry Pi, Display with HDMI support, HDMI to HDMI cable, USB mouse and Keyboard.

There are 2 methods to Install the LibreELEC on SD Card –                                                                                                                                                                          – First, using the LibreELEC Installation media                                                                                                                                                                                          – Second, using the Image file and writing it on Disk using Win32 disk Imager. This can be used for any OS. Click here to jump to Method 2

Make sure the SD card is formatted

Downloading the Image for Required OS –

Visit the Official Download page of raspberry pi and choose the OS to be Downloaded –

Metho 1

Step 1 – Downloading the Required Installation Media 

  • For tutorial purpose, we will now continue with the installation of LibreELEC OS. Steps involved for the installation of other OS’s are also the same



  • Click on the required OS and it will redirect you to the official developer page of the LibreELEC. Now click on the downloads section of the website or directly click here or visit the link :
  • There you will get to download the installation media required to boot the SD card with the LibreELEC OS. For windows, click on windows link and for Linux and MacOS, click on the respected links given. We will be using windows –

  • Setup file “LibreELEC.USB-SD.Creator.Win32.exe” will be downloaded. Now install  and run the file as an administrator
  • Now Installation media will open like this –

Step 2 – Downloading and Burning Image file for the OS on SD Card

  • Now Select the appropriate file and Download it in Required folder

  • Make sure that the SD card is formatted
  • After download, select the SD card port and click on the write button. It will take few minutes depending upon your system to write OS on your SD Card.
  • After finishing, eject the SD card and insert it in your Raspberry Pi and boot it up.


Step 1 – Downloading the Image for the appropriate board

  • Download the compressed image file with extention .gz name “LibreELEC-RPi2.arm-9.0.0.img”.

  • After downoading extract .img from .gz file using WnZip
  • The extracted file will be a Disk Image file named “LibreELEC-RPi2.arm-9.0.0” having size of about 549 MB

Step 2 – Burning the Image file on SD card

  • Download the Win32 Disk Imager software ( for Windows only ) from here or click on the link : . This is used to write any image file to USB stick or SD card.
  • After download install the Win32 disk Imager software and open it.

Click on the folder icon and select the image file and the also select the drive on which it is to be written and click on write as shown below

  • A dialogue box will aper to confirm you. Click on Ok and proceed.
  • Writing will be completed in few mintes depending upon your system. Now safely eject your SD card and Inser it into the Pi. Power it on and boot it up.

Method 2 is the most basic and easiest method to write any OS to SD card. You just need Disk image file of the OS and Win32 Disk Imager to write it on SD card. Yes, it’s really simple as it seems.

Hope that you would have liked it. For any Querry, you can leave a comment below : – )


Meeting the Raspberry Pi

Hope that you should have purchased the Raspberry Pi 3 B+ starter kit. Now let’s introduce you with the Raspberry Pi

  • USB ports — These are used to connect a mouse and keyboard. You can also connect other components, such as a USB drive.
  • SD card slot — You can slot the SD card in here. This is where the operating system software and your files are stored.
  • Ethernet port — This is used to connect the Raspberry Pi to a network with a cable. The Raspberry Pi can also connect to a network via wireless LAN.
  • Audio jack — You can connect headphones or speakers here.
  • HDMI port — This is where you connect the monitor (or projector) that you are using to display the output from the Raspberry Pi. If your monitor has speakers, you can also use them to hear the sound.
  • Micro USB power connector — This is where you connect a power supply. You should always do this last after you have connected all your other components.
  • GPIO ports — These allow you to connect electronic components such as LEDs and buttons to the Raspberry Pi. The picture given below is the detailed GPIO pin representation of the Pi –


 Formatting the SD card

 Installing Raspbian with NOOBS

  •  Downloading NOOBS
    →  Using NOOBS is the easiest way to install Raspbian on your SD card. To get hold of a copy of                   NOOBS:



→ You should see a box with a link to the NOOBS files. Click on the link ( As Shown Below )


  →  The simplest option is to download the zip archive of the files

 Formatting the SD Card

If the SD card on which you wish to install Raspbian currently has any of your personal or Important      data, you should get the backup of at any other place as it will be erased after format.

  • Visit the SD Association’s website and download SD Formatter 4.0 for Windows or Mac.
  • Follow the instructions to install the software.
  • Insert your SD card into the computer or laptop’s SD card reader and make a note of the drive letter allocated to it, e.g. F:/
  • In SD Formatter, select the drive letter for your SD card, and format it.

Extracting NOOBS from Zip Archive

Next, you will need to extract the files from the NOOBS zip archive you downloaded from the Raspberry Pi website.

  • Go to your Downloads folder and find the zip file you downloaded.
  • Extract the files and keep the resulting Explorer/Finder window open.

Copying the Files

  • Now open another Explorer/Finder window and navigate to the SD card. It’s best to position the two windows side by side.
  • Select all the files from the NOOBS folder and drag them onto the SD card.

  • Now eject the SD card safely

Booting from NOOBS

  • Once the files have been copied over, insert the micro SD Card into your Raspberry Pi, and plug the Pi into a power source.
  • You will be offered a choice when the installer has loaded. You should check the box for Raspbian, and then click Install.


  • Click Yes at the warning dialog, and then sit back and relax. It will take a while, but Raspbian will install.


  • When Raspbian has been installed, click OK and your Raspberry Pi will restart and Raspbian will then boot up.

Connect your Raspberry Pi

Let’s connect up your Raspberry Pi and get it running.

  • Check whether your Raspberry Pi already has an SD card in the slot at the underside, and if not, insert an SD card with Raspbian installed (via NOOBS).
  • Find the USB connector for your mouse, and connect the mouse to one of the USB port on the Raspberry Pi (it doesn’t matter which one).
  • Connect the keyboard in the same way.
  • Look at the HDMI port on the Raspberry Pi — notice that it has a large flat side on top.

Now make sure your monitor is plugged into a wall socket and turned on

  • Connect the monitor cable to the Pi’s HDMI port — use an adapter if necessary.
  • Plug the power supply into a socket and connect it to the micro USB power port.


You should see a red light on the Raspberry Pi and raspberries on the monitor. 

The Pi will boot up into a graphical desktop as shown.


Finish the Setup

When you start your Raspberry Pi for the first time, the Welcome to Raspberry Pi application will pop up and guide you through the initial setup.

Follow the steps – Set your Country and your time zone. Then set a new password for youe raspberry pi.

You are now Done with the set up of Raspberry Pi. Now with Raspberry Pi SKY is the limit !!!!!!

Hope that you would have liked it. For any Querry, you can leave a comment below : – )

  • Hey there, in this tutorial we will be learning about how to use laptop as Display for Raspberry Pi. Laptop’s keyboard and pointer will also work with it, hence will no longer need Dedicated display, mouse, and keyboard. We will be using SSH protocol and VNC server to Interface with raspberry pi.
  • But don’t be excited, you will need a dedicated HDMI display, mouse and keyboard for initial process.
  • Before starting the tutorial, we hope that Raspbian is installed in your Pi’s SD card and has been booted already.

( If you haven’t installed Raspbian on Pi, please refer our tutorial – )

Buy our Raspberry Pi Starter Kit –

Buy our Raspberry Pi Advanced Started Kit –

Step 1 – Creating a blank SSH file in SD Card (Windows)

  • For this, eject the SD card from the Pi and insert it into the laptop using SD Card holder. In SD card we have to load a blank SSH file.
  • For this open command prompt on your laptop in which SD card is inserted and give the command “echo>I:\ssh” where I is the drive letter allotted to the SD card drive.



  • And press Enter. A blank file named ssh will be created in SD card like shown-


  • Now eject the SD card safely from the Device.

Step 2 – Enabling SSH in Raspberry Pi

  • Plug in your Pi, connect a HDMI Display, Mouse and Keyboard.

  • Open the terminal of your Raspberry Pi and write command “sudo raspi-config” and press Enter.



  • A Raspberry Pi configuration menu will open. Now use arrow keys to change between the options and press Enter on 5th option, i.e Interfacing option



  • Now, move to the 2nd option, i.e SSH and press Enter



  • A window will open to ask you to enable the SSH Server. Select YES using side arrow keys and press Enter
  • A pop-up will appear showing that SSH server is Enabled.

Step 3 – Enabling VNC Server in Raspberry Pi

  • Repeat the same steps given in Step 2. But now enter into the 3rd Option, i.e VNC in Interfacing Options menu.
  • A window will open to ask you to enable the VNC Server. Select YES using side arrow keys and press Enter



A pop-up will appear showing that VNC server is Enabled.

Now both SSH and VNC server are enabled. Now reboot the raspberry pi.

Step 4 – Downloading the required Softwares in Laptop

You will need to Download 3 softwares in your Laptop. All softwares with their download links are given below ( Please make sure that you are downloading the suitable version of the software depending on your system ) –

  1. Angry IP Scanner. Click here to download or visit this link :
  2. PuTTY. Click here to download or visit this link :
  3. VNC viewer. Click here to download or visit this link :

Download and install all the softwares in your system and then proceed to furthur steps.

Step 5 – Connecting  Raspberry Pi to Laptop

If Pi is connected to laptop with LAN cable directly then follow given steps

  • Open Network and Sharing center of Laptop ( Your laptop will not recognize the raspberry pi connected via ethernet port unless changing some settings  ) and click on the WiFi network you are connected.

  • Click on the properties and then click on the Sharing tab


  • Now click on the sharing tab



  • Check on the Box and allow other users to connect to your pc’s internet connection and in Drop down menu select Local Area connection. Click on OK after finishing.


Step 6 – Knowing IP address of  Raspberry Pi 

⇒ If External display is already connected, you can open terminal in pi and type command “sudo ifconfig” and press enter. Network details of raspberry pi will be shown

  • The IP address of the ethernet port will be shown at the place as Marked in above picture. Here it is Make note of YOUR IP address for further use. After this, you can directly jump to Next step.

 If you don’t have a display now, don’t worry. Let the Raspberry Pi be connected to the laptop via Ethernet Cable and follow steps as given

  • Open the Network and sharing centre and Now click on the Local Area Connection by Unidentified Network


  • Click on the Properties tab and then Double Click on the option of ( Internet Protocal Version 4 )



  • A Window with IPv4 properties will open. Note the IP address written in the first box and close that Window.



  • IP address will be in the range of that only ( In my case, it showing i.e IP address will be in Range of to )
  • Now Open the software Angry IP scanner and enter the Range of IP address in which you want to scan for IP ( Note : You just have to vary the last 3 digits of the IP address from 1 to 255, remaining first 9 digits will remain same. In my case 192.168.137 will remain same as it was shown in IPv4 properties )
  • After entering the proper IP range, click on the start button to scan for any alive host in that IP range



  • Software will start searching for the hosts alive in that IP range.
  • After scanning is done, search for search for host name “” and note carefully the IP address associated with it.



  • Here the IP adress is –

– Note the IP address of the RaspberryPi

Step 7 –  Connecting to Raspberry Pi using SSH with PuTTY

Open the PuTTY Software. A PuTTY Configuration window will open up.

  • Enter the IP address of Raspberry Pi at the given space.
  • Below that, make sure that SSH option is selected.
  • And then without changing any settings click on open button.



  • A PuTTY security alert window will open. Click on “Yes” to proceed.

Congratulations! Now we have established a connection between Pi and Laptop

  • A window asking for login credentials for RaspberryPi will open, You have to Enter username first, then press enter and then password for logging in to Raspberry Pi. ( By Default Username is “pi” and password is “raspberry )



  • Congratulations! Now you have entered inside the terminal of raspberry pi.
  • Now to view the Pi’s screen, type a command “vncserver”. It will turn on the vnc server of raspberry pi.
  • Also, note the VNC Desktop address i.e generated after turning on the vnc server
  • Here it is –



Step 8 –  Viewing Raspberry Pi using VNC viewer

  • Open VNC viewer in your laptop and enter the VNC address in the top bar and press enter. ( VNC address was generated in the last step )


                                  *Don’t forget to put :1,:2,:3 ( as shown in PuTTY ) as mentioned in VNC address

  • An Identity Check window will appear. Click on contine to move further.
  • In next step, it will ask for authentication
  • Enter the Username and password of Raspberry Pi for login and press on Enter.
  • This is how Rasberry Pi screen will appear.



Congratulations, you have successfully displayed the Raspberry Pi’s screen on your laptop. You can use Laptop’s Display, Touchpad and Keyboard as Output and Input devices for pi.

Hope that you would have liked it. For any Querry, you can leave a comment below : – )


In this document, we will guide you on How to Install Ubuntu MATE 16.04.2 LTS and ROS Kinetic on Raspberry Pi.



Step1: Download the image for Ubuntu MATE

Official Download Link for Ubuntu MATE for Raspberry Pi
It comes packaged as an XZ archive so use 7 Zip to extract the IMG file.


Step2: Download and Install Win32 Disk Imager
Installing an OS onto a Raspberry Pi requires you to use another computer to write the image file onto a micro SD card. You must have a way to mount a micro SD card onto the computer using either an inbuilt or external USB reader.

  • Insert your micro SD card and launch Win32 Disk Imager.
  • Select your extracted Ubuntu Mate IMG file and change the Device to the drive letter of your micro SD Card.
  • Click Write to begin the process.

  • It will take about 10 minutes to write the image


Step 3: Eject the device safely in Windows, insert it into the Raspberry Pi 3 and power it on.
  • Connect Raspberry Pi to Monitor or TV using HDMI cable.
  • Select English as the Language and click Continue.

  • Select “I don’t want to connect to a wi-fi network right now” and click Continue.

  • Select an appropriate location on the map to set the timezone and system locale and click Continue

  • Select an appropriate keyboard layout and click Continue.

  • Enter an appropriate Name, Username and Computer name and then a password. Select “Log in automatically” and click Continue.

  • The installer will now proceed to configure the system.

  • When configuration is complete you will see the splash screen below.

  • Go to the System Menu in the top left corner and select Preferences – Internet and Network – Network Connections.

  • Select “Wired connection 1” under Ethernet and click the Edit button. Click on the “IPv4 Settings” tab at the top.

  • Click on the Method drop-down list and select Manual.

  • Enter an appropriate IP Address, a Netmask in CIDR notation and the Gateway address. Enter your networks DNS server address. Click Save. Click Close to finish.



How to install ROS Kinetic on Raspberry Pi 3 (Ubuntu Mate)


The ROS framework is compatible with a short list of Linux distributions. Neither the hardware side is not better. There are just few hardware architectures compatible with ROS. Raspberry Pi is one of the development boards compatible in terms of hardware with ROS.

So, I thought to install ROS Kinetic on the Raspberry Pi 3 running Ubuntu Mate. But only a certain version of Ubuntu Mate is compatible with ROS and Raspberry Pi 3, it is about the Ubuntu MATE for Raspberry Pi 3. This is an OS version released last year and include support for the WiFi and Bluetooth modules integrated into the Pi 3.

The OS version used by me on Raspberry Pi 3 is Ubuntu MATE 16.04.2.

The ROS version that I have installed is Kinetic Kame. Kinetic was released early last year and is compatible with Ubuntu Mate 16.04. I chose this version for two reasons:

  1. it will be officially supported for the next five years;
  2. it is the most complete version after Indigo;

The first step in installing ROS on Raspberry Pi 3 is called Mate. Ubuntu Mate. The operating system is simple to install. I followed the steps on the download page, and within minutes I managed to have a Pi 3 running Ubuntu Mate.

What you find below are the steps to install ROS Kinetic on the Raspberry Pi 3.


Step1 : Go to System -> Administration -> Software & Updates


Step2 : Check the checkboxes to repositories to allow “restricted,” “universe,” and “multiverse.”

Software and Updates



Step3 : Setup your sources. List
sudo sh -c ‘echo “deb $(lsb_release -sc) main” > /etc/apt/sources.list.d/ros-latest.list’


Step4 : Setup your keys
wget -O – | sudo apt-key add –


Step5 : To be sure that your Ubuntu Mate package index is up to date, type the following command
sudo apt-get update


Step6 : Install ros-kinetic-desktop-full
sudo apt-get install ros-kinetic-desktop-full


Step7 : Initialize rosdep
sudo rosdep init
rosdep update


Step8 : Setting up the ROS environment variables
echo “source /opt/ros/kinetic/setup.bash” >> ~/.bashrc
source ~/.bashrc


Step9 : Create and initialize the catkin workspace

mkdir -p ~/catkin_workspace/srccd catkin_workspace/src


cd ~/catkin_workspace/



Step10 : Add the catkin_workspace to your ROS environment

source ~/catkin_workspace/devel/setup.bash

echo “source ~/catkin_workspace/devel/setup.bash” >> ~/.bashrc


Step11 : Check the ROS environment variables
export | grep ROS


The setup looks like in the picture 

Check the ROS installation
  1. Open a new terminal and type: roscore
  2. Open a new terminal and type: rosrun turtlesim turtlesim_node


Testing Rplidar


  • ### Create a ROS Workspace

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src

  • ### Clone the ROS node for the Lidar in the catkin workspace src dir

git clone

  • ### Build with catkin

cd ~/catkin_ws/catkin_make

  • ### Set environment when the build is complete

source devel/setup.bash

  • ### Launch demo with rviz

Check the authority of rplidar’s serial-port :

ls -l /dev |grep ttyUSB

Add the authority of write: (such as /dev/ttyUSB0)

sudo chmod 666 /dev/ttyUSB0

Start a rplidar node and view the scan result in rviz.

$ roslaunch rplidar_ros view_rplidar.launch    #for rplidar A1/A2

Start a rplidar node and run rplidar client process to print the raw scan result




Rviz will pop-up and show a background grid. The “view” from the laser scanner will be marked in red. The laser scanner is positioned at the center of the grid, it has a range of roughly 15cm to 6 meters, so you’ll be able to see everything around it on its scanning plane within that range.