Control DC Motor with Raspberry Pi 4 using Python

Hello friends, I hope you all are doing well. Welcome to the 9th tutorial of our Raspberry Pi programming course. In the last chapter, we generated a PWM signal from our Raspberry Pi to control the brightness of an LED. We also studied different functions used in Python to perform PWM. In this chapter, we'll get a bit advanced with PWM and use it to control the speed and direction of a DC motor with the help of a motor driver IC.

To control the speed & direction of the DC Motor, we will:

  • Design a Circuit Diagram.
  • Write Python code.

Components Required

We will use the following components to control the DC motor speed:

  • Raspberry Pi 4.
  • DC Motor.
  • Motor driver IC(L293D).
  • Breadboard.
  • Jumper wires.

Controlling DC Motor speed with Raspberry Pi 4

  • In order to control the DC motor with any microcontroller, we need to use the motor drivers i.e. L298, ULN2003 etc.
  • In our project, DC motors are controlled by the L293D motor driver, an intermediate integrated circuit.
  • Raspberry Pi 4 will send the signal to the motor driver, which in turn will control the speed or direction of the DC motor.
  • To regulate the DC motor's speed, we will write Python programs in Raspberry Pi, to control the GPIO pins and will send signals to the motor driver IC.

Control DC motor using PWM

Pulse Width Modulation(we studied in the previous tutorial) will be used to regulate the speed of a DC motor. A quick recall, a  PWM signal is used to generate a variable voltage at the output depending on the duty cycle. The duty cycle refers to the length of time during which the signal is kept at a high level and determines how much power is given to the signal.

As a result of the PWM signal, the speed of a DC motor can be controlled in a non-resistive or non-dissipative manner.


Motor Driver L293D

  • We will use the L293D Motor driver, it will get the signals from Raspberry Pi through its GPIO pins and will control the motor.
  • The Raspberry Pi's low-current signal is amplified by this motor driver into a high-current signal used to drive a motor.

L293D Pinout

The L293D pinout is shown in the following diagram.

  • As you can see in the L293D pinout, it has 4 input/output channels.
  • In order to control the speed of 1 DC motor, we need to use 2 channels of L293D.
  • So, a single L293D IC can control 2 DC motors at a time.
  • It also has 2 Enable Pins and are used as master control pins for these channels.
  • Enable Pin 1 is used to control the first two channels(left side), while Enable Pin 9 is used to control the last two channels(right side).
  • Vss(Pin16) is the reference voltage pin, it should be provided with 3.3V or 5V. It's the reference to the signals provided at Input pins. In our case, we are using RPi4 and its GPIO pins provide 3.3V, so we will give 3.3V at Vss pin.
  • Vs(Pin8) is the source voltage pin, normally a 9V or 12V power is applied at this pin. The voltage at Vs pin is provided to all the output pins by the L293D.

Why do we need a Motor Driver L293D?

The microcontrollers provide either 5V or 3.3V at their GPIO Pins, in the case of RPi4, it's 3.3V. The current rating of these GPIO pins is normally 10-50mA, which is quite low and it's justifiable as their sole purpose is to send the signal.

Now if we talk about DC Motors, they normally operate at 5V-48V and have a current rating from 100mA to 10A. So, we can't connect a DC motor directly to a microcontroller's pin. We need a motor driver to amplify the voltage and current.

Moreover, DC motors also produce back EMF, which may burn the GPIO, so in order to protect the board, we should have a motor driver in between.

L293D Working

  • The PWM signal generated by the Raspberry Pi will be provided to Input1 and Input2.
  • If Input1 is at a High state, while Input2 is at a LOW state, the motor will rotate in one direction, let's say clockwise.
  • If we changed the states i.e. Input1 at a LOW state, while Input2 at a HIGH state, the motor will change its direction and will rotate in the anti-clockwise direction.
  • The motor won't run if you simultaneously supply highs or lows to both inputs.

Controlling DC Motor with Raspberry Pi4

  • As shown in the above figure, we will use three GPIO pins of Raspberry Pi 4, connected to Enable1, Input1 and Input2 of the L293D motor driver.
  • Vss Pin of L293D is provided with 3.3V from RPi4.
  • We will also connect the GND of L293D with that of RPI4(Pin6).
  • Vss of L293D is provided with +9V from the battery and that will be provided at the output and will control the motor's speed.

Python Code for DC Motor Speed Control

We have designed the circuit in the above section and now it's time to get our hands on Python code. We will be using the Thonny IDE in Raspberry Pi 4.

In this code, we will write a simple code to drive the motor forward for 5 seconds, then backward for another 5 seconds at a 50% duty cycle. You can alter any of these values as you see fit.

I will explain the code line by line for better understanding:

  • To use the GPIO pins, you must first import the GPIO module using the import command.

  • We also need to include a sleep instruction, required while making changes to the PWM duty cycle or the direction of the motors.

  • To access the GPIO pins, you'll first need to put them into board mode. To do so, run this command.

  • As we need to send PWM signals to the motor driver, so we need to make these pins OUTPUT, using the below command:

  • Let's create a PWM object by using the PWM GPIO pin, using the below command:

  • LEt's start the PWM object with a 0% duty cycle.

  • Initiating a clockwise movement of the motor by making the first pin HIGH and the second one LOW.

  • Setting the 25% duty cycle to the PWM object:

  • Setting the Enable Pin HIGH:

  • Delay of 5 seconds:

  • Enable Pin is set to LOW to stop the motor.

  • Reverse the motor's polarity:

  • By setting the duty cycle to 50%, the motor will now run at 50% speed in the opposite direction.

  • The enable pin should be set to HIGH.

  • Keep the code running for another five seconds:

  • Reset the Enable pin to turn off the motor.

  • After that, clean up and reset the GPIO channels after disabling the PWM object. It's always recommended to clean up the GPIO pins so that the next program could use them without getting an error, saying the pin you selected is not available to use.

  • If you followed all of the steps correctly, your engine will run for five seconds in the forward direction and then for five seconds in the reverse direction.

  • A variable whose value changes with each iteration of the loop is called an iterative variable. You may adjust the duty cycle such that your motor's speed grows in steps as you observe it.

  • Now as we lowered the duty cycle to 25%, the DC motor speed gets lowered as well.

  • Here's the complete code and the hardware images:

Application of DC motor control systems

DC Series Motor:

Motors from the DC series are commonly employed in electric locomotives and fast transit systems, as well as trolley vehicles. Because of their high starting torque, they're also found in cranes, hoists, and conveyors.

DC Shunt motor:

The use of DC shunt motors in rolling mills is due to their ability to accurately manage speed. They're used for driving lathes at a fixed speed, used in reciprocating and centrifugal pump drives, and also used in blowers, machines, and reciprocating pumps.

Synchronous Motors:

They can be found in a wide variety of machinery, including elevators, conveyors, heavy planers, shears, and punches, as well as intermittently high torque loads and air compressors.

Conclusion

Congratulations! You have made it to the end of this tutorial. We have seen how PWM is used with a motor driver IC to control a DC motor's speed and direction. In the next tutorial, we will have a look at how to Control a Stepper Motor with Raspberry Pi 4 using Python. Till then, take care. Have fun !!!

Create PWM Signal in Raspberry Pi 4 using Python

Hello friends, I hope you all are doing great. It's the 8th tutorial in our Raspberry Pi programming course. In the previous lectures, we interfaced LCD 16x2 and Keypad 4x4 with Raspberry Pi 4. In this chapter, we are not going to interface any external module with Pi, instead, we'll create a PWM signal in the raspberry pi using Python. Let's get started:

Components Required

We are going to use the below components in today's PWM project:

  1. Raspberry Pi 4.
  2. LED.
  3. A resistor of 330 ohms.
  4. Breadboard.
  5. Jumper wires.

Before going forward, let's first understand what is PWM:

What is PWM?

  • In PWM(Pulse Width Modulation), we simply turn on and off our power supply at regular intervals and thus reduce the average power of the signal.
  • We have shared a detailed tutorial on Introduction to PWM(Pulse Width Modulation), you should read it once to understand PWM.

Let's understand the working of PWM with an LED example. We can change the brightness of an LED using PWM. If we provide +5V, the LED will have full brightness, but if we provide +2.5V to the LED, its brightness will fade. We achieve +2.5V from a +5V signal by turning it ON and OFF continually. So, in a signal of 1 sec, if we turn it ON and OFF 100 times, the overall power of the signal will be halved as it's in an OFF state for 50% of the duration. This process is called Pulse Width Modulation(PWM).

What is a "duty cycle"?

The percentage for which the signal remains in the ON state during one cycle is called the duty cycle.

To get an ideal square wave, you need a duty cycle of 50%. The signal is always on(full-scale) with a 100% duty cycle, while the signal is always off(Ground) with a 0% duty cycle.

PWM Signal's Frequency

The inverse of the period is the frequency of the signal, which is the number of times a periodic change is accomplished per unit of time. Speed is determined by how quickly a signal goes from high to low i.e. how quickly a PWM completes a cycle. Constant voltage output is achieved by continually turning the digital signal on and off at a high frequency.

PWM Resolution

The 'PWM resolution' refers to the degree of control over the duty cycle. The more 'brightness' levels we can display, the greater our PWM resolution needs to be. Pprecise microcontroller timing is required because the duty cycle is normally around 50Hz. The more powerful the microcontroller, the shorter the time intervals it can keep track of. The microcontroller must not only time the 'interrupt,' which generates the pulse but also run the code that controls the LED output, which must be completed before the next interrupt is called, which is another limiting issue. It's also likely that you'll want your microcontroller to accomplish activities other than controlling the brightness of the LEDs, so you'll need some spare execution time between interrupts.

The fundamental benefit of greater PWM resolutions for LED PWM control is that it reduces the difference between 'off' and the LED's lowest achievable brightness. Suppose we have a duty cycle of 20,000 microseconds and a resolution of 10,000 microseconds. In that case, the difference in brightness between "off" and the lowest possible brightness will be 50 percent of the total brightness. The difference would be 10% at a resolution of 2,000 microseconds. The "PWM resolution" determines the number of brightness levels that we can support between 0% and 100% when it comes to brightness levels. (100 percent). Again, the better the resolution, the more precise the timing, and the more computing power is needed to process the information.

The above diagram shows a PWM resolution of 10%.

Depending on the nature of your application, the resolution and overall duty cycle requirements may be different. There is no need for precision control for simple displays; nevertheless, the ability to manage the brightness level may be crucial (think of the issue of mixing colors using an RGB LED, for example). More control and accuracy necessitate more microcontroller resources; thus, the trade-off is straightforward.

Applications of PWM

  1. Using PWM, you may adjust the screen's brightness.
  2. Use a variety of loudness levels for the buzzer.
  3. Control the motor's speed i.e. DC, Servo, Stepper etc.
  4. Provide a physical outlet for analog signals.
  5. Create an audio output.
  6. Communication: encoding of the message.

Raspberry Pi PWM Signal

  • Raspberry Pi 4 has two PWM channels, PWM0 and PWM1.
  • Four PWM pins are available on the Raspberry Pi, GPIO12 and GPIO18 share the PWM0 channel, whereas GPIO13 and GPIO19 share the PWM1 channel.
  • The following are the pinouts for the PWM channels on the 40-pin header:

  • The Raspberry Pi 40-pin Header's PWM pins are illustrated in the following figure.

  • On a Raspberry Pi, all of the PWM pins are used by the audio subsystem. As a result, we can choose either PWM or Audio output.
  • Hardware PWM signals can only be generated by importing the Pigpio library. The RPi.GPIO library, on the other hand, can be used to generate PWM signals.

Software PWM in Raspberry Pi

  • There are two ways to generate PWM signals with the Raspberry Pi i.e. hardware PWM and software PWM.
  • It is possible to use all 26 GPIO pins on the RPi to generate PWM frequencies of up to a few thousand Hertz using software PWM. The software PWM signals' duty cycle can be adjusted anywhere from 0% to 100%.
  • Software PWM is more adaptable than hardware PWM. However, software-based PWM has the major disadvantage of being less accurate than a hardware-based PWM channel. Because software PWM generation consumes CPU resources, your Raspberry PI's processing capacity will be limited.

Raspberry Pi PWM Circuit Diagram

Even though hardware PWM is the preferred approach for generating PWM from the Raspberry Pi, we will use software PWM in this article.

  • Connect the anode of the LED with GPIO21. After that, connect the LED's cathode to a 330 Ohm series resistor and ground the resistor's other end.
  • Pins 2 and 6 of the Pi board can be used to supply the circuit with Vcc and ground.

Python Code for PWM Signal Generation

The thorny Python IDE on raspberry pi will be used here to write our Python script. If you haven't already done so, please go back to Chapter 4 and read about how to get started with this IDE before reading on.

To keep things simple, we'll create a file called PMW.py and save it to our desktop.

Putting the project into action

We're using a 50 Hz software PWM signal to generate a customized sine wave with RPi. It has a 20-millisecond window at this frequency. During the application, the frequency does not fluctuate.

Increasing the software PWM duty cycle from 0 to 100 is required to produce a rectified sine wave. The PWM signal is applied to the LED in five-pulse trains every 0.1 seconds, with each train lasting 0.1 seconds.

As a result, the duty cycle is lowered from 100 to 1 in steps of minus one. Five PWM pulse trains, each lasting 0.1 seconds, are applied to each increment. Iteration continues indefinitely until a keyboard interrupt is received, at which point the user program terminates.

Code

Import RPi.GPIO then time libraries. Then a simple script is run to begin. The GPIO.setwarnings() method is used to disable the warnings.

To set the RPi's PINs to the number of board, use the GPIO.setmode() function to set the pin numbering. The GPIO.setup() method configures pin 40 of the board as an output. However, the GPIO.PWM() technique is used to instantiate board pin 40 as a software PWM.

It is possible to write a user-defined setup() function to ensure that the software PWM has no duty cycle when it is first started. Only one instance of this function is ever called.

The duty cycle of the PWM signal is altered from 0 to 100 and then back to 0 in a user-defined loop() function. This occurs in increments of one, with a 0.1-second gap between each. For an endless number of times, the LED lights up and fades back down.

The PWM signal is turned off when a keyboard interrupt is received by calling the endprogram() method. The GPIO of the Raspberry Pi is then wiped clean.

Setup() and loop() are the two methods in a try-exception statement, and they are each called once.

Code Syntax

The GPIO.PWM() method

A PWM instance can be created with the help of this function. This is a two-step process:

  • PWM signal must be generated on a specific channel number
  • The frequency in Hertz of the PWM signal. The method must be assigned to a variable before an instance can be generated.

The syntax for this method is:

The number of the channel must be given in accordance with the user-Board program or BCM numbering.

The start() method

This technique can be used with a PWM software instance. PWM duty cycle is all you need to know about this.

PWM instances can be accessed by calling this method from a Python program. A software PWM signal with the specified duty cycle is started at the supplied channel.

The syntax is as follows:

The ChangeFrequency() method

This technique can be used with a PWM software instance. There's only one thing needed: a new Hertz value for the PWM signal's frequency.

The frequency of the PWM output is changed when this method is used on a PWM object in Python.

The syntax is as follows:

The ChangeDutyCycle() method

An instance of PWM software can use this technique. One reason is all that is required: the launch of a new cycle of service.

The duty cycle ranges from 0.0 to 100.0. The duty cycle of the PWM signal is changed when this method is called on a PWM instance in Python.

Here is the syntax of the method:

The stop() method

This technique can be used with a software PWM instance. It doesn't need a response. An instance's PWM signal is paused when this method is called on it.

The syntax for this method is:

Output

Conclusion

Congratulations! You have made it to the end of this tutorial. We have seen how PWM is generated in the raspberry pi. We have also seen how to set up our raspberry pi pins with LEDs to be controlled and wrote a python program that controls the output of these pins. The following tutorial will learn how to control a DC motor with Raspberry Pi 4 using Python.

Installing Thonny IDE for Raspberry Pi Pico Programming

Hello readers, I hope you all are doing great. In our previous tutorial, we discussed the installation procedure of Visual Studio Code for programming Raspberry Pi Pico.

We have already mentioned in our previous tutorials that RP2040 or Raspberry Pi Pico supports multiple programming languages like C/C++, Circuit python, MicroPython cross-platform development environments. Raspberry Pi Pico module consists of a built-in UF2 bootloader enabling programs to be loaded by drag and drop and floating-point routines are baked into the chip to achieve ultra-fast performance.

There are multiple development environments to program a Raspberry Pi Pico board like Visual Studio Code, Thonny Python IDE, Arduino IDE etc.

So, in this tutorial, we will learn how to install Thonny Python IDE to program the Raspberry Pi Pico board using Micropython programming language.

Downloading Thonny Python IDE for Windows

Thonny Python IDE (Integrated development environment) is a development tool designed for beginners. The major feature of using Thonny is that it is easy to operate and this development environment also provides a faithful representation of function calls. The Thonny IDE is compatible with Linux, MacOS and Windows OS.

  • To download the Thonny Python IDE follow the given link: https://thonny.org/
  • This is the official website of Thonny where we have different download versions for different OS.
  • Click on ‘Windows’ to download the installation setup for Windows OS (as shown below).

Fig. 1 Download thonny

Installing Thonny Python IDE

  • Once the installation setup is downloaded successfully for Windows next step is the installation of the IDE.
  • To install the Thonny Python IDE in your system, double-click on the downloaded file.
  • Select “Install for all users”.

Fig. 2 Choose Installation Mode

  • Follow the basic installation procedure.
  • Accept the license agreement and press next.

Fig. 3 Accept the agreement

  • Select the installation/destination location.
  • You can keep the default location or you can also change the location by clicking on

Fig. 4 installation location

  • Now, select the “Start menu folder” and press ‘Next’.
  • If you want to create a desktop icon for Thonny then check the respective icon and press Next (as shown below).

Fig. 5 Desktop icon

  • Finally, press Install to install the setup.

Configuring the Raspberry Pi Pico for programming with MicroPython

MicroPython is a programming language that runs directly on embedded hardware, for example, ESP and Raspberry Pi Pico. It is a full implementation of the Python (3) programming language.

Programming Raspberry Pi Pico is a very easy process. Users can program the board by connecting it via USB port, and then just drag and drop the file into Raspberry Pi Pico.

Download the MicroPython UF2 file

    • To download the micropython UF2 file for raspberry Pi Pico programming follow the given link :

https://www.raspberrypi.com/documentation/microcontrollers/micropython.html

  • Scroll down the page for MicroPython UF2 file and download the file to your system, as shown below:

Fig. 6 Download Micropython UF2 file

Connecting Raspberry Pi Pico board with laptop/computer

  • Press and hold the BOOTSEL button from the Raspberry Pi Pico development board.
  • Connect or plug the Raspberry Pi Pico board to your system/computer via USB cable and release the BOOTSEL button once the Pico is connected to the computer.
  • Now you should see a new volume in your system i.e., RPI-RP2.
  • Drag and drop the downloaded MicroPython UF2 file into RPI-RP2 This UF2 file will reboot your system.
 

Select Interpreter and Install MicroPython Firmware

  • Open the Thonny IDE.
  • Go to Run >> Select Interpreter.

Fig. 7 Select Interpreter

  • Select the necessary/required interpreter which is MicroPython (Raspberry Pi Pico) as shown below:

Fig. 8 MicroPython for Raspberry Pi Pico

  • Press “Install or update firmware”.
  • Again press Install.
  • Make sure that your system is connected to internet.

How to check whether Micropython firmware is installed successfully or not and whether it is working or not?

  • Go to View >>
  • In the file list (on left side of the screen) a complete list of all the local files and document saved on your system will be displayed and along with that your should see Raspberry Pi Pico file in the same list (this is the file saved in Pico).
  • Again go to View >> Shell.
  • In shell type some command like printing a message as shown below:

Fig. 9 Printing a message with MicroPython (Pi Pico)

  • If the command is executed successfully means the firmware is successfully installed or updated and we are ready to program our Raspberry Pi Pico with Thonny integrated development environment.

Conclusion

So, this concludes the tutorial and the installation procedure of Thonny Python IDE (Windows) for raspberry Pi Pico programming.

In our next tutorial we will discuss how to write a program for raspberry Pi Pico programming to control GPIOs using MicroPython programming language.

How to Control Raspberry Pi 4 from Laptop using VNC

This is the third tutorial in our Raspberry Pi programming course. In the previous chapter, we learned how to install Raspbian on our Raspberry Pi mini-computer. In this chapter, we'll learn how to use a VNC server to remotely control and see its desktop from our computer.

Where To Buy?
No.ComponentsDistributorLink To Buy
1Raspberry Pi 4AmazonBuy Now

What is VNC?

Computing over a network is known as "virtual network computing," or "VNC." To remotely control another computer, you can use this screen-sharing technology, which works on all major operating systems. As a result, a remote user can interact with a computer's display (screen, keyboard, and mouse) as if they were sitting right in front of it.

VNC takes advantage of the client/server concept. Rather than installing a VNC server on the distant device, users will instead use a VNC viewer or client on the device they wish to control. Use a tablet or a smartphone in place of one of the previously mentioned computers. As soon as a viewer and a server are connected, the server gives the viewer a screen copy of the computer on the other side of the world.

Thanks to the application, both the remote user and the connected user can see and control everything on the distant computer's screen using keyboard and mouse instructions from afar.

What’s a VNC Server?

Other programs (referred to as "clients") can access the resources on a computer server. The server can provide services to one or more clients, such as data or resource sharing, in what is known as the "client-server model." The advantage of this strategy is that a single server can service many clients, while a single client can make use of several servers. A server will respond to a request from a client by sending back a response.

When a computer has VNC Server software installed, it can be accessed and controlled remotely from another device. The software makes it possible to stream the device's desktop to another computer running VNC Viewer. Once a connection is established, users using VNC Viewer can view exactly what a person seated in front of the remote computer sees (with permission).

What’s a VNC Viewer?

A viewer is a piece of software that allows you to see the contents of a digital file in its entirety.

Remote control of local PCs and mobile devices is made possible through the usage of VNC Viewer. Using VNC Viewer software, a user can access and operate a machine from another place using a device such as a computer, tablet, or smartphone.

As a desktop sharing system, it delivers keystrokes, mouse clicks, and other input events to a remote computer running VNC Server so that you may control it from your mobile device once connected. It's as if you're sitting directly in front of the computer that you've accessed remotely.

What protocol is used by VNC?

VNC uses a protocol called remote framebuffer to share data between the client and server, which determines the type of data exchanged. Using this, clients can access and control another machine from afar. Because it's compatible with all windowing apps and systems, it may be used on any mainstream operating system, including Windows, macOS, Linux, and others.

User access to a computer's monitor, mouse and keyboard is provided via the RFB client or viewer (also known as a client). Framebuffer updates originate on the RFB server (as in the windowing system). A key goal of Remote Framebuffer is to run on a wide range of hardware and to simplify the process of building a client by requiring as little input from the client as possible.

File transmission, more advanced compression, and stricter security procedures have all been added to RFB since its inception as a basic protocol. When using VNC, clients and servers can agree on the appropriate RFB version to use, as well as the security and compression options that are supported by both parties. Cross-platform interoperability is made possible as a result of this.

Why use VNC?

There are times when you won't be able to use your Raspberry Pi. For instance, you might have forgotten about your Raspberry Pi while away, or it may be buried beneath your TV or other devices. Using Raspbian and the free VNC software, you can connect to your Raspberry Pi wirelessly from any other device running Raspbian. You have the option of connecting to the internet or to your home network.

Prerequisites

  • Raspberry Pi running Raspbian
  • A network connection
  • A VNC server and viewer

Configuring VNC on a local network

Enable VNC

Begin by ensuring that both computers involved are on the same local network.

Select Preferences > Raspberry Pi Configuration from the apps menu icon (raspberry) at the top-left of the screen.

The default password for Raspbian is 'raspberry,' which you should change right away. By clicking the Change Password option, you can set a new password. Select the Enabled radio button next to VNC on the Interfaces tab. OK when you're finished. Menu bar in upper right corner of screen has VNC button at end of menu bar VNC Server will be launched as soon as you click on it.

Note your Ip address for the next steps.

Open VNC Viewer

You can now link your Raspberry Pi to another computer. Instead of a Windows computer, you might use a Mac or Linux computer on the same network or even another Raspberry Pi.

With a web-based interface, VNC Viewer may be used on a variety of platforms including macOS, Linux, Android, and iOS. On the official website of realvnc, download VNC Viewer. To use the software, it must first be downloaded and then installed.

Connect to Raspberry Pi

In the "Enter a VNC Server address or search" box of the VNC Viewer, enter the Raspberry Pi's IP address (the four numbers displayed in VNC Server). RETURN is all that is needed to disconnect when a connection is established. If an error message appears, press the Enter key to proceed.

For security reasons, you'll need to log in with your Raspberry Pi's username and password. To remember your password and access Raspbian, select ‘Forgot Password’ and then OK.

Remote control

The Raspberry Pi window is shown on your windows computer. By dragging the mouse cursor around the screen, you can see the Raspberry Pi's mouse. Remote control of your Raspberry Pi is now possible thanks to this window.

When you hover your mouse over the top of the VNC Viewer window, a menu will appear. Enter The Full Screen option is located to the left of the Options and allows you to have the preview window take over your screen. Because your Raspberry Pi display may not be compatible with your PC display, choose Scale from the menu (such that it is set to Scale Automatically).

Your Raspberry Pi will provide you a desktop PC-like experience.

Looking at properties

Close the VNC preview window and use the VNC Connect menu bar to get to the properties. You can end a session from the drop-down menu.

To access your Raspberry Pi's desktop, simply open VNC Viewer from the Address Book. To reopen the connection, simply double-click on the icon and select Properties from the context menu that appears.

Enter 'Raspberry Pi' in the Name field. This will give your screen a more personal touch. After that, select Options. Automatic is the default setting for Picture Quality on your camera. The lower the setting, the better; if you have a fast connection, the higher it should be.

Make sure to check out the "Experts" section at the bottom. In this section, you'll find configuration options for pretty about everything on your computer. You can change the False to True option in the Fullscreen drop down box. In VNC Viewer, you can preview your Raspberry Pi in full-screen mode. After you've made your options, click OK to keep them.

Remote access in wide area network

You may access your Raspberry Pi from anywhere in the world with a RealVNC account.

Verify your identity in the upper left corner of VNC Viewer when it has been opened. Sign up if you don’t have an account. Set up a password for your account. Keep your password at least eight characters long and difficult to decipher. There is a RealVNC home page that you will be taken to. Verify your email address and you're done setting up.

Sign in

A single account must now be used to sign in to both of these applications.

You should be able to see the VNC Viewer Sign In window from the computer. Your Raspberry Pi must be running VNC Server before you can connect to the cloud.

Go back to the VNC Viewer application on your PC. In the Address Book area, you will find a Raspberry Pi Window, but you'll also notice a Team option immediately below it.

What exactly is the distinction between the two?

This account can be used from different networks and operates remotely.

Send files

Sending and receiving files is possible between the Pi and computer. We've created a new text file called test.txt in our Documents folder.

Connect to the Pi using VNC Viewer to send a file. An option to transfer files can be found in the VNC Viewer preview window's menu.

Sending files is as simple as clicking the Send Files button in the VNC Viewer's File Transfer window and the transfer will begin. Click Open after you've selected a file from your computer's file picker. On your Raspberry Pi's desktop, the file will be saved. The message "Download complete" will appear in the File Transfer window; close it.

Retrieve files

With VNC Viewer, it is possible to download files from your Raspberry Pi's SD card. VNC Server icon can be found in the Raspbian menu bar by right-clicking it. Select File Transfer from the VNC Server drop-down option to open the File Transfer window.

Your Raspberry Pi can now be accessed remotely. The screen and keyboard can now be removed from your Raspberry Pi and left connected to the network. The PC connection will be waiting for you when you're ready.

Connect with Android and iOS

Using your smartphone, you can also remotely connect to the Raspberry Pi. Download the VNC Viewer software from the app store, then, open your VNC Connect account and log in using your email address and password.

Your Raspberry Pi will be listed in the Team drop-down menu. Click it and input your Raspberry Pi's username and password.

On start up, you will have to go through the 'Control the computer' step. The 'How to control' window will open once you click Next. This screen shows you how to use movements like mouse clicks on the touchscreen. Start using Raspberry Pi from your phone by closing this window.

To move the cursor, make use of your smartphone's touchscreen. An on-screen keyboard can be accessed with a simple swipe of your finger on a key at the top of the app.

Even on your phone, you can now access your Raspberry Pi. Remote monitoring has never been easier.

Misconceptions about VNC and VNC Connect

When it comes to deploying new software and systems, there will always be some trepidation, and there is a lot of misinformation floating about that influences how people feel about doing so. However, this has the drawback of preventing individuals and organizations from reaping the full benefits of new technologies.

In this article, we'll debunk some of the most popular myths regarding VNC Connect, many of which can be traced back to VNC's open-source roots.

  1. VNC is open source. Open-source software is common among recent adaptations of the VNC protocol; however, this does not apply to all VNC-based software. As of 2016, VNC Connect, which uses RFB protocol version 6, is not open source.
  2. It is not safe to use VNC-based software. Out of the box, open source VNC-based remote access is vulnerable to attack. Secure connections are built into VNC Connect right out of the box, and remote PCs are secured by default with a password or system login credentials.
  3. VNC doesn't work with the cloud. The majority of open-source VNC-based applications is only available for use offline. Offline (commonly known as "direct") and cloud connections are also available through VNC connect, so you can select the one that best suits your company needs.
  4. The VNC protocol is out of date. VNC technology has been around for more than 20 years, but it has undergone a major transformation. VNC Connect is continually checked and updated to correct any faults that may arise and to meet the ever-changing needs of its users. The software roadmap is based on user feedback to ensure that it incorporates the designs and features that are most frequently requested.

Conclusion

Because buying two keyboards, monitors, and mice for your computer and Raspberry Pi would be prohibitively expensive, VNC is a great option to gain access to your raspberry pi remotely. The two computers can be used at the same time, and you don't have to switch between them. So far, we've learned how to set up our mini-computer for VNC and how to establish a remote connection to the VNC viewer. Our first project will be to use Python to control the GPIO pins of a Raspberry Pi 4, which we will cover in the next topic.

Installation of Raspbian in Raspberry Pi 4

Welcome to the second chapter of our beginner's course on the Raspberry Pi. In the previous tutorial, we learned about the components of this little computer. We also considered its uses, as well as the most important advantages and disadvantages. Let's get started with setting up our little computer to run the Raspbian operating system in this lesson.

Where To Buy?
No.ComponentsDistributorLink To Buy
1Raspberry Pi 4AmazonBuy Now

How to Install Raspbian using an imager

The next step is to make sure you have your board and SD card. The Raspberry Pi has an operating system because it is a full computer. For those who prefer a GUI desktop experience, a headless mode is still an option. Most people use Raspbian, a Debian-based operating system tailored specifically for the Raspberry Pi. However, there are other options. An excellent starting point is this operating system, which is likely to support other Linux packages that you are already familiar with.

Other means to install and run an operating system on the Raspberry Pi are also available. The imager installer is the most convenient method. As long as you're familiar with the operating system ISO, you may download it to your SD card, format your SD card and mount the ISO, and then boot the Pi. Follow the imager installation option if that's all gibberish to you.

Download imager

For this process, we will open our browser and navigate to the raspberry pi website and down to the software option, you will see a download for windows. This button allows you to download the imager for windows which in my case I am using. If you are using another operating system like mac and ubuntu there are also imagers for those particular operating systems.

The executable imager file will be downloaded to your computer as seen below.

This software allows us to flash our operating system into the micro-SD card which will be used in the mini-computer.

Flashing the operating system into the storage card

Connect the card reader with an sd card in it to your computer through USB or a regular card slot.

Launch the imager

On your computer, navigate to the location you downloaded the imager software and run it. In windows just double-click on it and it should startup.

Once the installation is done, go ahead and run the application:

Selecting the SD card

On the pi imager window, there are two options and when we click the choose storage, our SD card is detected since we plugged it into our pc.

If you have any other drive plugged into your pc, they will also appear on the window therefore be careful to select the right one otherwise you will override the wrong drive and lose your saved files.

Select the operating system

We will click on the other button "choose os" that is on the pi imager window to select the operating system we want to flash into our SD card. You will see different types of operating systems available for installation and we will go ahead and select the 32-bit raspberry pi os.

Write to SD card

Once all the required parameters are set, i.e., the os and storage, go ahead and click the write button. The flashing process begins and it takes a minimum of 5 minutes to complete.

How to Install Raspbian with etcher

NOOBS (New Out of the Box Software) is an automated installer provided by the Pi Foundation, but for this article, we're going to forego it for now.

To complete numerous projects, it is a good idea for you to learn about "flashing" the SD card yourself. Despite NOOBS's reputation as a beginner's tool, I found this one to be easier to use.

You'll need an image file and an application to put it to your SD card to install an operating system. However, you can use any operating system of your choice for this guide. For example LibreELEC for a media box; RetroPie for retro gaming; and so on.

Because it's accessible for Windows, macOS, and Linux, Etcher is my go-to tool for writing to the SD card. There may be partitions that aren't visible in Windows, but these may be cleaned out with diskpart if you've previously used the SD card in a Pi.)

The full Raspbian image with suggested software is what I'm running, so go ahead and download it if that's what your Pi model calls for. It will either be an IMG file or an IMG compressed into a ZIP file (which you don't have to do if you're using Etcher).

It's as simple as opening Etcher and clicking the Select Image button to select your downloaded file. Flash your SD card by selecting it as the target. Selecting a destination drive should only be done with extreme caution, as the operation will wipe whatever disk you select.

Once the SD card has been ejected, you can insert it into your Pi, connect the HDMI wire to a display or TV, and turn on the Pi by plugging it into the wall. Once you've landed on the Raspbian desktop, you can begin fiddling with your Wi-Fi and software installations with apt.

Booting the raspberry pi

Now that flashing is complete, with the pi powered off, we will go ahead and eject the storage SD from the pc and put it back to the raspberry pi SD slot. Then we will go ahead and plug the power cord back in and our mini computer should start. If you mouse, keyboard and screen go ahead in the previous tutorial and see how they are connected since they are necessary for this step.

The mini-computer boots up into the os and you will find a window with instructions on what to do. Follow through the graphical user interface, provide a password, location, screen, and Wi-Fi connection.

Then go ahead and install updates and the raspberry pi will reboot. A couple of issues will be solved when it boots up such as window dimensions and resolution.

We will do some more configurations in the terminal, therefore go ahead and start the terminal.

Configuration

Preferences on the menu can be found in the Configuration tool, which enables you to change most of your Pi's settings, including the password.

Several options are available, as illustrated in the screenshots below. We'll enable vnc and ssh for the time being. The Raspberry Pi's fundamental system settings can be modified in this area.

It's a good idea to change the factory default "raspberry" password for the pi user. When your Raspberry Pi boots up, choose between using Desktop or CLI (command line interface), and enable Auto Login.

You can set your Raspberry Pi to wait until a network connection is available before starting up, by selecting network at boot.

You can choose whether or not your Raspberry Pi boots up with a splash screen.

Interfaces

There are numerous ways to connect your Raspberry Pi to other devices and components. For your Raspberry Pi to recognize that a specific type of connection has been made to it, you must use the Interfaces tab to enable or disable the various connections.

To use the camera on the Raspberry Pi, you must first enable it.

A Raspberry Pi can be accessed remotely through SSH or VNC.

To enable the SPI, I2C, and Serial (Rx, Tx) GPIO pins, go to the SPI menu. To enable the 1-Wire GPIO pins, go to the 1-Wire menu. To enable the 1-Wire GPIO pin, go to the 1-Wire menu. To enable Remote GPIO, go to the Remote GPIO menu.

Performance

We can alter the performance settings of our Raspberry Pi on this tab if we need to do so for any specific project.

Caution: Changing the performance parameters on your Raspberry Pi could cause it to behave strangely or stop working altogether.

If you want to boost your computer's performance, you can overclock the CPU and adjust its voltage.

Localization

This enables you to customize your Raspberry Pi's settings based on where you live.

To configure your Raspberry Pi's locale, select the language, nation, and character set you want to use.

For example, you may want to change your time zone, or you may want to switch to a different type of keyboard layout.

Go ahead and finalize the configuration and reboot now that you've completed the setup.

Setting up remote connections

  1. On Windows, connecting to the Raspberry Pi via RDP is a straightforward process.

You don't need much more than a remote desktop program and the IP address of your Raspberry Pi to get started.

Open Remote Desktop Connection on your Windows computer to get started. The app will appear as seen in the image below.

In the "Computer:" field, type in the local IP address of your Raspberry Pi (1.), and then click the "Connect" button (2.).

  1. After connecting to your Raspberry Pi, the xrdp software will present you with this screen.

Enter the account's "username" and "password" from your Raspberry Pi.

If you're logging in as the default pi user, your username and password should be "pi" and "raspberry," respectively.

  1. You should now be able to connect to your Raspberry Pi using the Windows remote desktop program.

Have trouble connecting to the Raspberry Pi? Double-check that your IP address is accurate. TeamViewer or TightVNC are two other options.

I hope you can now access the Raspberry Pi's remote desktop using the tool of your choice.

Installing Python on the Raspberry Pi

Python will be installed on your Raspberry Pi, and you'll see how simple it is to do so. This can be accomplished in a few simple steps thanks to Python's default package repository.

  • We should check our package list and existing packages for updates before we install Python. The following instructions can be used to update both of these on your device. Let's go on to the next phase now that we've completed this one.
  • Next, we'll set up our Raspberry Pi with the Python package we downloaded earlier. Python 3 will be the focus of this guide because it is the most recent version that is still widely supported. Installing Python is as simple as running the following command.
  • Once this process completes, you will now have Python installed on your Raspberry Pi. This will provide you with the minimal essentials of Python, but that is all you will need for now. Later on, you will end up using package management such as pip to extend the capabilities of Python.

Using the Thorny Desktop IDE

Thonny, a Python IDE, is pre-installed on desktop versions of Raspberry Pi OS. It is much easier, faster, and more pleasant to write code when using an IDE. Open Thonny on your Raspberry Pi, and then learn a little bit of Python in the process.

  • The Thonny IDE must first be opened before we can proceed. On your computer's desktop, go to Start, and then click "Raspberry". Next, you'll need to click on the "Programming" option on the left-hand side of the page. Lastly, select the "Thonny Python IDE" option to launch the Python editor on your Raspberry Pi".
  • Since you're probably using Thonny for the first time, let's go through the basics of how it works.

The toolbar is located at the very top of the screen. All the buttons you'll ever need to work with the editor are right here. The "Save" and "Run" buttons are the only ones you'll need (1.)

It's time for the center box. All of your Python code can be written here. (2.)

Finally, the Python shell is at the bottom. You can use this to directly communicate with Python. The output of your code can also be found here (3.).

Conclusion

You should now have a better understanding of how to get started with Python on your Raspberry Pi. This instruction explains how to install the Raspbian operating system, configure its interface, and install the Python interpreter with a few basic command lines. On the Raspberry Pi, we also demonstrated how to start a Python code editor to develop code.

Visual Studio Code Installation for Raspberry Pi Pico Programming

Hello readers, I hope you all are doing great. This is the second tutorial of the Raspberry Pi programming series. In our previous tutorial, we discussed the basic features and hardware architecture of Raspberry Pi Pico.

In this tutorial, we will discuss the various available development environments for programming the Raspberry Pi Pico. Later, in this tutorial, we will also discuss the installation of Visual Studio Code for Pi Pico programming.

Fig. Raspberry Pi Pico

RP2040 supports multiple programming languages like C/C++, Circuit python, and MicroPython cross-platform development environments. Raspberry Pi Pico module consists of a built-in UF2 bootloader enabling programs to be loaded by drag and drop and floating point routines are baked into the chip to achieve ultra-fast performance.

There are multiple development environments to program a Raspberry Pi Pico board like Visual Studio Code, Thonny Python IDE and Arduino IDE etc.

We need to download and install some tools before installing the Visual Studio Code for programming Raspberry Pi Pico which includes:

  1. CMake
  2. ARM GCC embedded tool-chain package
  3. Python
  4. Git open source project
  5. Build tools for VS code

CMake

Fig. CMake

CMake is an open-source system developed/designed to fulfill the need of powerful cross-platform build environment which is responsible for managing the build process in a compiler independent manner and in an OS (operating system. It is designed to work in conjunction with the native build environment.

CMake is responsible for generating a build environment for compiling a source code, building executables, creating libraries and generating wrappers.

It also supports dynamic and static library builds. It can handle complex hierarchies and applications dependent on several libraries. CMake can also handle projects with multiple toolkits or libraries, where each library is further having multiple directories.

CMake is open-source tool which is easy to use and also having a simple yet extensible design which can be extended (as per the requirements) to support new features.

Installing CMake in Windows

Fig. 3 Windows 64-bit installer

  • Open the downloaded .msi file for installation.

Fig. 4 Press Next

  • Accept the terms and conditions and press next.

Fig. 5 Accept Agreement

  • Select the ‘Add CMake to the system path for all users’ option and press next to continue the installation process.

Fig. 6 Add path

  • Select the destination location and then press next.

ARM GCC Compiler

The GCC ARM tool-chain is compatible with devices that are based on 32-bit Arm Cortex-A, Cortex-M, Cortex-R processors.

Installing ARM GCC Compiler (in Windows)

Fig. 7 Downloading ARM GCC tool-chain

  • Install the “ARM GCC tool-chain” by double-clicking on the downloaded executable file.
  • Follow the default installation procedure to continue the installation process.
  • At the end select/check the “Add path to environment variable” and press the Finish button.

Python

Installing Python (Windows PC)

Fig. 8 Download Python

  • If the Python installation file is downloaded successfully start the installation process by double clicking in the downloaded file.
  • Enable/check the “Add Python 3.10 to Path” at the bottom and click on “Install Now”.

Fig. 9 Add path and install

  • Click ‘OK’ once it (python) is installed successfully.

Build Tools for Visual Studio Code

The next task is downloading and installing ‘Build Tools’ for Visual Studio Code. This tool is responsible for the command-line interface.

Fig. 10 Download Tool chain

  • Open the downloaded executable file to initialize the installation process.
  • During installation process, select Desktop development with C++ and also enable the “Windows 10SDK ” option from included tool list and click on install.

Fig. 11 select the necessary tool

  • The installation process will take some time as the installation is significantly large (1.85 GB).

Fig. 12 installation

 

Git

Git is an open-source tool responsible for code management. The main purpose of using Git is to track the changes in the source code or any set of files, which helps multiple developers work together on non-linear development. In simple words, we can say that Git makes a team of people or developers work together and that is too using common/same files. Toptal is a marketplace for top coders. Top companies and startups Hire Toptal’s freelance coders for their mission-critical software projects.

Download and Installing Git

  • To download Git, follow the given link: https://git-scm.com/download/win
  • Download the respective setup file i.e., the “ 64-bit Git For Windows setup” executable file.

Fig. 13 Download Git for Windows

  • Start the installation process by double clicking on the downloaded executable file.
  • Next task is selecting the necessary components.
  • All the necessary components are already checked so just press Next.

Fig. 14 Select necessary components

  • While adjusting the name of the initial branch in new respositories, select the “Let Git decide” option and press Next.

Fig. 15

  • Next, adjust the path environment.

Fig.16 Select the above highlighted choice

  • Next step in installation process is configuring the line ending conversion by selecting the “Checkout as-is, commit as-is.

Fig. 17 “configure line ending conversions”

  • Next, thing is to configure the ‘terminal emulator’, for that select the “Use Windows default console window”.

Fig. 18 configure terminal emulator

  • Next, select the “Enable file system cashing”

Fig. 19 “configure extra option”

  • Enable the “select experimental support for pseudo console” option and press install.

Fig. 20 “Experimental support for pseudo consoles”

Downloading Pico SDK

Once all the necessary tools (mentioned above) are successfully installed, we can download the Raspberry Pi Pico SDK and respective examples.

Before downloading the Pico SDK and Pico examples, we need to create a folder or directory to save the SDK and pico examples. So, we are creating a folder “RPi Pico” in C:\ drive.

  • Open the command prompt.
  • Next task is to create a new new directory in ‘C’ drive using “mkdir” command to download and save the SDK and pico examples.
  • To download/clone the raspberry pi Pico SDK type : “git clone –b master https://github.com/respberrypi/pico-sdk.git in the command prompt and press enter.
  • Make sure your system is connected to internet.

Fig. 21 download Pico SDK

  • After completing the cloning process, go to the ‘pico-sdk’ directory using ‘cd pico-sdk’ command and type “git submodule update –init” and press enter to add the tinyUSB submodule.

Fig. 22

  • Now got to the previous directory (where you downloaded the SDK) using command “cd ..” that is ‘RPi Pico’ in our case.
  • Download the raspberry pi Pico examples using “git clone -b master https://github.com/raspberrypi/pico-examples.git”.

Now we are ready to program Raspberry Pi Pico using Command Prompt.

Programming the Raspberry Pi Pico using Command prompt for Visual Studio Code

  • To program the Raspberry Pi Pico with Developer command prompt, click on Start button and search for Visual Studio 2022.
  • Click on the Developer Command Prompt for VS 2022.

Fig. 23 Developer Command prompt

  • Go to RPi Pico
  • Next thing to do is, to set the path for SDK use the following command; setx PICO_SDK_PATH "..\..\pico-sdk" and press enter key to set the path.

Fig. 24

  • After setting the path, exit from the command prompt.
  • Restart the same Developer Command Prompt for VS 2022.
  • In the RPi Pico directory create a new directory with name ‘build’.
  • Go to ‘build’ directory you just created.

Fig. 25 create build directory

Using CMake to build the Makefiles:

  • To create Makefiles use the command “cmake –G “NMake Makefiles” ..”.
  • Now we are ready to build projects using nmake The nmake command will build all the available projects and the process is time consuming.
 

Download and Install Visual Studio Code in Windows

Visual Studio Code is tool developed by Microsoft for source code editing.

  • Download Visual Studio Code
    • Follow the given links to download the Visual Studio Code https://code.visualstudio.com/
    • Download the installation setup for Windows by clicking on “Windows x64 User Installer”.

Fig. 26 Download Visual Studio Code

Installation of Visual Studio Code

  • Once the package is downloaded successfully, we are ready to install.
  • Start the installation process and the first step while installing the setup is to accept the agreement and press next.

Fig. 27 Accept the agreement

  • Select the destination location where you want to store the installed files.
  • Next, select the start menu folder.
  • In Additional Task, check the “Create a desktop icon” icon of you want to create one and then check the “Add to path” option (as shown below) and then press next.

Fig. 28 Add to path

  • Now we are all set to install the software. Press the install button.
  • Do not check the “Launch Visual Studio” icon, press finish.
  • To launch the Visual studio Code, go to Developer Command prompt.
  • Open the RPi Pico
  • Type code and press enter.

Fig. 29 Launch the Visual Studio code

  • Once the Visual Code studio is launched successfully, a “Get started- Visual Studio” screen will pop-up automatically, as shown below:

Fig. 30 Visual Studio Code launched successfully

 

Installing CMake in Visual Studio Code

After successfully installing the Visual Studio Code, the next thing to do is to install CMake in VS code.

Steps to install CMake in Visual Studio Code are:

  • Open the Visual Studio Code on the left menu list, click on.
  • Search for Cmake and install the tool.

Fig. 31

  • On the bottom left menu list, press Setting icon and select “Setting” option.

Fig.32 setting

  • Click on the Extension icon and select on the CMake Tool Configuration
  • Again the in User list expand Extension and select CMake
  • A new list will appear on right side of user list.
  • Scroll down to the list and click on the “CMake Configuration environment” and set item as “PICO_SDK_PATH” and Values as “..\..\pico-sdk” and press “OK”.

Fig. 33 CMake Configure Environment

  • Make sure your system is connected with internet.
  • Again go down in the list and click on “CMake: Generator” and fill the space with “NMake Makefiles” and close the settings window.

Fig. 34 CMake generator

  • Next, go to the Explore icon (top left of the screen) and select Open Folder
  • Search for pico-example by writing “:\RPi Pico\pico-examples\” in the search bar and then select the pico-example

Fig. 35 Open folder

Fig. 36 Select ‘pico-examples’ folder

  • Select the “GCC for arm-none-eabi” from the list.

Fig. 37 GCC fro arm-none-eabi

  • After this, the CMake tool will initialize building the Makefiles for all projects.
  • From the bottom blue menu tab, by selecting the build button, you can build other projects as well.
  • So now we are all set to upload a program into raspberry pi pico.

Before writing a program for Raspberry Pi Pico make sure you have all the necessary hardware components along with the software and compilers (installed) required to program the Pico board.

Components required to program Raspberry Pi Pico are:

  • The first thing required is a Micro-USB Cable, which allows the user to connect it to a computer or a Raspberry Pi for programming and powering up the Pico board.
  • Next component is the development environment required to compile and upload the program into the Raspberry Pi Pico development.
  • If you need to interface a peripheral with your Pico board using a breadboard then, you also need a set of Pico Headers.

Conclusion

This concludes the installation procedure for Visual Studio Code in Windows ( for Raspberry Pi Pico programming) which includes the installation of various tools and compilers necessary for programming Raspberry Pi Pico.

In our next tutorial, we will discuss the installation procedure of Python Thonny IDE for programming the Raspberry Pi Pico. We will also continue the programming part with Python Thonny IDE with MicroPython programming language.

I hope you found this tutorial of some help and also hope to see you soon with a new tutorial.

Getting Started with Raspberry Pi Pico

Hello readers, I hope you all are doing great. This is the first tutorial of our Raspberry Pi programming series. In this tutorial, we are going to provide a brief description of the Raspberry Pi Pico module designed and developed by the Raspberry Pi organization itself. We will also discuss various features, memory, peripherals interfacing capabilities, hardware architecture, programming techniques etc.

Before moving towards the detailed study of the Raspberry Pi Pico module, let’s first understand the traditional Raspberry Pi Computers.

What is Raspberry Pi?

Raspberry Pi is a single-board computer or a minicomputer. It was created with the goal of making computing knowledge more accessible to those who cannot afford laptops or desktop computers, as well as developing programming skills at a lower cost. The Raspberry Pi organization designed it.

The Raspberry Pi is a low-cost computer that includes some GPIOs (General Purpose Input-Output) for connecting to and controlling peripherals. Despite the fact that the Raspberry Pi's processing speed is much slower than that of desktop computers and laptop computers, it is still a computer with all of the processing and interfacing capabilities and low power consumption.

A Raspberry Pi can be used to create hardware, home automation, industrial applications etc.

There are various Raspberry Pi models available and Raspberry Pi Pico is one of them.

Fig. 1 Raspberry Pi Pico Vs Raspberry Pi Computer (Pi 0)

Raspberry Pi Pico

Raspberry Pi Pico is a completely different model or device than traditional Raspberry Pi models. Raspberry Pi Pico is not a Linux computer, but it is a microcontroller like various available Arduino boards.

It is a cost-effective development platform designed by Raspberry Pi which has enough processing power to handle complex tasks. It is a low-cost yet powerful microcontroller board with an RP2040 silicon chip.

Like the Raspberry Pi computer, Raspberry Pi Pico is also featured with a processing unit, GPIO (so it can be used to control and receive inputs from various electronic peripherals) etc. but it does not offer any wireless connectivity feature.

Other available Raspberry Pi boards like Raspberry Pi 0, Raspberry Pi 4, 3 etc. are similar to a traditional desktop computer. This means they have all the features to work as a computer like, an HDMI port to connect a monitor, USB ports for mouse and keyboard, SD card slot for OS etc.

But, Raspberry Pi Pico does not have any of the above features or capabilities, neither an HDMI port nor the USB for keyboard and mouse connectivity and instead of using an SD card for storage Pico model is featured with ‘Onboard flash memory’ to store programs.

So now you might have a doubt, that whether one can run a Raspberry Pi OS on a Raspberry Pi Pico or not? The answer is, NO. Unlike traditional Raspberry Pi modules, Raspberry Pi Pico doesn’t run a full desktop OS (operating system) but it runs code directly without a desktop interface.

If you have an Apple, Linux or Windows computer or even a different Raspberry Pi board (Pi 0, 4 or 3 etc.) then, you just need to plug the Raspberry Pi Pico into a computer to program the board for a specific task or project. Once the Pico is programmed successfully, it will run that code every time the board is powered ON.

So we can say that Raspberry Pi Pico is more like an Arduino board than a traditional Raspberry Pi model.

Features of Raspberry Pi Pico

Fig. 2 Raspberry Pi Pico development board

Some key features of the Raspberry Pi Pico board are:

  • Dual-core processor (ARM Cortex-Mo+), 133Mhz
  • DMA controller
  • It supports 16MB of Flash memory via QSPI bus
  • 264kB of on-chip static RAM(SRAM)
  • SP2040 microcontroller chip designed by Raspberry Pi organization
  • A micro USB (type B) port for powering and programming the board
  • AHB crossbar
  • 2 on-chip phase-locked loops or PLLs to generate USB and core clocks
  • Programmable on-chip LDO to generate a core voltage
  • 26 GPIO pins with 23 GPIO pins are digital-only and the rest 3 pins are having ADC capabilities
  • 3 pin ARM SWD (Serial wire debug) port
  • 2MB onboard QSPI Flash
  • Raspberry Pi Pico board operates at a range of 1.8 – 5.5V DC power supply.
  • Operating temperature: -20°C - +85°C
  • Raspberry Pi Pico board also supports drag-and-drop programming using mass storage over a USB.
  • RP2040 also offers on-chip floating-point libraries.
  • Built-in temperature sensor.
  • Multiple digital peripherals supported by RP20400 are:
    • 1 real-time counter
    • 2 UART channels
    • 2 I2C
    • 2 SPI (Serial Peripheral Interfaces) channels
    • 16 PWM (Pulse width Modulation) channels
  • High quality and performance at a very low price
  • It also supports low power sleep mode and dormant mode

This module also offers an onboard buck-boost SMPS (switch mode power supply), which provides a flexible option for powering the board via a micro USB port, batteries or external supplies.

Along with various available peripheral interfacing modules and data communication capabilities, the Raspberry Pi Pico also offers, 8 PIO state machines, a USB 1.1 controller.

The Raspberry Pi Pico development board has been designed to use either a soldered 0.1" pin-headers or can also be used as a surface-mountable device (SMD) or module, as the user IO (input/output) pins are also castellated.

Microcontroller (RP2040)

Raspberry Pi Pico comes with a dual-core microcontroller RP2040 chip, the chip is completely designed in-house at Raspberry Pi.

Fig. 3 RP2040 Microcontroller

RP2040 is the first microcontroller from Raspberry Pi. It is manufactured on a 40nm process node, which provided low power consumption capability and a variety of low power modes to offer extended duration operation on battery power.

The RP2040 microcontroller board consists of total of 36 GPIO pins but only 26 GPIO pins are exposed for control and interfacing.

Now let’s understand why this microcontroller is named so!

  • In RP2040, RP stands for Raspberry Pi.
  • The first digit ‘2’ represents the number of processing cores.
  • The second digit ‘0’ represents the type of processor i.e., Mo+
  • ‘4’ represents the amount of RAM, from the functional floor (log2 (RAM/16kB)
  • The last digit represents the amount of non-volatile storage and ‘0’ indicates no non-volatile storage.

Fig. 4 RP2040 microcontroller

Communication protocols

Some of the communication protocols or methods supported by the raspberry Pi Pico model are:

  1. UART ( It offers 2 UARTs)
  2. 2 SPI (Serial peripheral interface) controllers
  3. 2 I2C controllers

GPIOs

Like a Raspberry Pi computer, Raspberry Pi Pico also featured with GPIO pins to control & interface peripherals or to communicate data with peripherals and even to receive inputs and control signals from those peripherals.

Fig. 5 Raspberry Pi Pico Pin-out

The Raspberry Pi Pico pin-out reveals that it has 40 pins in total, including the power supply pins ( GND and VCC pins). PWM, ADC, UART, GPIO, SPI, I2C, debugging pins, and system control pins are the different types of pins.

Unlike the Raspberry Pi computer board series, the Pico board's GPIO pins serve multiple purposes and in total Raspberry Pi Pico has 26 multifunctional pins. These 26 multi-functional pins are marked as GP0, GP1, GP2 and so on. They can be used to perform both digital input and digital output functions.

For example, if we consider the GP4 and GP5 pins, they can be used as either a digital input or digital output, as can I2C1 (SDA and SCK pins) or UART1 (Rx and Tx). But, only one function can be used at a time by selecting a particular pin and providing the respective instructions in the code.

  • PWM pins: Raspberry Pi Pico has 16 PWM output channels. Actually, it has 8 PWM blocks and each PWM block provides two PWM outputs and hence a total of 16PWM channels.
  • ADC pins: Raspberry Pi Pico board has 4 ADC pins to read analog inputs from peripherals (sensors) out of which only 3 ADCs and usable.

A 12- bit ADC is supported by the RP2040 Pico board and thus the ADC range can go from 0 to 4095.

The MicroPython code, on the other hand, can scale the ADC values to a 16-bit range. As a result, we have a range of 0 to 65535. Because the microcontroller operates at 3.3 V, an ADC pin will return a value of 65535 when 3.3 V is applied to it or 0 when no voltage is applied. When the voltage applied or the input voltage is in the range of 0 to 3.3 V, we can obtain all of the in-between values.

  • UART pins: if you have previously worked with any microcontroller board or development board then you might have used this protocol because this is the most commonly or frequently used serial communication protocol. Raspberry Pi Pico module also offers two UART channels, namely UART0 and UART1 and dedicated GPIO pins are available to implement this protocol.

Fig. 6 Raspberry Pi Pico Communication protocols

  • I2C pins: I2C is a bidirectional serial bus (Two Wire) that is used to communicate data among I2C enabled devices but over a short distance. In raspberry Pi Pico there we have two I2C controllers, which are easily accessible via GPIO pins.
  • SPI pins: SPI stands for Serial peripheral interface and it is used to communicate data between SPI enabled devices over a dedicated or available GPIO pins. Raspberry Pi offers 2 SPI channels for peripheral interface.
  • Power Supply Pins: Some power supply pins are also available to power up the board:
  • SMPS: This pins is used to generate the 3.3V for the Pico board and its GPIOs
  • VSYS: This is the primary input voltage and can be varied in 1.8v to 5.5.V supply range.
  • VBUS: The micro USB input voltage connected to the pin1 of micro-USB port.
  • GND pin

Some other features of Raspberry Pi Pico are:

Labeling

The silkscreen labeling on the top side of the board provides an orientation for 40 pins, while a full pin-out is printed on the rear.

USB

Raspberry Pi Pico comes with a USB 1.1 controller. This USB port is used to power up the board and program the Raspberry Pi Pico.

Bootsel

A BOOTSEL button is available on the Raspberry Pi Pico development board which means Boot Select. This button is used to put the board into USB mass storage mode while powering up the Pico board. This allows the user to drag and drop programs into the RPI-RP2 mounted drive.

Debugging

An SWD which stands for Serial Wire Debug is provided for hardware debugging and letting the user quickly track the problems down in the program.

Programming the Flash

As we mentioned earlier, the Raspberry Pi Pico offers 2MB of on-board QSPI flash memory which can be programmed or reprogrammed via using either the SWD (or Serial Wire Debug) port or using a special USB mass storage device mode.

An Internal Temperature sensor

Raspberry Pi Pico module comes with an inbuilt temperature sensor. The sensor is internally connected to the ADC or analog to digital converter pins of the Raspberry Pi Pico board. These ADC pins, supports a range of values and that is determined by the input voltage applied to the pins.

Programming Raspberry Pi Pico(2040)

Fig. 7 Programming Raspberry Pi Pico

There are multiple development environments available that support different programming languages to program the RP2040 microcontroller.

But, before writing a program for Raspberry Pi Pico you should have all the software and hardware components required to program the board.

Components required to program Raspberry Pi Pico:

The first thing required is a Micro-USB Cable, which allows the user to connect it to a computer or a Raspberry Pi for programming and powering up the Pico board.

The next component is the development environment required to compile and upload the program into the Raspberry Pi Pico development.

If you need to interface a peripheral with your Pico board using a breadboard then, you also need a set of Pico Headers.

RP2040 supports multiple programming languages like C/C++, Circuit python, MicroPython cross-platform development environments. Raspberry Pi Pico module consists of a built-in UF2 bootloader enabling programs to be loaded by drag and drop and floating-point routines are baked into the chip to achieve ultra-fast performance.

There are multiple development environments to program a Raspberry Pi Pico board like Visual Studio Code, Thonny Python IDE and Arduino IDE etc.

In our next tutorial, we will discuss the installation of the development environment for Raspberry Pi Pico and get started with the respective development environment.

So, this concludes the tutorial. I hope you found this of some help and also hope to see you soon with a new tutorial on Raspberry Pi.

Getting Started with Raspberry Pi Programming Series

to our new beginner’s course on Raspberry Pi. This course is appropriate for anyone using either a traditional Raspberry Pi board or the new Raspberry Pi 400 board that includes an integrated keyboard and display. Learning how to code, building robots, and doing plenty of other strange and exciting things are all possible with this low-cost computer setup. The Raspberry Pi can do everything a computer can do, from surfing the web to viewing movies and music, and playing video games.

Raspberry Pi is much more than a modern computer. It`s created to educate young people on how to program in languages such as Scratch and Python, and it comes with all of the major programming languages pre-installed. The world is in desperate need of programmers now more than ever, and Raspberry Pi has sparked a new generation's interest in computer science and technology. Raspberry Pi is used by people of all ages to build intriguing projects ranging from old-school gaming systems to internet-connected weather equipment.

Where To Buy?
No.ComponentsDistributorLink To Buy
1Raspberry Pi 4AmazonBuy Now

What are the aims of this course?

In this course, we'll learn how to make games, build robots, or hack all kinds of fantastic projects. The Raspberry Pi 4 Model B will be covered in this course. In the event that you're working with a different model of Raspberry Pi, don't be worried. whatever is taught here can be applied to any other model in the family.

What is this mini-computer?

It is a small computer about the size of a credit card that can run the Linux operating system. It uses a "system on a chip," which combines the CPU, GPU, RAM, USB ports, and other components into a single chip.

To distinguish it from traditional computers that conceal their internal components behind a casing, the Raspberry Pi's ports and functions are fully exposed, a protective case is available to buy. If you want to know how different computer components work and where to put the various peripherals, this is a great resource.

Features

All Raspberry Pi models share one feature in common:

  • Software written for one model can be used on another, as they are interchangeable.
  • Raspberry Pi operating system can even run on a pre-release Model B prototype. Although it will take longer, still run.

With this, what are you able to accomplish?

Now you've got a little machine that runs a lot of free software, so that's good. Exactly what can you do with it? Fortunately, I've got a simple and fun Python project that I used to teach middle school children in a coding lesson.

  • It's possible to create a weather station, a calculator, a gaming gadget, and a lot more out of the same thing. If you have a Raspberry Pi, you can even make a customized espresso machine that is secure like a Raspberry Pi locked door lock, as this one.
  • Can be used as a game server
  • Controller for robots
  • Webserver
  • Cryptocurrency Mining

Advantages of using this mini-computer

  • Low price
  • High computing power in a small board
  • Numerous interfaces
  • Linux and Python are supported

Disadvantages

  • Windows cannot be installed on the computer.
  • Inconvenient to use as a Desktop PC.
  • There is no graphics processor.
  • Internal eMMC storage is not present.
  • We can't attach external RAM as in a normal computer.

Components in a Raspberry pi

The Raspberry Pi features a number of parts that can be used to control the Raspberry Pi as well as other devices. The following ports will be available on your Raspberry Pi:

  1. System-on-chip

The majority of the Raspberry Pi's system resides on an integrated circuit, which is what the term "system-on-chip" refers to. Included in this is the CPU, which is referred to as a computer's 'brain,' as well as the graphics processing unit (GPU).

  1. Random-access memory (RAM)

A brain is useless without memory, therefore you'll notice another chip to the side of the SoC, tiny and black plastic, like a cube where RAM is located. When you're working on a Raspberry Pi, the RAM stores your work; it's only when you save it to the microSD card that it's written to the microSD card. The volatile and non-volatile memories of the Raspberry Pi are made up of these components. When the Raspberry Pi is turned off, the volatile RAM loses its contents, however, the non-volatile microSD card retains them.

  1. Raspberry pi`s radio module

A metallic lid covers the Raspberry Pi's radio component, which allows it to communicate wirelessly with other devices. In actuality, the radio has two main functions. Wi-Fi and Bluetooth are built-in, so you can use them to communicate with your computer and other nearby smart devices, sensors or cellphones.

  1. power management integrated circuit (PMIC)

Just behind the middle row of USB ports, an additional black, plastic-covered chip is seen towards the board's bottom border. The USB controller manages the four USB ports. The network controller is positioned next to this chip. An integrated circuit (PMIC) is also located on the upper left side of this board. It is in charge of converting power from a USB port to the precise voltage that the Raspberry Pi needs.

  1. Ports for connecting USB devices

The circuit board contains a variety of ports, beginning with four ports in the right side of the bottom edge. You can connect any USB-compatible device to your Raspberry Pi using these ports, including keyboards, mice, digital cameras, and flash drives. One of the two types of USB ports is a USB 2.0 port, which uses version two of the USB standard; the other is a USB 3.0 port, which uses version three.

  1. Ethernet port

There is an Ethernet port. Using an RJ45 cable, a Raspberry Pi can be linked with a wired computer network via this port. You'll notice two LEDs at the bottom, which indicate the connection is operational.

  1. Raspberry Pi AV jack

There is a 3.5 mm audio-visual jack. Connecting to amplified speakers rather than headphone jacks improves sound quality, but the headphone jack can still be used. Audio and video signals can be transmitted using the TRRS (tip-ring-ring-sleeve) adapter, which connects the 3.5 mm AV jack with projectors, tv, and other displays that can receive composite video signals.

  1. Camera connector

The camera serial interface (CSI), or camera connector, as it is most commonly called, is located above the AV jack and has a strange-looking plastic flap that may be pulled up (CSI). This allows you to connect a camera, which you'll learn later in this course.

  1. micro-HDMI ports

There are two micro HDMI connections available, which are a scaled-down version of the connectors seen on gaming consoles, set-top boxes, and televisions. Multimedia denotes that it can transport both audio and video information, and high-definition indicates that the quality will be excellent. A computer monitor, television, or projector will be needed to connect the Raspberry Pi to these adapters.

  1. Type-C port

The port above the HDMI ports is where you'll plug in the Raspberry Pi's power supply. USB Type-C ports can be found on smartphones, tablets, and other mobile devices. Instead of a standard mobile charger, employ the certified Raspberry Pi USB Type-C Power Supply for the best results.

  1. Display connector (DSI)

There is a strange-looking connector at the top of the board, which appears to be the camera connector at first sight, but it's not. It is for usage with a Raspberry Pi Touch Display.

  1. Raspberry Pi’s GPIO header

In two rows of 20 pins each, you'll find 40 metal pins along the right edge of the board. To communicate with peripherals such as LEDs and buttons to temperature sensors, joysticks, and pulse rate monitors, the Raspberry Pi includes a function known as GPIO (general-purpose input/output).

  1. Raspberry Pi’s microSD card connector

The Raspberry Pi has one more port, the micro-SD connector, which is on the other side of the circuit board. The MicroSD card is inserted here and you'll find all the files you've saved and installed as well as the operating system that makes your Raspberry Pi work.

What can you expect from the Raspberry Pi?

  • 1GB of RAM, and dual-band 802.11ac wireless LAN
  • This device has a Bluetooth 4.2 connection; it also has four USB 2.0 connections, an HDMI port, a composite video port, and 40 GPIO pins.
  • 3D graphics, Camera interface (CSI), Display interface, and Micro SD card slot (DSI)

What operating system is it using?

Unfortunately, the Raspberry Pi lacks the ability to run either Macintosh or Windows. Instead, it uses Raspbian, a Linux distribution. Installing Raspbian on your own micro-SD card is also possible using the NOOBS installation. You'll see this loading screen when you insert in the microSD card with Raspbian installed and turn on the Raspberry Pi.

As you've seen, the desktop on your huge PC looks exactly like the one you are used to. A web browser, terminal, picture viewer, calculator, and a slew of other tools are all included by default.

Requirements before you begin

The Raspberry Pi is the heart of your project, but without a power supply or storage, it won't be able to go very far. To get started, you'll need the following:

  1. The Raspberry Pi

      1. A Power Supply

The power supply standard for the Raspberry Pi 4 has been upgraded from microUSB to USB-C, which is an improvement. Powering your Raspberry Pi is best done with a dedicated power adapter from the Raspberry Pi Foundation.

      1. MicroSD Card

The later Pi models use microSD cards instead of the normal SD cards that were used in the original Pi models A and B. However, not all SD cards function correctly, therefore it's preferable to acquire a pre-loaded operating system with the original Raspberry Pi microSD card or a tested suitable card, such as the SanDisk Ultra 32GB.

      1. Case

This is technically optional, but we strongly advise it. It is a good idea to use a case to protect your bare board rather than leaving it exposed. The FLIRC case has a built-in heatsink, making it an excellent choice for older models of the Raspberry Pi.

      1. Mouse, Keyboard, and HDMI Cable

You can control your Raspberry Pi using a keyboard and a mouse. Raspberry Pi can utilize almost any USB-connected keyboard and mouse, wired or wireless. However, don`t use 'gaming' keyboards with flashing lights since they consume too much power to be used successfully.

USB gamepads are also necessary when you are building consoles like a gaming rig, therefore, don't forget about them.

First time set up

We are now going to set up our minicomputer therefore follow these simple steps to get yours up and running:

  • An SD card should be inserted into the SD card slot on the pi board. For the time being, we strongly advise you to stick with Raspbian until you are more comfortable with its features.
  • Use one of the USB ports to connect a mouse and a keyboard to the system. When using 'gaming' mice or other high-end equipment that requires software and drivers, it might waste power and place additional strain on the system. Just use 'plug-and-play' equipment to keep things easy and hassle-free.
  • Using the HDMI port, connect a monitor. Connect the monitor to a wall outlet, and then turn the power on and off as necessary. If you turn on the Raspberry Pi right now, nothing will happen. Adapters for non-HDMI monitors that don't impede access to the USB ports should be used.
  • In order to use Ethernet instead of Wi-Fi, you will need to connect an Ethernet cable as well. The speaker or headphones should be plugged in as well if you wish to hear sound from the speakers. However, to get the Raspberry Pi up and running, you don't need either of these items.
  • Finally, insert the micro-USB cable into the power source and into the wall socket. The Raspberry Pi's red LED will light up, and you'll be able to see it booting up on the monitor. Once you get back to your computer, you'll see a desktop screen.

Congratulations! You've successfully assembled your Raspberry Pi! I hope you have something like this:

Conclusion

At this point in the course, we've learned about the Raspberry Pi computer and what each component does. Our minicomputer has now been set up, and in the next tutorial, we'll learn how to use the python programming language with the Raspbian operating system.

Introduction to Raspberry Pi

Hello friends, I hope you all are doing great. Today, I am going to start a new tutorial series on Raspberry Pi 4. It's our first lecture today, so I will explain the basics of Raspberry Pi boards.

In this tutorial series, I will teach you each and everything about Raspberry Pi and its programming. I have designed this guide for beginners, so we will start from the very basics and will slowly move toward complex concepts. Python programming language is used in Raspberry Pi boards, so we will study Python as well.

So, we will learn both programming and hardware circuit designing in this tutorial series. Let's first have a look at What is Raspberry Pi?

What is Raspberry Pi?

Raspberry Pi is a series of Single Board Computer, developed by the Raspberry Pi Foundation in England, to teach computer science in schools. When you buy the Raspberry Pi board, you only get the board. There are other components i.e. power adapter, HDMI cable and memory card etc. required to run the Raspberry Pi board. After these basic components are provided, the operating system must be installed on the Micro SD card.

A Single board computer(such as Raspberry Pi) is a computer that contains basic units i.e. ram memory, input-output unit, microprocessor but unlike normal computers, it is not possible to expand the hardware features. For example, it does not contain a SLOT to increase the RAM memory from 1GB to 2GB. Since Raspberry Pi is designed as a single board and does not have a structure open to development for extra hardware to be installed on it, its cost is quite low. Single-board computers are not used as personal computers but are used in engineering projects where heavy computing is required i.e. robotics, IoT, image processing etc.

Components i.e. memory, video card, network card, sound card etc. are usually integrated on-board in a single-board computer. The operating system is installed on the Micro SD card. Pictured is the Dyna-micro MMD1, the first single-board computer produced in 1976.

Figure 1: DYNA-MICRO MMD1- First single board

There are many alternatives to Raspberry Pi i.e. Orange Pi, Banana Pi, Asus Tinker Board etc. When examined in terms of features, Raspberry Pi boards are preferred, thanks to the community support behind them, even if the hardware features of the alternatives are better.

The official operating system of the Raspberry Pi card is Raspberry Pi OS, but other operating systems can also be installed on Raspberry Pi boards.

Raspberry Pi 4 is the latest version and it allows the use of both 32-bit and 64-bit operating systems.

Figure 2: Raspberry pi os versions

Figure 3: Recommended 3rd party operating systems for raspberry pi

There is a processor with ARM architecture on the Raspberry Pi. The processor is based on the RISC(reduced instruction set computer) architecture developed by Advanced RISC Machines(ARM).

Figure 4: Raspberry pi 4 -4gb version

ARM-based processors are used in mobile devices, handheld terminals, mobile phones, media players, calculators, disk drives, VCDs, DVDs, cameras and even cars. To give a percentage, 75% of 32-bit processors in the world are ARM-based processors. The reason why this architecture is so preferred is the power saving, low cost and performance features of ARM-based processors.

Figure 5: The processor used in the Raspberry pi4 version is a BCM2711-ARm based processor.

The table shows the hardware comparison of all raspberry pi boards ever produced.

When you buy the Raspberry Pi card, a power adapter and Micro SD card are needed to run the card and load the operating system into it. For Raspberry Pi 3 and previous versions, the power adapter must be micro-USB compatible and at least 2 Amps and 5 Volts. For Raspberry Pi 4 and above versions, the power adapter must be USB-Type C and at least 2.5 Amps.

Figure 7: Raspberry Pi 4 power adapter

Figure 8: While the USB-Type C connection shown on the left is used for Raspberry Pi 4, the micro USB connection is used for previous version cards.

Figure 9A microSD card is needed to install an operating system. It is recommended to use a Class 10 type card.

HDMI cable is used to interface card, monitor/display, keyboard, mouse etc. with Raspberry Pi 3 and previous versions, while micro HDMI cable is required for Raspberry Pi 4.

Raspberry Pi 4 Applications

Raspberry Pi 4 has a vast range of applications because of its portability, ability to produce integrated solutions, ram memory, internet connection, processor speed etc. Few applications of Raspberry Pi 4:

  • IoT Products.
  • Cryptocurrency Mining.
  • Printing on Servers.
  • Raspberry Pi Media Center.
  • Retro gaming station.
  • Control & Robotics.
  • Animations i.e. stop-motion camera, time-lapse video etc.
  • Build a Raspberry Pi web server.
  • Home automation & Security Systems.
  • Network monitoring system.
  • Stream live video on youtube.
  • Learn how to code( Python, C++, Code blocks etc.)
  • Bluetooth and Wifi Projects.
  • AI Projects.

Raspberry Pi OS Installation

Installing an operating system on the Raspberry Pi card to use it required. A minimum 8GB Micro SD card is required to install the Raspberry Pi OS operating system. https://www.raspberrypi.com/software/operating-systems/

You can install the 32-bit or 64-bit raspbian os operating system on the Raspberry pi card. Especially if you have the Raspberry pi 4 8GB version, it would be appropriate to choose 64 bit OS. Because with a 32-bit operating system, you can only use up to 4GB of the RAM memory of the raspberry pi.

Figure 10: Preferable operating systems for raspberry pi 4

In Raspberry Pi OS installation, the image file (iso extension) must be downloaded to the computer and installed on the micro SD card via Win32 Disk Imager or a program that does the same job. In this step, we will examine how to upload the image file to the microSD card.

A-Raspbian os installation steps with Raspberry pi imager

The first step is to download the appropriate version of the imager application for our operating system to the PC.

https://www.raspberrypi.com/software/ When we log in to the address, the imager application can be downloaded by clicking the "download for windows" button.

https://downloads.raspberrypi.org/imager/imager_latest.exe

Installation Steps:
  • When the imager application is run, the screen will appear as follows.

Figure 11: Raspberry pi imager application screen

In the first step, the operating system selection button is clicked. Select the operating system from the pop-up window. Here I prefer Raspbian os 32 bit operating system. If you want, you can choose other operating systems that you can use for different purposes from this menu.

Figure 12: Choose OS screen

If you want the operating system and all the applications that need to be installed on the raspberry pi, you can choose the Full version. For this, the Raspberry pi os (Other) tab is selected. Raspberry pi os Full tab is selected from the window that opens.

Figure 13: full version raspbian os 32 bit version selection

The settings button can be seen in the lower right corner of the opening screen. By clicking this button, we can change various settings that the raspberry pi will need during installation.

Figure 14: The required settings can be changed during installation using the settings button.

Many settings can be made, such as activating the SSH connection, wifi connection settings, entering the user name and password.

If you do not have hardware for raspberry pi at the time of installation, such as monitor, keyboard, mouse, it is enough that your raspberry pi and your personal computer are connected to the same network. ssh connection can be used for this purpose. Thanks to the wifi setting we will make in the settings section, we can provide a remote connection to the raspberry pi card, which is on the same network as your pc.

Figure 15: Setup settings window

2-Select microSD Card: Your microsd card must be formatted in fat32 format.

3-Write Button : All files in your selected microsd card will be deleted and after the work is finished, you will receive the operating system loaded.

B- Installation using iso file

In this section, the installation of the “Raspberry Pi OS with desktop and recommended software” version will be explained. In other versions, there are not some applications to be used as many packages have been removed to reduce the size. The MU Editor application will be used for programming the Raspberry Pi board. This application is only available in the "Raspberry Pi OS with desktop and recommended software" version. In addition, applications such as Scratch are only available in this version for the user to use.

For installation, the file must be downloaded and extracted from the compressed folder. Looking at the extracted file, it will be seen that the file is a mirror file.

Figure 16: Raspberry Pi disk image (ISO file)

After downloading your preferred iso file to your computer, you need a program that will allow you to install your operating system on your sd card. For this purpose, you can choose the win32 imager application. Download this application from https://win32diskimager.org/#download and install it on your computer.

Figure 17: Writing .img file to sd card.

After the image file is loaded on the SD card, the operating system can be started by inserting the SD card into the Raspberry Pi.

Raspberry Pi as Internet of Things(IoT)

The Internet of Things (IoT) philosophy may be viewed as a highly dynamic and radically dispersed networked system comprised of a huge number of identifiable smart devices. These objects may communicate and interact with one another, as well as with end-users and other network entities. As the Internet of Things era begins, the usage of small, inexpensive, and flexible computer hardware that allows end-user programming becomes more prevalent. The Raspberry Pi, a fully configurable and programmable tiny computer board, is one of them discussed in this article. Although there are certain limitations, the Raspberry Pi remains a low-cost computer that has been used effectively in a wide range of IoT vision research applications despite its few shortcomings.

Introduction:

Introductory Notes The Internet of Things - IoT – may be viewed as a highly dynamic and widely dispersed networked system. For example, it is a network of linked smart objects that may communicate and interact with one another, as well as with end-users or other network entities, such as users or other entities in the network. Safety, security, comfort, convenience, and energy savings are maximised when smart devices can perceive physical phenomena and transform them into data streams, as well as when smart devices can trigger actions. These systems should:

  • allow new applications to be built on existing systems,
  • allow new systems to be deployed in parallel with existing systems,
  • allow an adequate level of interoperability so that innovative and competitive cross-domain systems and applications can be developed.
  • The IoT systems will be designed, managed, and used by multiple stakeholders, each with its own business model.
  • The above figure shows Raspberry Pi Model A (left) and Model B (right) board:
  • The Raspberry Pi’s core components are shown in the above figure.

While internet access can be achieved through an Ethernet/LAN cable or a USB dongle (WiFi connectivity), a USB connector is required [5, 6]. Figure 1 shows an example of a formalised formalised formalised formal Model A (left) and Model B (right) Raspberry Pi boards Figure 2: The Raspberry Pi's essential components The Raspberry Pi, like any other computer, is powered by an operating system. Raspbian is a fantastic Linux alternative for Raspberry Pi since it is free and open-source, keeping the platform's price cheap and making it more hackable. There are a few non-Linux OS alternatives available as well [5]. The Raspberry Pi offers a wide range of applications, which is one of its best features. The remainder of the article will discuss what allows it, as well as the performance and limits of the Raspberry Pi. The performance of the Raspberry Pi will be compared against the following IoT prototype platforms (Fig. 3): Arduino is an open-source physical computing platform that is built on a basic microcontroller board and includes a programming environment for creating software for the board (Fig. 3 a). It can accept information from a number of sensors and operate lights, motors, and other actuators to influence its environment. The Arduino programming language and the Arduino Integrated Development Environment may be used to programme the microcontroller on the hardware board (IDE). Arduino has two operating modes: stand-alone and linked to a computer via USB cable [3]. BeagleBone Black Is a single-board computer based on low-power Texas Instruments processors and the ARM architecture.

TABLE I

  • COMPARISON OF PLATFORMS’ SIZE, WEIGHT AND COST

B. Strength and Memory The suggested platforms' major objective is low power consumption in order to fulfil the multi-year application requirements. Only by combining low-power hardware components and low-duty-cycle operating approaches can ultra-low-power operation be accomplished.

As previously indicated, the Raspberry Pi requires up to 700mA to operate. The Raspberry Pi device may be powered by a variety of power sources (provided they can deliver adequate current 700mA), such as a computer USB port or powered USB hub (depending on power output), special wall warts with USB ports, mobile phone backup battery (depending on power output), cell phone solar charger, alkaline batteries (six rechargeable AA batteries and a voltage regulator). The Raspberry Pi's main power supply constraint is that no external device should use more than 100mA from any of its USB ports.

In terms of storage, the gadget should have enough memory to store the gathered data. In addition to storage capacity, programme memory should be sufficient to execute simple computations and send just the necessary data and routing information if the device is connected to a network. It is crucial to understand that the Raspberry Pi does not have a hard drive and that everything is saved on a Secure Digital (SD) Card. The minimum needed SD card capacity is 2 GB, however larger SD cards with capacities of 32 GB, 64 GB, or more are available but frequently prohibitively costly. This storage may be increased by employing devices that supply an extra hard drive through USB ports. These are referred to as USB Mass Storage (UMS) devices and can be traditional hard drives, solid-state drives (SSDs), or even tiny pocket-sized flash drives. Table II provides a comparative study of platform CPU, memory, and power.

TABLE II

  • COMPARISON OF PLATFORMS’ CPU, MEMORY AND POWER

C. Adaptability To be useful in a wide range of applications, the architecture must be adaptable and versatile. Furthermore, for economic considerations, it must make it simple to build precisely the correct mix of software and hardware components. As a result, these devices need an extraordinary level of hardware and software flexibility while being efficient [10]. The adaptability and universality of any gadget, on the other hand, are its strengths. One of the best things about the Raspberry Pi is its versatility; there is no one way to utilise it. It can, for example, be used for: broad purpose computing, capable of interfacing with other electronic boards and communicating with other computing devices using a range of various protocols such as Serial Peripheral Interface (SPI) and Inter-Integrated Circuit (I2C): o I2C – low-speed interface – Inter-Integrated Circuit (I2C) is a serial bus interface that can communicate with numerous devices using only two wires. It operates at relatively modest speeds. o Serial Peripheral Interface Bus (SPI) – Serial Peripheral Interaction Bus (SPI) is a synchronous full-duplex (two-way) serial connection. The Raspberry Pi Model B Rev 2 features an enhanced variety of connections in addition to the usual GPIO port [13]. P5 header has 8 pins (+3.3 V, +5 V, two ground pins, and four GPIO pins that can offer the second I2C protocol) and P6 header has two pins — their short-circuiting enables soft reset of BCM2835. Table III examines the expansion connections used by the Raspberry Pi and other platforms to connect to a broad range of external devices.

TABLE III

  • COMPARISON OF PLATFORMS’ EXPANSION CONNECTORS

The Ethernet connector on the Raspberry Pi serves as the primary interface for communicating with other devices. It is auto-sensing, so it may be linked to a router or directly to another computer (without the use of a crossover connection) [5, 6]. Model B features a conventional RJ45 Ethernet connector, but model A lacks one but may be linked to a wired network using a USB Ethernet adapter. The USB Ethernet adapter offers two speeds: 10 Mb/s and 100 Mb/s (Table IV). When you attach a cable to the Raspberry Pi, it will immediately get the information it needs to connect to the Internet when it loads its operating system through the Dynamic Host Configuration Protocol (DHCP). This gives the Raspberry Pi an Internet Protocol (IP) address and informs it which gateway to use to connect to the Internet (typically the IP address of router or modem). The Raspberry Pi's drawback is the absence of an inbuilt WiFi module, however, this functionality may be added via USB dongles. As a result, the Raspberry Pi may be used to create ad-hoc networks or to connect to a variety of wireless networks, including those that utilise the newest 802.11n high-speed standard [11]. Raspberry Pi can serve static webpages, but it can also produce dynamic content by utilising databases and web apps. It can also offer access to its GPIO ports via web technologies. In addition, Raspberry Pi may be used as a Sensor Web node by connecting it to a network and making it accessible to other computers.

Emerging user programming trends enable non-professional end-users to customise products to meet their unique demands. There are hundreds of products available now that allow end-user programming. Using affordable hardware and open-source software, it is feasible to programmatically manage numerous devices in such a manner that the own solution satisfies user demands. Furthermore, giving end-users with skills and the ability to mould goods to their requirements benefits both users and product creators. One of the prototype systems that allows end-user programming will be explored in this work. The Raspberry Pi computer board will be highlighted, including a comparison of its performance and limitations with current popular prototyping platforms [2]. The primary objective of this research is to identify and explain the benefits and drawbacks of the Raspberry Pi, as well as the capabilities of its use in the construction of the future generation of IoT. The remainder of this paper is arranged as follows. Section 2 contains an overview of the Raspberry Pi, its main components, and a detailed comparison with other existing IoT systems. The final section includes closing thoughts that summarise Raspberry Pi's merits and drawbacks as IoT hardware.

II. COMPARISON OF THE RASPBERRY PI WITH OTHER IoT

HARDWARE PLATFORMS

Smart items are key to the Internet of Things vision. These things, which are equipped with information and communication technology, can preserve their context, are networked together, can access Internet services, and communicate with one another and with humans [3]. Raspberry Pi is a tiny, powerful, inexpensive, hackable, and educational computer board that was released in 2012. (Fig. 1). It functions similarly to a normal PC, needing a keyboard for command entry, a display unit, and a power source. This credit card-sized computer with numerous capabilities and a price range of $25-35$ is an ideal platform for interacting with a variety of devices. The overwhelming bulk of the system's components, including its central and graphics processing units, audio and communications gear, and a 256 MB (Model A) – 512 MB (Model B) memory chip, are integrated into a single component. The Raspberry Pi board seen in Figures 1 and 2 comprises both necessary (CPU, the graphics chip, programme memory - RAM) and optional components (various interfaces and connectors for peripherals). The SD Flash memory acts as a hard drive for the Raspberry Pi CPU. The tiny Cortex-A8 core powers the device (Fig. 3 b). It is a tiny computer the size of a credit card that can run an operating system such as Linux/Android 4.0. The primary distinction between it and Arduino is that it can run a tiny operating system, thereby transforming it into a minicomputer capable of running applications on various operating systems. BeagleBone is intended to operate at a much higher level and has far greater computing capability than Arduino.

Phidgets are a collection of “plug and play” building pieces for bridging the physical and virtual worlds using low-cost USB sensing and control from a PC. Phidgets contain USB-based hardware boards for input (temperature, movement, light intensity, RFID tags, switches, and so on) and output actuators (servo motors, LED indicators, LCD text displays, and so on) (Fig. 3 d). Because of its design and API, programmers can discover, observe, and control all Phidgets linked to a single computer. All of the needed software components are packaged as an ActiveX COM Component. Each Phidget component necessitates the usage of a corresponding visual component, which provides a visual on-screen interface for interactive end-user control. The system includes a broad API library and may be used with a wide range of applications, including other toolkits in some situations. Using Phidgets, programmers may quickly create physical interfaces without requiring an extensive understanding of electrical design difficulties.

Udoo is a small PC with an integrated Arduino-compatible board that can run both Android and Linux. It is an extremely capable prototype board for software development and design. Udoo incorporates a microcomputer with the most popular communication interfaces (Ethernet, WiFi, USB, HDMI, SATA, digital and analogue input/output) as well as a microcontroller with a standard pinout for rapid prototyping applications. As a result, Udoo is open hardware, low-cost platform outfitted with an ARM i.MX6 Freescale CPU and an Arduino Due compatible portion based on the ATMEL SAM3X ARM processor. The creators of Udoo say that the board will have the processing power of four Raspberry Pis. Udoo's retail lineup consists of three versions, all of which share the majority of features and differ mainly in connection and the i.MX6 CPU utilised [9]: Udoo Quad, Udoo Dual, and Udoo Dual Basic.

Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir