Welcome to the next tutorial of our Raspberry Pi programming course. Our previous tutorial taught us to set up a free media server on Raspberry Pi. We also learned how to connect with different devices and stream media files. This tutorial will teach us how to use a Raspberry pi as a DNS server.
You must have access to the following resources to follow this tutorial:
There must be a unique identifier for every machine on the Internet to speak with each other Using IP addresses; clients can identify the servers they need to contact. However, no one is expected to remember the digits of an address; thus, DNS names are used instead. This DNS can be built on a Raspberry. It's a number-to-domain converter. Clients first need to get the internet address by querying Domain name servers. This can take up valuable time. As a result, it is possible to accelerate Internet connection by configuring a dedicated Domain name server.
The DNS helps you navigate IP-based networks. You typically type in a domain name like www.example.org in your browser's address bar. Computers use iPv4 and IPv6 addresses to communicate across the Internet. However, the server must transform the memorable domain for the transmission to work. Domain name servers are utilized for name resolution. Using a cache first is necessary for this. It may not be necessary to look for the individual system's IP address in some cases.
As a result, DNS queries are routed to single or multiple servers. The internet service provider's DNS server is the first to be called upon most of the time. This DNS offers an optimum result by comparing the search with its database. Otherwise, a request is sent directly to one of the Thirteen Internet core nameservers. This database contains all of the URLs on the Internet.
Static IP addresses are rare among internet users, especially those who aren't the owners of their routers. This property goes hand in hand with the use of dynamic DNS. Internet service providers only assign IP addresses for up to 24 hours. This assignment is followed by a brief forced separation, network disconnection, and a new IP address assignment for the user. Since clients are rarely addressed from outside the home network and only make an HTTP request to the server– rather than vice versa – this usually is not an issue.
However, setting up a DNS server may be necessary for the following situations: Remote desktops and mini-game servers are two examples of this type of technology. As a result, dynamic DNS is employed. A DDNS server assigns a domain name to the domestic server, allowing it to be accessed. DynDNS is a good option if you want a web-based Domain name server that clients from anywhere in the world can access at any time.
For several reasons, users prefer to use Domain name servers instead of manually looking up external IP addresses. When you have a large family, numerous roommates, or an office, having your server is a no-brainer when everyone uses the same devices and shares the same network.
To begin, use the commands below to update the software packages:
Once the DNSMasq tool installs, the Domain name server is configured. The Domain name server forwarder is configured with the aid of DNSMasq.
Several devices on the same network can use it to get their Domain name server queries answered. It also manages limited resources utilized while configuring the Domain name server on a Raspberry.
Increasing the DNS server's responsiveness is the goal of this stage.
Modify the dnsmasq.conf file by following the steps outlined below:
CTRL plus W will locate and delete any # symbol from the lines:
To remove the line displayed below, press CTRL followed by W to locate it.
Then, add these lines:
We will ensure the upstream is the Google Domain name server by completing the preceding steps.
If you want to increase the size of the cache to 1000, delete the # symbol and do the following:
It is possible to speed up response times by increasing the cache's capacity. Performance is also boosted by storing more domain name server responses.
Next, save the changes, then run the following command to reboot DNSMasq:
Use the following command to see if the DNS is up and running:
Dig is used to verify the server's functionality. If you want to gather info about DNS servers, static IP, and other things, you can use dig in Linux.
For example:
The query execution time is shown in the preceding image.
Keep in mind that the server's response time of 1091 msec is all that matters here.
The time it takes to make a query is reduced since the address is saved in the cache. The image below makes this quite evident.
Keep in mind that the Request Time is all that matters.
Ifconfig is used to get the raspberry network address.
For example, our server Ip is 10.0.2.15.
The next step is to configure devices to use this Ip as their Domain name server. To make this happen on your Windows PC, follow these steps:
Press Windows key Plus R to access run, access the Control panel by typing control, and press Enter.
In the control panel, select Network and Internet.
Afterwards, click on the View networks option in the newly opened window that appears.
Choose adapter configuration from the left-hand menu of the new pane.
You may do this by right-clicking on the interface you're using, such as Wlan0 or Eth0, and selecting Preferences.
Right-click on TCP/IPv4 and choose Preferences once more.
Then choose those Domain name server addresses from the drop-down menu that appears inside the new window.
Using a Raspberry, you can maximize the speed of the network. Domain name server query response times can be sped up by storing IPs in a local cache.
Keeping a Domain name server safe is essential since it is a common target for fraudsters.
Ensure that the upgrades automatically keep it running smoothly. Use the following command to upgrade.
Whenever you enter a web link into the browser's address bar, a Domain name server searches for the desired address. As a result, various Domain name servers are queried, and each of them performs a translation of the domain you entered. The following are the several servers that are contacted:
You'll see the web page you were looking for after the Ip has been found in the internet browser. Even while it sounds complicated, the process is relatively simple and takes only a few seconds to get you back to the website of your choice.
A single denial of service assault can overwhelm a web server with just one machine and one internet connection. When it comes to overloading the high-capacity systems today, they don't work very well.
Another sort of Cyberattack known as a DNS magnification is where attackers exploit open Domain name servers to overwhelm domain name server responses. As part of an attack, the intruder spoofs the user's Domain name server source address and sends another request to the open DNS. The Domain name server response is sent to the destination rather than the Domain name server.
Domain name server hijacking can take place in three ways:
Domain name server tunnelling uses the Domain name server protocol, which is used to determine the network id to transfer data.
When a client sends a domain name server request, the only info included is that which is necessary for the server and the client to communicate. By using Domain name server tunnelling, an extra set of data is routed over the network. Communication can proceed unhindered by filtering, firewall, or sniffing software.
As a result, it is challenging to identify and trace its origins. It is possible to establish command structure and control via Domain name server tunnelling. It is also capable of leaking data. When information travels via a Domain name server, it is often broken down into smaller bits and reconstructed.
Web traffic can be redirected to infected sites using security holes in the domain name server protocol known as domain name server poisoning or server spoofing.
When you visit a website, your internet browser first asks for a local Domain name server for the Ip. The local domain name server will contact the root servers of the domain and authoritative name servers to obtain the address of your domain.
For the Internet to function, a company's ICT department must support the DNS servers as a critical piece of infrastructure. A well-maintained authoritative Domain name server is required for this.
The most important thing to remember is that a server going offline is impossible with an adequately designed anycast Domain name server. It is possible to maintain each server at a time while providing a fast and reliable Domain name server by connecting geographically distributed endpoints with redundancy servers at every station.
Do you need a "perfect" domain name server? Yes, Outages to your external Domain name server can have a direct impact on the following departmental activities:
This is an extensive list, but there are likely many more devices and programs that rely on the Domain name server to work correctly. Although outages and poor performance can harm your bottom line, the ROI is robust and measurable. As long as a Domain name server outage spares your team from having to meet with the above departments, the service will pay for itself.
This tutorial taught us how to use a raspberry pi as a DNS server. We also learned the possible attacks on a domain name server and how to prevent these attacks. In the following tutorial, we will learn how to use a raspberry pi as a VPN server.
Welcome to the next tutorial of our Raspberry Pi programming course. Our previous tutorial taught us to set up a webserver in raspberry pi. We also looked at configuring addclient and deploying apps to our repositories. This tutorial will teach us to set up a free media server on Raspberry Pi.
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Raspberry Pi 4 | Amazon | Buy Now |
Even if you lack some of the expertise mentioned above and experience, we can still attempt to accomplish this task, and you will gain new knowledge in the process!
This can be done in a variety of ways. It's a mix of free and paid options. While we're here, we'll learn how to use the DLNA protocol to run a public media server on a Raspberry Pi. Let's get right down to business right away.
It's possible to store information in the form of files on a media server at a central location. It doesn't matter if it's a document, image, film, ebook, or scripting file stored on a conventional media server; everything it contains is a file. It merely allows you to store data in a more orderly fashion. Accessing data should necessitate you navigating it on your own.
A media server sits on top of the file server. Media items such as photos, music, and videos can be accessed with this application. In addition, it enables network playback. There's no need to worry about where the video files are kept. You don't have to do anything more than type in your questions and wait for the results to appear. For example, you can search for all the music by a particular artist or musician. These new features improve the media server's usability, manageability, and overall appeal.
Let's have a look at the DLNA, shall we? When it comes to digital living, DLNA (Digitized Living Network Alliance) is the acronym. SONY with Intel collaborated to create a multimedia transfer protocol standard. Its primary purpose is to set guidelines for media distribution via the Internet. Smart gadgets like android Tv, smartphones, and set-top boxes that can share multimedia content are all DLNA-compliant. Microsoft Media Player, VLC, and Plex will all be DLNA-enabled in the future.
Computers can now be used as multimedia servers thanks to the DLNA standard. A DLNA server and a DLNA client are necessary for DLNA to function. Media sharing is a server-to-client process that occurs at all times. Servers and clients cannot independently share material. Clients and servers are two terms you may hear used interchangeably. What do you think about their appearance? Any DLNA-enabled device can serve as a DLNA client. Smart devices that can stream media over the Internet are one example. Setting up a DLNA server does not necessitate a large server. Any of your friends can access it and set up their server with it. The Windows Player is capable of serving as a Digitized Living Network Alliance server. In addition, many NAS devices are equipped with DLNA server programs that allow users to view multimedia files stored on them. Free multimedia services can be built on the Raspberry Pi using the miniDLNA software.
Because of its small size, it can be run on any Raspberry model. Let us set up a miniDLNA service on our RPi and transfer multimedia files to external smart devices via the network.
A better grasp of the setup procedure is gained by splitting this topic into four primary subsections.
It's as easy to set up as any other application. Let's do an apt installation.
/mnt/data-ext4/ is where we'll create all of the directories we need for our demonstration purposes.
Inside the minidlna folder, we can write to a folder instead of root, as shown by the permissions below. In general, it's not a good idea to offer complete access to everyone. s Instead, new users and groups are created, and the ownership is transferred to them. Therefore, the database and logs are stored in this folder.
Ownership can be changed with the command shown. In the chown command, the user and the group are permitted to access the folder.
Minidlna folder ownership after the chown command is shown here.
Set up an entirely new subdirectory named "Music" inside the "public" folder you just created. The 'public' folder has all permissions for all the users, so the sudo word isn't necessary anymore. This folder is owned by 'user' and group 'pi,' and no one else has to write access to this folder.
You can use the same 'chown' command to make the Music folder owned by everyone and grant write access. Everyone acknowledges the file/directory because nobody and no group are users.
Likewise, you can reorganize your multimedia files in any way you see fit by creating new folders. For demonstration, we will establish a couple of extra subdirectories.
Add a few extra subdirectories inside the /mnt/NTFS public folder. Then, add some audio and video files to each of these folders.
Now tell miniDLNA where to find the media files. Modify the configuration file in your preferred text editor.
Make a list of all additional folders you've made to contain multimedia files in the line where you see 'media dir.' Just after the equal sign is a letter, ',' include the location of the files.
A: Audio
P: Picture
V: Video
PV: Pictures and Videos
Navigate a little farther down the page to specify where the DB and logs will get saved. Quit the editor and save the modifications you've just made.
Restart your minidlna server for the modifications to be reflected in the database and take effect. If everything is okay, the program should be functioning. Please check the status of the server.
Analyze the logs to confirm that everything is functioning as intended.
Just keep an eye out for warning logs. There are claims it can manage up to 8192 folders and subfolders. If you have a more extensive selection, you can change the value of your collection to make it more valuable.
/proc/sys/fs/inotify/max_user_watches. But, this will not survive a reboot.To keep the value set indefinitely. Modify the document /etc/sysctl.conf.
At the very end, add the following sentence:
This can be accomplished in a variety of ways. Here's an easy one:
It's done. However, keep in mind that indexing and cataloging massive data will take longer. The cataloging process might take a little longer at times.
Use Plex to set up a media server for your home.Choose Plex Media Server from the menu button of the official website, then Linux from the left-hand platform drop-down, and select the Choose Distribution button there.
If you're looking for an ARMv7-based distribution, choose Ubuntu (16.04+) or Debian (8+), then save the image. Then follow the steps below to install.
Installing WinSCP is as simple as going to the official website and downloading the software. Run the program you downloaded and installed after it has finished downloading and installation.
Once you've logged in, you should see the local Computer system files on your left side and the Raspberry Pi system files on the other side.
Locate the Plex Storage Server you already downloaded, right-click on it, and select Upload. On the raspberry home directory, the file will be stored there.
Using a secure shell, you may download plex with the wget command from your Raspberry Pi. Direct access to the application file is required to download the entire package. Copy the link address of the application by right-clicking on it and selecting "Copy Link Address."
To download a specific package, run wget accompanied by the URL link and press return on your pi terminal.
The package is saved to the current working directory after downloading.
Connect to the Pi through a secure shell using PuTTY. You should be in the root directory. The program 'ls' output will reveal the file that was previously.
We'll now use the dpkg tool to complete the installation.
IMPORTANT: The filename must match exactly what appears in the secure shell terminal. The reference name of the command is just for illustrative purposes.
Press the return key then you'll be prompted for additional verification. Please accept them, and it'll be deployed as intended. Once the server has been set up, it may be found at:
Whenever you launch the service for the first time, it will prompt you to check in to the Plex account. Once you've entered your username and password, the page should reroute to the local server.
The OS makes it more difficult to mount a hard drive in headless mode. Using this method, you should be able to get everything you need to get this working.
Use the following command to make a new directory in the media directory:
To make a copy of your system's /etc/fstab, type the command:
To identify the external HDD, type the command:
The name may differ if you're looking for the sda2 (/dev/sda2).
Type the command below to obtain the partition Block ID:
There is a LABEL to identify this drive and its type as NTFS, which you can see by looking at the printout. You may also get it as ext4, depending on the format.
The following command is used to modify the /etc/fstab file:
Insert this line in the file:
This UUID is the one that we acquired when we checked the id of the block in the steps above. Ntfs or ext4 should be the file system on the attached drive.
Hit Ctrl + O to save the file, followed by Ctrl + X to quit; the file is saved.
Reboot the Pi while the HDD is still plugged, and then run the df program once more to make everything work as it should. A working /media/HDD mount is still required.
If something goes wrong during this stage, getting the server up and running again will be more challenging.
The Plex app can is found on the Internet by browsing the following address:
Then, click the settings button displayed below.
Navigate to MANAGE > LIBRARIES from the left menu. Libraries are now clearly visible. Select "Add Library" from the drop-down menu. You should now be able to select a media type from a new popup:
Click Next, then Browse for a Multimedia Folder to select the files you want to use. The hard drive will be as seen in the image below. To upload media, click Add and then choose the media directory from which you want to add it.
At this point, the service should begin searching for your files. Depending on the content and the volume of data in the folder, this could take a while to accomplish.
The server-side plex setup is now complete and operational. You can now choose from a variety of ways to consume your media.
You'll be able to watch movies, web series, and live TV through the client application and your local media files.
This tutorial taught us to set up a free media server on Raspberry Pi. It is now possible to stream and organize your media files attractive and portable manner. In the following tutorial, we will learn how to use a raspberry pi as a DNS server.
Hello friends, I hope you all are doing great. Today, we are going to share the 2nd tutorial of Section-VIII in the Raspberry Pi Programming Course. In the previous tutorial, we interfaced a Barcode Scanner with Raspberry Pi 4. In today's tutorial, we will discuss how to set up a web server in raspberry pi. So, let's get started:
We are going to use the following components, in today's project:
When configuring a Raspberry Pi, select the expand FileSystem option to ensure that all of the Micro SD storage is allocated for the operating system and modify the default Pi passwords to protect your server from attackers.
Next, we will install the web server. As a result of its minimal memory footprint and compatibility with Node.js, We use Nginx as our web server. Apache or Lighttpd web servers could also be used.
Run ifconfig to discover the IP address of your Rpi. Your ethernet adapter's output will be found under eth0.
After discovering the IP addresses, you can direct your browser to it and expect to receive the default Welcome message for Nginx.
If you don't intend to get access to your Raspberry Pi from elsewhere in your local area network, the following step is unnecessary. Those who wish to connect to their server from a different area should nevertheless be able to do so.
It is common for devices connected to a router in a domestic home networking environment to appear hidden from view. The external IP address of your network can only be used to access your router. Those devices can receive incoming traffic depending on your router's decision-making abilities.
As soon as you access a web page, the router understands that the response traffic is associated with that connection, and it will allow it through. It's possible to get around this by using a router that blocks incoming traffic that isn't part of a currently open connection (like whenever an external device tries to connect to a local device). This is a critical network safety precaution!
From the outside, how can you access your Pi's onboard network? What you need to do is to use port forwarding. Incoming connections on specific ports must be allowed to travel through the gateway and then sent to the specified device. Default by HTTP and SSH protocols use ports 80 and 22. Therefore, opening these ports in your router will enable users to access the web app and secure connections to manage the server.
Enable and forward a port on your gateway using the advanced configuration settings on the admin site. A simple search for "Forwarding," "Port Forwarding," or "Network Address Translation" will yield the results you need.
For Hypertext transfer protocol, one port must be opened, and a different port must be opened for secure shell protocol. The central concept is to have your Rasp Pi forward traffic addressed to the two ports: port 80 for Hypertext transfer protocol traffic and port 22 for Secure shell protocol traffic. Here's an illustration of what your router's setup page may look like if you applied this:
In case the IP address of your rasp pi is 192.168.1.16, you'll need to configure port forwarding. We use this address to forward all incoming connections to the Internet.
The external Internet address of your router can be found on Google by searching "what's my IP address."
Establish a Secure shell connection using the command below once you've left your router's network to confirm if forwarding is working.
Similarly, you may check for Hypertext transfer protocol forwarding by redirecting your web browser to the external IP address. However, it's essential to know that port forwarding lets anyone with knowledge of the external IP of your router access this port.
Static IPs aren't necessary with dynamic Domain name servers. It's a straightforward procedure. You can use your router to set up a dynamic Domain name server, or you can use a Raspberry Pi to do it.
Cloudflare's API is used to connect to the newest version of ddclient. After downloading directly from Sourceforge, we'll copy and paste the program.
To configure the Cloudflare protocol, we need to set up ddclient. Cloudflare details like our address, API secret and time zone, and records will be required to make the changes.
The values procured are as such:
Using the asterisks marks, we will alter the script with the change above:
We will test to ensure that our hostname is updated correctly. Here is the command we'll use:
The following notice will appear on our screens:
This section will teach you how to run JavaScript in a full-stack environment on Nginx. Installing Node.js and MongoDB is required to perform this.
Installing Node.js on a Raspberry Pi has never been easier.
Once the installation is complete, use Node -v to see if it's working.
You can now install MongoDB simply by entering the command:
To maintain database integrity, you must stop the service on the Raspberry Pi before you can turn the raspberry pi off.
Developing an application locally and later pushing any modifications to a BitBucket repository is possible. The pre-installed version of Git on Raspberry pi 4 makes it easy to download and run your most recent program code.
Let's create a Git repo and add some program code to it. We will start an application using the generator-angular-full stack, which scaffolds the server and client code.
This is how you get angular running on your computer:
A new directory is created for your application:
And then build the app:
The following instructions will walk you through setting up a BitBucket repository.
Next, create a directory on your computer's hard drive:
As a result, the code can be committed and pushed:
The grunt-build-control tool is included with the generator to keep track of your builds. Add the BitBucket config to Gruntfile.js in the root folder of your app:
Create a folder for distribution by running the following command:
The code should be committed and pushed to your repository's build branch.
Your code is already on a server for your convenience. You will require a secure shell key for your Raspberry before using it on your BitBucket account for deployment. As a result, login to the Raspberry desktop and generate a public/private key from the terminal:
Afterward, launch the agent:
Also, provide the agent with the key:
Now you need to output the content of the public key:
Now copy and paste it into BitBucket.
Configure your BitBucket account by clicking on your profile image. Click on the Add keys tab under the SSH section of SECURITY.A /var/www folder can serve as a place to store all of your application's code, but it's not a necessity.
To eliminate the need for sudo, you can make your Raspberry user the owner and www-data the group when you place the files inside the webroot:
Cloning your repo build branch and installing the required dependencies is now possible.
Now you may launch your application in production mode:
Open a web browser and type in the device's Internet protocol address to see if it works.
One final step must be taken before the application can be accessed from the outside world. Even though Nginx listens on port 80 to receive Hypertext transfer protocol requests for your Raspberry Pi, the Node app will be listening on another port. Configure Nginx to reverse proxy to recognize requests for your app and pass them forward to Node.
The sites-available subdirectory is where Nginx stores the configuration files for all of the applications it serves:
Download and modify the config file from here.
With Nginx set as a server proxy, the finished config file will look like the following:
Creating a symlink inside the sites-enabled directory where Nginx searches for activated configurations during runtime is required to enable this config.
To make these modifications effective, you must reload the service.
As a result of the server "name my-app.dev" command you specified earlier, your app is now available to receive hypertext transfer protocol traffic addressed to the my-app.dev domain. You must now figure out how to make the traffic you transmit from outside this domain name resemble this domain name as your final challenge. The host file eliminates the need to purchase a domain and link it to your Internet address.
The external Internet address of your router should be entered on the workbench from which you intend to visit the site, and the host my-app.dev should be entered in the same place. The correct domain name will be included in the Host hypertext transfer protocol header in any HTTP communication you send to my-app.dev.
If you want to keep the servers running, you can install pm2 on your Raspberry Pi, and In the event of an error, you can erase the MicroSD card and start over.
A JavaScript application can be accessed beyond your network since deployment is possible on your new home development server.
Managing the equipment you use for development while working from far is a huge benefit.
PI Server Applications' responsibility is to gather, store, and retrieve mathematical and text data.
Engineers can analyze and evaluate the entire plant with the help of this Software. It all begins with the PI Server Applications. Numbers and strings are all handled by computers in the same way: collected, stored, and retrieved. Additionally, the PI Information Archive serves as a data provider for Windows-based apps used by researchers, engineering teams, and other plant staff to access the plant data contained in the Archive's database. In most cases, the PI Servers Application runs on a network of computers running different software packages.
The following are some examples of PI Server Applications:
This tutorial taught us to set up a webserver in our Raspberry pi. We also learned how to configure and create a repository for our app and deploy it. However, In the following tutorial, we will learn how to use a raspberry pi as a media server.
Hello readers, I hope you all are doing great. In our previous tutorial, we discussed the implementation of pulse width modulation (PWM) in Raspberry Pi Pico using the MicroPyton programming example. We also implemented the LED brightness control program to demonstrate an application of the pulse width modulation technique.
In this tutorial, we are going to implement another application of pulse width modulation technique which is ‘Direction and position control of a servo motor’ with Raspberry Pi Pico module and MicroPython programming language.
Later in this tutorial, we will also discuss how to control the position of a servo motor with push buttons (to be used as control inputs) and also to use LEDs for indication purposes.
Before interfacing the servo motor with the Raspberry Pi Pico module, let’s first understand the behavior of a servo motor and how it is different from a DC electric motor.
There are several applications for electric motors in which the motor must only rotate at a specific angle. We need a special type of motor with a special arrangement that causes the motor to rotate at a specific angle for a given electric signal (input) in such applications, or we can call it an angular precision motor. The Servo motor is used in these types of applications.
A servo motor is a low-cost, high-power output device that can only rotate 180 degrees (90 degrees in each direction) and can control the angle of rotation anywhere within that 180-degree range.
Fig. 1 Servo motor
Technically speaking, a servo motor is a linear or rotary actuator that can control acceleration, linear or angular position, and velocity with precision. It consists of a motor and a position feedback sensor. It also requires a sophisticated controller, which is often a dedicated module designed specifically for use with servo motors.
The main feature of using a servo motor is that it has angular precision, which makes the motor capable of rotating as far as we want it to before stopping and waiting for the next input signal from the microcontroller (or Raspberry Pi Pico in this project). Unlike a standard DC electric motor, the servo motor starts turning as soon as the power supply is applied to it and continues to rotate until the power is turned off. On the other hand, we cannot restrict the rotational progress of the DC motor, but we can control its speed of rotation and turn it on and off or we can say that the DC motor does not have angular precision. Small servo motors are available there in numerous Arduino launcher kits (beginners) since they are simple to use in small electronic projects and applications.
A servo motor is mostly used in obstacle detector/avoidance robots and robotic arms.
We have already published tutorials on how to download and install the above mentioned software components.
Follow the given link for a detailed study of Raspberry Pi Pico: https://www.theengineeringprojects.com/2022/04/getting-started-with-raspberry-pi-pico.html
A servo motor is controlled by sending a PWM or pulse width modulated signal. A servo motor can only turn for a total of 180 degree movement (90 degree in either direction).
Pulse width modulation technique is used to control the amount of power delivered to the load for a particular time. The pulse width modulated signal sent to the motor specifies the position of the shaft, and to turn the rotor into a desired position depending on the duration of the pulse sent through the control wire.
The major factors affecting the behavior of pulse width modulation are frequency and duty cycle. Frequency defines the number of cycles per second or it is the reciprocal of total time ‘T’.
Frequency = 1/ T
Where, T= ON time + Off time
The duty cycle determines the time for which the output pulse from the Raspberry Pi Pico is high.
Duty Cycle = ON time/ T
Fig. Interfacing servo motor with raspberry pi pico
Servo motor consists of three wires; red, brown and yellow. Two wires are for VCC and ground and the third one is the data or control pin. The servo motor we are using operates at 5V dc supply so the red wire of the motor is connected to the VBUS pin of raspberry Pi Pico board. The interfacing of servo motor with raspberry Pi Pico module is shown in Table1.
Table 1 Raspberry Pi Pico and servo motor interfacing
To program Raspberry Pi Pico board there are various development environments available (like uPyCraft IDE, Visual Studio Code, Thonny IDE ect.) and multiple programming languages as well.
In this tutorial, we are going to use Thonny IDE to program the Raspberry Pi Pico board.
We have already published a tutorial on installing Thonny IDe for Raspberry Pi Pico Programming on our website. Follow the given link to install the IDE: https://www.theengineeringprojects.com/2022/04/installing-thonny-ide-for-raspberry-pi-pico-programming.html
Fig. 4 New Project
Fig. 5 Select Interpreter
Image: 6 MicroPython for raspberry Pi Pico programming
Image: 7 Ready to program
Fig. 8 Importing libraries
Fig. 9 object declaration
Fig. 10 PWM frequency
Fig. 11 Changing angular position continuously
Fig. 13 Save the program
Fig. 14 Save the program
Fig. 15 Run the saved program
from machine import Pin, PWM
import time
# declaring pwm object for servo motor pin i.e., GPIO_1
pwm = PWM(Pin(0))
# setting PWM frequency at 50Hz
pwm.freq(50)
while True:
for position in range(1000, 9000, 50): # changing angular position
pwm.duty_u16(position)
time.sleep(0.1) # delay
for position in range(9000, 1000, -50):
pwm.duty_u16(position)
time.sleep(0.1) # delay
Fig. 16 Raspberry Pi Pico and servo motor
That’s all about interfacing and controlling a servo motor with Raspberry Pi Pico module and pulse width modulation.
So far in raspberry Pi Pico programming series, we discussed and demonstrated the interfacing of output devices with raspberry Pi Pico board.
Now let’s take another example, where we are going to control the direction of rotation of a servo motor using push buttons which are acting as control inputs and we are also using LEDs (outputs) as indicators for various positions.
GPIO stands for General Purpose Input Output which means a GPIO pin can be configured both either as an input or an output pin. In raspberry Pi Pico (RP2040) module we have 30 GPIO pins and hence any of them can be used either as input or output pin.
Push button is used as an input component to trigger some event or an interrupt in microcontrollers. So here in this example, we are using some push button as control inputs to control the direction of rotation in a servo motor.
Push button operates in two logic states, Digital High and Digital Low. A push button can be connected with raspberry Pi Pico either in pull-up or in pull-down mode. In pull-down mode, when the button is presses the GPIO input will be in logic high and otherwise the input will be logic zero. On the other hand in pull-up mode the GPIO input will be in logic low state when the button is pressed and vice versa.
A schematic is attached below representing the interfacing of a push button with raspberry pi Pico:
Fig. 17 Push button interfacing
Most of the programming instructions will remain similar to the previous example with some additional instruction to interface LEDs and Push buttons and assigning their respective task.
Fig. 18 led object declaration
Fig. 19 Push button object Declaration
Fig. 20 Push Button 1
Fig. 21 Push button 2
Fig. 22 Push button 3
Fig. 23 Interfacing push button, servo motor and LEDs with Pico board
Fig. 24
from time import sleep
from machine import Pin, PWM
# declaring pwm object for servo motor
pwm = PWM(Pin(0)) # PWM pin for Servo motor
# declaring led object
led1 = Pin(5, Pin.OUT)
led2 = Pin(6, Pin.OUT)
led3 = Pin(8, Pin.OUT)
led4 = Pin(9, Pin.OUT)
led5 = Pin(10, Pin.OUT)
led6 = Pin(13, Pin.OUT)
led7 = Pin(14, Pin.OUT)
led8 = Pin(15, Pin.OUT)
led9 = Pin(15, Pin.OUT)
led10 = Pin(16, Pin.OUT)
led11 = Pin(17, Pin.OUT)
led12 = Pin(18, Pin.OUT)
led13 = Pin(19, Pin.OUT)
led14 = Pin(20, Pin.OUT)
led15 = Pin(21, Pin.OUT)
led16 = Pin(22, Pin.OUT)
# object declaration for push buttons
button_1 = Pin(26, Pin.IN)
button_2 = Pin(27, Pin.IN)
button_3 = Pin(28, Pin.IN)
pwm.freq(50) # set PWM frequency for servo motor
def led_blink (x):
led1.value(x)
led2.value(x)
led3.value(x)
led4.value(x)
led5.value(x)
led6.value(x)
led7.value(x)
led8.value(x)
led9.value(x)
led10.value(x)
led11.value(x)
led12.value(x)
led13.value(x)
led14.value(x)
led15.value(x)
while True:
button1_state = button_1.value()
if button1_state == True:
for position in range(1000,5000,50):
pwm.duty_u16(position)
led13.value(1)
sleep(0.01)
led13.value(0)
button2_state = button_2.value()
if button2_state == True:
for position in range(5000,9000,50):
pwm.duty_u16(position)
led14.value(1)
sleep(0.01)
led14.value(0)
button3_state = button_3.value()
if button3_state == True:
for position in range(1000,9000, 40):
pwm.duty_u16(position)
led_blink(1)
sleep(0.05)
for position in range(9000, 1000, -40):
pwm.duty_u16(position)
led_blink(0)
sleep(0.05)
The results observed are attached below. In the image attached below, we can see the difference in the servo motor’s shaft position when compared with the previous image (off state).
Fig. 25 Servo motor control with push buttons
In this tutorial, we implemented another application of Pulse width modulation technique with Raspberry Pi Pico module and MicroPython Programming language. We also learn how to use Raspberry Pi Pico’s GPIO pins to receive input from peripheral devices.
So, this concludes the tutorial. We hope you found this of some help and also hope to see you soon with a new tutorial on raspberry Pi Pico programming series.
Welcome to the next tutorial of our Raspberry Pi programming course. Our previous tutorial taught us to how to print from a Raspberry pi. We also discussed some libraries to create a print server in our raspberry pi. We will learn how to take screenshots on Raspberry Pi using a few different methods in this lesson. We will also look at how to take snapshots on our Raspberry Pi using SSH remotely.
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Breadboard | Amazon | Buy Now | |
2 | Jumper Wires | Amazon | Buy Now | |
3 | PIR Sensor | Amazon | Buy Now | |
4 | Raspberry Pi 4 | Amazon | Buy Now |
This article will assist you when working with projects that require snapshots for documenting your work, sharing, or generating tutorials.
Screenshots are said to be the essential items on the internet today. And if you have seen these screenshots in tutorial videos or even used them in regular communication, you're already aware of how effective screenshots can be. They are quickly becoming a key internet currency for more efficient communication. Knowing how and when to utilize the correct ones will help you stand out from the crowd.
In this case, we'll employ Scrot, a software program, to help with the PrintScreen procedure. This fantastic software program allows you to take screenshots using commands, shortcut keys, and enabled shortcuts.
Scrot is already installed by default in the latest release of the Raspbian Operating system. In case you already have Scrot, you may skip this installation process. If you're not sure whether it's already installed, use the command below inside a pi Terminal window.
If your Pi returns a "command not found" error, you must install it. Use the following command line to accomplish this:
After installing it, you may test its functionality by using the scrot instruction again. If no errors occur, you are set to go on.
Capturing a snapshot on a Raspberry Pi isn't difficult, especially if Scrot is installed. Here are a handful of options for completing the work.
If you have the Scrot installed on your Pi successfully, your default hotkey for taking screenshots will be the Print Screen key.
You can try this quickly by pressing the Print Screen button and checking the /home/pi directory. If you find the screenshots taken, your keyboard hotkey (keyboard shortcut) is working correctly.
In addition, screenshots and print screen pictures will be stored with the suffix _scrot attached to the end of their filename. For instance,
This is easy as pie! Execute the following command on your Pi to snap a screenshot:
That is all. It is that easy.
The following approach will not work unless you have the navigation closed and have to snap a screenshot without the menu. To get a perfect snapshot with no menu, you must wait a few seconds after taking the picture. You may then close your menu and allow the Scrot to initiate the image capture.
To capture in this manner, send the following command to postpone the operation for five seconds.
Other Scrot settings are as follows:
You might need to give the images a unique name and directory on occasion. Add the correct root directory, followed by the individual title and filename extension, exactly after scrot.
For instance, if you prefer to assign the title raspberryexpert to it and store it in the downloads directory, do the following command:
Remember that the extension should always follow the file name .png.
If the capture command isn't already mapped as a hotkey, you'll have to map it by altering your Pi's config file, and it'll come in handy.
It would be best if you defined a hotkey inside the lxde-pi-rc.xml script to use it. To proceed, use this syntax to open the script.
We'll briefly demonstrate how to add the snapshot hotkey to the XML script. It would be best to locate the <keyboard> section and put the following lines directly below it.
We will map the scrot function to the snapshot hotkeys on the keyboard by typing the above lines.
Save the script by hitting CTRL X, Yes, and afterward ENTER key when you've successfully added those lines.
Enter the command below to identify the new changes made.
You may discover that taking snapshots on the raspberry is impractical in some situations. You'll need to use SSH to take the image here.
When dealing with Ssh, you must first activate it, as is customary. You may get more information about this in our previous tutorials.
Log in with the command below after you have enabled SSH:
Now use the command below to snap an image.
If you've previously installed the Scrot, skip line 2.
Using the command below, you can snap as many snapshots as you like using varying names and afterward transferring them over to your desktop:
Remember to change the syntax to reflect the correct username and Ip.
you can snap a screenshot and save it immediately to your Linux PC. However, if you regularly have to take snapshots, inputting the passcode each time you access the Rpi via SSH will be a tedious chore. So you can use publicly or privately keys to configure no passcode ssh in raspberry pi.
To proceed, use the following command to install maim on raspberry pi.
Return to your computer and use the command below to take a snapshot.
We're utilizing the maim instead of other approaches since it's a more elegant method. It sends the image to stdout, allowing us to save it to our laptop via a simple URL redirect.
Raspi2png is a screenshot software that you may use to take a screenshot. Use the code below for downloading and installing the scripts.
After that, please place it in the /usr/local/bin directory.
Enter the following command to capture a screenshot.
Ensure to use your actual folder name rather than <directory_name> used.
Because we are using a GUI, this solution is relatively simple and easy to implement.
First, use the following command to download the GNOME Snapshot tool.
After it has been installed, go to the Raspberry navbar, select the menu, select Accessories, and finally, Screenshot.
This opens the GNOME Picture window, where you can find three different taking options, as seen below.
Choose the appropriate capture method and select Capture Image. If you pick the third choice, you will have to use a mouse to choose the location you wish to snip. If you use this option, you will not need a picture editor to resize the snapshot image. The first choice will record the entire screen, while the second will snip the active window.
GNOME gives you two alternatives once you capture a screen. The first is to save the snapshot, and the other is to copy it to the clipboard. So select it based on your requirements.
It all begins with a simple screenshot. You don't need any additional programs or software to capture a basic screenshot. At this moment, this feature is built into almost all Raspberry Pi versions and Windows, Mac PCs, and cellphones.
It is the process of capturing all or a part of the active screen and converting it to a picture or video.
While it may appear the same thing as a screenshot and a screen capture, they are not the same. A screenshot is simply a static picture. A desktop window capture is a process of collecting something on the screen, such as photographs or films.
Assume you wish to save a whole spreadsheet. It's becoming a little more complicated now.
Generally, you would be able to record whatever is on your window. Still, in case you need to snip anything beyond that, such as broad, horizontal spreadsheets or indefinitely lengthy website pages, you'll need to get a screen capture application designed for that purpose. Snagit includes Scrolling snapshot and Panorama Capture capabilities to snap all of the material you need in a single picture rather than stitching together many images.
This is a GIF file containing a moving image. An animated succession of picture frames is exhibited.
While gif Images aren't limited to screen material, they may be a proper (and underappreciated) method to express what's on your display.
Instead of capturing multiple pictures to demonstrate a process to a person, you may create a single animated Version of what is going on on your computer. These animations have small file sizes, and they play automatically, making them quick and simple to publish on websites and in documents.
This is making a video out of screen material to educate a program or sell a product by displaying functionality.
If you want to go further than a simple snapshot or even gif Animation, they are a good option. If you have ever looked for help with a software program, you have come across a screencast.
They display your screen and generally contain some commentary to make you understand what you are viewing.
Screencasts can range from polished movies used among professional educators to fast recordings showing a coworker how to file a ticket to Information technology. The concept is all the same.
Using screenshots to communicate removes the guesswork from graphical presentations and saves time.
The snapshot tool is ideal for capturing screenshots of graphical designs, new websites, or social media posts pending approval.
This is a must-have tool for anybody working in Information Technology, human resource, or supervisors training new workers. Choose screenshots over lengthy emails, or print screen pictures with instructions. A snapshot may save you a lot of time and improve team communication.
Furthermore, by preserving the snapshot in Screencast-O-Matic, your staff will be able to retrieve your directions at any time via a shareable link.
To avoid confusion, utilize screen captures to show. IT supervisors, for instance, can utilize images to teach their colleagues where to obtain computer upgrades. Take a snapshot of the system icon on your desktop, then use the Screen capture Editor to convert your screen capture into a graphical how-to instruction.
Any image editing tool may be used to improve pictures. You may use the highlighting tool to draw attention to the location of the icons.
Everybody has encountered computer difficulties. However, if you can't articulate exactly what has happened, diagnosing the problem afterward will be challenging. It's simple to capture a snapshot of the issue.
This is useful when talking with customer service representatives. Rather than discussing the issue, email them an image to help them see it. Publish your image immediately to Screencast and obtain a URL to share it. Sharing photos might help you get help quickly.
It can also help customer support personnel and their interactions with users. They may assist consumers more quickly by sending screenshots or photographs to assist them in resolving difficulties.
Snapshots are a simple method for social media administrators to categorize, emphasize, or record a specific moment. Pictures are an easy method to keep track of shifting stats or troublesome followers. It might be challenging to track down subscribers who breach social network regulations. Comments and users are frequently lost in ever-expanding discussions.
Take a snapshot of the problem to document it. Save this image as a file or store it in the screenshots folder of Screencast. Even if people remove their remarks, you will have proof of inappropriate activity.
This tutorial taught us how to take screenshots from a Raspberry Pi using different methods. We also went through how to remotely take snapshots on our Pi using SSH and discussed some of the benefits of using the screenshot tool. However, In the following tutorial, we will learn how to use a raspberry pi as a webserver.
Welcome to the next tutorial of our Raspberry Pi programming course. Our previous tutorial taught us to how to tweet from Raspberry pi. We also discussed some methods used by the tweepy library to perform some API calls in our project. We will learn how to print from a Raspberry pi in this lesson.
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Raspberry Pi 4 | Amazon | Buy Now |
There are several benefits of having a print server. Print servers may link numerous computers to one or multiple printers, either physically or wirelessly, allowing you to access the printer with various devices and send print instructions from all the other connected computers.
It is not easy to print from an Android smartphone to a cabled printer; however, a printer server makes it simple. A print server is useful in small workplaces where employees may print from any business printer. Another benefit is that we do not need to install drivers and software for the printer on your devices.
The Common Unix Printing System is a printing tool for machines running UNIX-like operating systems. It enables the machine installed to function as a printer server. A CUPS-enabled computer may take tasks from numerous devices, process them, and send them to the right printer for printing.
With our Raspberry terminal, we will configure the typical Unix printing system.
We need to ensure that our Pi runs the most recent software; thus, we will carry out the following command in the terminal.
Once the installation is finished, we will restart our raspberry pi.
A few system changes are required before utilizing the Pi as a "server" on the network. We must configure the dynamic host configuration protocol client to use a static Ip; otherwise, the DHCP client may choose any accessible network address, making it difficult to access the RPi over the network.
We begin by modifying the DHCP configuration file.
If you choose to create a static Ip for the wired connection or a Wi-Fi connection, add either one of the below.
Save your file by pressing Ctrl Plus X, then Yes, finally Enter key. Lastly, restart your Raspberry Pi.
Note that your network setup may differ in address category and Ip. This step must be done carefully; otherwise, your Pi will experience connection troubles. Run the following commands and look at the inet and subnet mask numbers to know what IP address you'll need:
The next step is to set up CUPS. This will take some time, but it will install with other requirements such as Samba, Perl, and several other tools or packages.
We have to make adjustments to CUPs' config file. The following commands can be used to edit the configuration file:
To the config file, add the following. We will be able to communicate with CUPS panels due to these modifications.
If you wish to change the Ip port, locate and modify this line.
In addition, if we want to use the CUPS Interface, you must accept requests coming from that domain. Just before <location> tags, we add these lines.
Save your file by pressing Ctrl + X, then Yes, accompanied by the Enter key.
The Raspberry user is then added to the lpadmin group. This allows the RPi to conduct CUPS administration duties without being a superuser.
We must guarantee that CUPS is available throughout the network.
Lastly, reboot CUPS to apply the modifications.
Samba is an industry-standard Microsoft interoperable package for Unix systems. It allows our Windows operating system to connect to our CUPS central server on the Raspberry Pi and transmit print instructions from the Windows system.
We have to change Samba's settings in the config file before we can proceed with the setup:
Scroll down to the print area and alter the guest's ok to yes.
Scroll down to the printer driver area and change the line shown below
Save the script by pressing Ctrl Plus X, then Yes, accompanied by the Enter key.
Lastly, reboot Samba to see the modifications take effect:
You may need to install printer drivers. You can look for the instructions for your specific printer brand on the internet, but we'll be using an HP printer for this lesson.
Install the following GUI if desired:
Then run the command below and download the displayed package from HP.
Link your computer to the network your Raspberry is in. Open the internet browser and navigate to the CUPS site by providing your Pi IP followed by port ":631," to which CUPS is connecting. If the internet browser displays the message "Connection not secure," select "Proceed Anyway."
You may find your Pi IP by running hostname -I on your Pi terminal. If all goes well, the website is:
Navigate to the Admin page and choose Add Printer. Ascertain that you turn the printer on and hook it to the Raspberry through USB. Follow the on-screen instructions to set up the printer. Check the "share this printer" checkbox before proceeding to the last stage. Lastly, print a sample page on the Printers tab to ensure that everything is working correctly.
Please remember that the printer might not be shown under "Local Printers." If this is the situation, you must configure the necessary printer drivers in your Raspberry Pi.
The last step is to transmit print instructions using any connected devices. After that, you can print wirelessly from Linux, Microsoft, Macintosh, Android, and apple. There is no need to install additional printer drivers for this.
This is the final and most straightforward step, in which we will wirelessly communicate print instructions to our printer. You must have CUPS installed on your Raspberry and print a sample page using the CUPS Web-based interface. Any gadget you would like to print from must be on the Pi network.
You must have Samba installed and set up on your Pi for this to function.
Navigate to Settings and select "Add a printer or scanner." This will automatically detect the network printer, and you may add it by clicking "Add Device."
Select "The printer that I want isn't displayed if it doesn't work."
The queue name, in this case, is like the printer's queue name in the Printers tab of the CUPS web-based interface.
You may add a wireless printer to a Linux desktop by going to GNOME Preferences- Devices and Printers. The procedure would be relatively similar in other Linux distributions.
The wireless printer will be discovered and added automatically. If that doesn't work, you might need to add the printers by entering the Ip of the Raspberry Pi.
At the bottom, press the Plus button. The printer will be detected automatically by Mac. Select and then click Add.
The system includes a Print Function in Android. For previous versions, you must install the CUPS Print plugin. Then go to Settings -Devices Connected -Connectivity- Preference Printing and activate the CUPS Printing plugin. You may start the Print Capability in Oreo and later versions.
For printing a paper or file, open the files in a printing-compatible app. Go to Options Print, choose your printer, and press the print button.
There was an issue that occurred after installing a printer. The printer only printed a few jobs and ignored the rest. I had to reboot either the Raspberry Pi or the printers to resume printing. The command below resolved this issue:
If you haven't yet experienced the pleasures of wireless connection printing, this project is a great place to start. But what's the point of wireless printing?
Wireless connected printers enable users to work effectively on the go because there are no cables attaching the printer to a particular spot. This may be useful in various industries, from retail, where sales associates can construct more checkout stations during busy periods, to logistics, where haulage carriers must track the weights of their vehicles.
Organizations with mobile workers, such as health & security inspectors, may profit from wireless communication because employees can print their invoices, records, and results right away – instead of having to go back to their offices.
Instead of struggling to access your business services to download discs, these wireless printers work efficiently. The benefits of a wireless connection are limitless. It allows business employees to produce receipts, examination data, tickets, and labels with a single click and return to their job with minimal interruption.
Wireless printing can also eliminate the requirement for Wi-Fi using iOS and Android technologies, allowing mobile employees, public transportation drivers, and law enforcement officers to print files regardless of their place.
Wi-Fi printers use infrared technologies to connect to other devices and quickly produce high-quality banners, receipts, and bar codes. The printer may increase doctor efficiency while drafting patient information if it is equipped with pre-cut labels and provide major benefits to CSI teams, who can now immediately manufacture evidence tags at crime scenes.
Depending on your company's needs, a single printer can serve various functions. While a shop manager may utilize a mini-printer for everyday receipt production, they could also opt to use the same printers to print tickets for exclusive launch events, therefore, lowering equipment expenses.
Because the printer is small and portable, employees may set it wherever needed. The printers provide excellent space-saving solutions for better printing efficiency and the ability for many users to connect to a single printer to cut the cost of buying extra resources.
These printers are intended to reduce waste, which is very important for conferences and seminars. Workers may print on demand since the printer does not have to be supplied with pre-printed tickets, avoiding the possibility of an unneeded surplus.
Wi-Fi printers are advantageous to small stores, like start-ups or pop-ups, since they are not well-established companies.
With a bit of investment in such a payment service and a portable printer, business owners may accept card payments at gatherings or establish temporary kiosks in existing businesses and cafés.
Despite their small size, Wi-Fi printers have a considerably longer battery storage life that may last weeks or even months on standby. This implies you won't have to pay a high electricity cost, and you won't have to resupply every day.
Wi-Fi printing makes printing more flexible, making it an excellent project for Raspberry Pis. The advantage of this approach is that it is compatible with Microsoft operating system, Macintosh, and other Linux distribution systems.
Decades ago, some individuals stopped sending these cards and letters. But there's nothing quite like receiving a handmade letter from someone. Your printer offers multiple options for printing in various sizes.
You could even use an inkjet printer to print creative design work if you're a creative individual. Because inkjet ink offers a much more accurate and vibrant color representation than laser ink, we recommend utilizing them instead of laser printers.
There is no better method to share professional details with customers than offering them a professional card nowadays. Ordering these cards, on the other hand, is shockingly costly.
Are you preparing a great social event or party? Prepare your paper napkins by printing something unique on them. That's right: you can personalize your napkins with photos, graphics, initials, logos, and other details.
With this capability, you can elevate that special event or family dinner to a whole new level. Furthermore, if you own a modest business that offers personalized napkins, it is really a fantastic option to work from home.
In this tutorial, we learned how to print from Raspberry pi. We also learned some of the benefits of using a wireless printer. However, In the following tutorial, we will learn how to take a screenshot in our Raspberry pi.
Welcome to the next tutorial of our Raspberry Pi programming course. Our previous tutorial taught us to configure our raspberry pi for voice control. We also discussed some methods of reducing vexing noises so that the voice command program understands you. However, in this lesson, we will learn how to tweet from Raspberry pi.
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Raspberry Pi 4 | Amazon | Buy Now |
Assume you wish to add tweeting into a Raspberry Pi software you're developing. This article will show you how to build a Twitter app, get access privilege tokens, and post a tweet. On our Raspberry Pi, we'll make a simple program that tweets the result of the uptime command. This is a made-up example, but it demonstrates what is needed to tweet from a raspberry pi.
For this session, a repo has been set up. Because we'll be referring to code within the repository, cloning it will be helpful. You could use this program as a reference point for your programs or copy the components you need.
Let's start by installing git with the command below.
We're going to clone the repository into our current working directory now:
After that, change the directory into the repository.
The Twitter Application programming interface requires that all queries use OAuth for authentication. To access the Application programming interface, you must first create the authentication credentials. Four text strings make up these credentials:
If you're a Twitter account, go through the procedures below to get the keys, tokens, and secrets. If you don't have a Twitter account, you'll need to establish one first.
Visit Twitter's developer site to sign up for a new account. You must now select the Twitter subscriber in charge of this account. It's most likely going to be yourself or your company. This is how this page appears:
After that, Twitter asks you questions about whatever you want to utilize the developer's account, as seen below:
You must specify the developer account's username and whether it will be used for commercial or personal purposes.
Apps and not accounts have access to Twitter's authentication credentials. Every tool or program that uses Twitter's API qualifies as an app. To perform API calls, you must first register your application. Navigate to the Twitter applications page and click on the option to create an application to register the app.
The following details regarding your application and its aim must be provided:
Navigate to your Twitter applications page to generate the authentication credentials. This is how the Apps page looks:
The Details button for your app can be found here. After hitting this button, you'll be sent to the following page, on which you can obtain your credentials. You could generate and copy the keys to use in your code by selecting the Keys and Tokens tab:
Save the credentials after you've generated them to use them later in your code.
The following snippet can be used to test the credentials:
Ensure that the "Read, access, and write direct message" is ticked in the "Permissions" section.
Tweepy is a Library for python for utilizing the Twitter API, and it's included in the requirements.txt document, so all you have to do is:
Tweepy is a library that simplifies the Twitter application programming interface. Tweepy is a collection of functions and classes that mirror Twitter models and application programming interfaces, and it handles implementation details discreetly, such as:
If you didn't use Tweepy, you'd have to deal with low-level features like hypertext transfer protocol, data encoding, authorization, and speed limits. This may consume a lot of time and is subject to mistakes. Tweepy allows us to concentrate on the functionalities we wish to implement.
Tweepy can be used to access the Twitter application programming interface features. Let's have a simple example to see what we're talking about.
The example command below will download all of your tweets from your timeline and output each one to the console. Twitter mandates that all requests be authenticated using OAuth. Tweepy makes using OAuth simple for you. We'll need to establish an account for our application to get started. Build a new app, and when it's done, you should get your authentication token and secret. Keep these two with you at all times; you'll need them.
Next, create an instance of OAuthHandler. We enter our user token and secret, which we received in the previous line, into this:
If you're utilizing a callbacks uniform resource locators that need to be given dynamically in a web application, you will pass it in like this:
If the callback uniform resource locator isn't going to change, it's preferable to put it up as static on Twitter when creating your app.
Unlike basic authentication, we must first perform the OAuth "dance" before we can use the API. The steps below must be completed for this:
So, to start the dance, let's get our request token:
This call asks Twitter for a token and then provides the authorization uniform resource locator, to which the user should be redirected to approve us. Simply keeping our OAuthHandler object alive till the user returns is sufficient. In a web app, a callback will be used. As a result, the request token must be saved in the session because it will be required in the callback uniform resource locator request. A fictitious example of saving the request tokens in a session is as follows:
As a result, we can now redirect the visitor to the uniform resource locator returned by our authorization URL() function.
If it is a desktop program (or any other software that doesn't employ callbacks), we'll need to ask for the "verifier code" that Twitter will provide after they have authorized us. This verifying code is sent in the callback query from the Twitter account as a GET query argument in the URL within a web application.
The request token is then exchanged with an access token in the last phase. The access token is the "key" to the Twitter Application programming interface treasure chest. To obtain this token, we must perform the following steps:
It's good to keep the access token on hand if you need it later. It is not necessary to fetch it every time. Because Twitter does not currently expire tokens, they would become invalid only when the user revokes our application's access. Your application determines the location where you store the authentication token. Essentially, you must save two string values: secret and key:
You can save these in a database, a file, or wherever else your data is stored. To re-create an OAuthHandler using this cached access token, follow these steps:
Since we have an access token for our OAuthHandler, we can move on to the following step:
The application programming interface class gives you access to the Twitter RESTful API's entire methods. Each method can take different parameters and provide different results. The API methods are classified into the following groups:
These ways allow you to read mentions, tweets, and retweets on your timeline and any other public user's timeline.
These methods deal with tweet creation, retrieval, and retweeting. Tweepy is used in the following code to produce a tweet with specific text:
The functions in this group may be used to retrieve users using a filtering criterion, extract user data, and show followers for each user so long as the account is public.
This set of routines includes methods for following as well as unfollowing persons, requesting followers for a user, and displaying the profiles a user is following.
Using these methods, you may write and view your profile information. This code sample might be used to change your profile information, for example:
You can designate any twitter message as Liked or delete the Like tag if it has already been added using these API calls.
This collection of methods includes unblocking and blocking members and a list of blocked users. You can view the users you've blocked in the following way:
You may search tweets using these methods using language, text, and other filters. For instance, this code will return the ten latest public tweets in English that contain the term "Python":
This set of tools allows you to generate a list of the most recent developments for any place. Here's how to construct a list of worldwide hot issues, for example:
Streaming enables you to actively monitor tweets in real-time for those that meet particular criteria. This indicates the program waits for the latest tweet to be produced before processing it if no other tweets satisfy the requirements.
You must construct two objects to use streaming:
This is how you do it:
Most of the time, when we call an API method, we'll get a Tweepy class model object back. This will hold Twitter's data, which we can use in our program. The following code, for example, returns a user model:
The following are the model classes:
Let's assume you want to obtain a list of all the tweets that mention you, then like each one and follow the author. This is how we can go about doing it:
Since every tweet object given by the mentioned timeline() belongs to the Statuses class, you can use the following syntax:
Tweet.user property is also a user object. Follow() may add the author of that tweet to the list of individuals to follow. Using Tweepy models allows us to write concise and understandable code.
Maybe we can put a motion detector and a camera on our cat and tweet images of it. Alternatively, we could set up a temperature sensor and tweet some weather-appropriate status updates. We can also leave the repository unchanged and tweet the uptime command if we only want others to know our pi's load average.
You may take the Twitter presence to another level by creating your personal Twitter bots. You may use bots to automate content generation and other Twitter tasks. This may save time and provide a better user experience for your viewers. The Tweepy library hides numerous low-level Twitter application programming interface details, allowing you to concentrate on the logic behind your Twitter bots.
In this tutorial, we learned how to set up our tweeter app on our Raspberry pi. We also learned how to generate access tokens, set up our app's permissions, and send a tweet. However, In the following tutorial, we will learn how to print on a Raspberry pi.
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Breadboard | Amazon | Buy Now | |
2 | DC Motor | Amazon | Buy Now | |
3 | Jumper Wires | Amazon | Buy Now | |
4 | Raspberry Pi 4 | Amazon | Buy Now |
Like the Amazon Echo, voice-activated gadgets are becoming increasingly popular, but you can also construct your own with a Raspberry, a cheap USB mic, and some appropriate software. Simply speaking to your Raspberry Pi will allow you to search YouTube, view websites, activate applications, and even answer inquiries.
Because the Raspberry Pi lacks a soundcard or audio port, this project requires a USB microphone or a camera with a built-in microphone. If your mic only has an audio jack, look for an affordable USB soundcard that connects to a USB port on one side and has a headphone and mic output on the other.
For the Raspberry Pi, there are various speech recognition programs. We're utilizing Steve Hickson's Pi AUI Toolkit for this project since it is powerful and straightforward to set up and operate. You may install a variety of programs using the Pi AUI Suite. The first question is whether or not the dependencies should be installed. These are the files that the Raspberry Pi requires to work with voice commands, so pick Yes, then press Enter to agree.
Following that, you'll be asked if you wish to download the PlayVideo software, which allows you to open and play video content using voice commands. If you select Y, you'll be prompted to enter the location of your media files, such as /home/pi/Videos. It's worth noting the upper-case letters are crucial in this scenario. The application will tell you if the route is incorrect.
Next, you'll be asked if you wish to download the Downloader application, which explores the internet for files and downloads them for you automatically. If you select Yes, you will be prompted to enter an address, port, password, and username. If you're not sure, press Return to choose the default settings in each scenario for now.
Install the Google Texts to Speech Service if you require your raspberry pi to read the contents of the text files. Since it communicates to Google servers to translate text into speech, the Raspberry Pi must be hooked up to the internet to utilize this service.
You'll require a google user account to install this. The installation requests your username—press Return after completing this step. The Google password is then requested. Return to the previous page and type this.
You may also use the installer to download Google Voice Commands. This makes use of Google's speech-to-text technology. To proceed, you must enter your Google login and password once again.
Regardless of whether you choose Google-specific software or not, the program will ask if you wish to download the YouTube scripts. These technologies allow you to say something like "play pi tutorial," An appropriate video clip will be played—press Return after typing a new welcome. You can also enable the silent flag to prevent the Raspberry Pi from responding verbally.
Lastly, the software installs the Voice command, which includes some of the more helpful scripts, such as the ability to deploy your internet browser by simply saying "internet."
Youtube: When you say "YouTube" followed by a title tag, a youtube clip of the first related YouTube clip appears. "I'm feeling lucky" is comparable to "I'm feeling lucky" on google. Say "YouTube" followed by the title of the video you want to watch, for example, "YouTube fluffy kittens."
Internet: Your internet browser is launched when you use the word "internet." Midori is the internet browser for Rpi by default, but you may alter that.
Download: When you say "download," followed by a search query, the Pirate Bay webpage searches for the files in demand. For instance, you can say "Download Into the badlands" to get the most current edition of the movie.
Play: This phrase utilizes the in-built media player to open an audio or video file. For instance, "Play football.mp4" would play the file "football.mp4" from the media directory you chose during setup, like /home/pi/movies.
Show me: When you say "show me," a directory of your choice appears. The command defaults to not going to a valid root directory, so you'll need to modify your configuration so that it points to one. For instance, show me==/Documents.
You'll be asked if you want the Voice command to set things up automatically. If an issue occurs at this point, run the following command to download and install the required software.
After installing the Voice command application, you may want to perform a few basic adjustments to the setup to fine-tune it. Execute the following command from your Raspberry Pi's Terminal or via SSH.
Following that, you'll be asked several yes/no questions. The first question is whether you wish to enable the continuous flag permanently. The Voice command application, in clear English, asks if you would want to listen to your voice commands constantly every time you launch it.
For the time being, choose Yes. After that, you'll be asked if you wish the Voice command application to set the verify flag permanently. If you select Y, the application will expect you to pronounce your keyword (the default setting is "Pi") before responding to requests.
If you like the RPi to monitor continually but not act on all words you say, this is a good option.
The next step asks if you wish to enable the ignore flag permanently. If Voice command receives a command that isn't expressly listed in the config file, it will try to find and launch a program from your installed apps. For example, if you say "leafpad," a notepad tool, the Voice command looks for it and starts it even if you don't tell it to.
This is a functionality that we would not recommend anyone to enable. Because you're using Voice command at the SuperUser level, there's a significant danger that you'll accidentally issue a command to the Raspberry Pi that will harm your files. If you wish to set up other programs to function with the Voice command, you can update the configuration file for each scenario.
The voice command afterward asks if you want to permanently enable the silence flag so that it doesn't respond verbally whenever you talk. As you see fit, select yes or no. After that, you'll be prompted to adjust the default voice recognition timeframe. If Pi is having problems hearing your commands, you should modify this.
If you select Yes, you'll be prompted to enter a number; this is the number of seconds that the Raspberry Pi will listen for a voice command; the default for RPI is 3. The application then allows you to customize your text-to-speech choices. Before you do this, make sure your volume is turned up. The application attempts to speak something and then asks if you heard it.
When the system receives your keyword, it responds with "Yes, sir?" as the default response. To modify this, select Yes in the following prompt, then enter your chosen response, for example, "Yes, ma'am?" Once you're finished, hit the enter key. The program will replay the assigned response to check that you are satisfied with the outcome.
Whenever the program receives an unidentified command, the method is the same as the default response. "Received the wrong command" is set as the default response, but you could still alter it to something more friendly by typing yes, then your desired response, like, "The command is not known."
You now have the option of configuring the voice recognition parameters. This will check to see if you have a suitable mic. The Pi will then ask you if you want it to test your sound threshold using the Voice command.
Check for background sound, then press Yes, then press enter key. It then requests you to say a command to ensure that it is using the correct audio device. Type Yes to have the application automatically select the appropriate audio threshold for your Rpi.
Lastly, the Raspberry Pi will ask if you wish to modify the default voice command term ("Pi"). After that, type Y and your new keyword, then press enter when you're finished.
After that, you'll be requested to say your keyword to acclimate the RPi to your voice. If everything looks good, press Y to finish the setup. Start with the fundamental commands outlined above when using the Voice command software.
Once you've mastered these commands, use the following line of code to exit the application and, if desired, change your config file.
The Raspberry Pi's technology is still a work-in-progress, so not everything you speak may be recognized by the program.
Stay near the mic and talk slowly and clearly to maximize your chances of being heard by the program if you still have difficulties understanding. Launch the terminal or log in through SSH to your Raspberry Pi and type the following command to access your audio settings to change your audio preferences.
Hit the F4 button on the keyboard to select audio input, then the F6 key to exit. Select your input device, the mic with the arrow up or down keys, then press Enter key. To change the mic's volume, push it up using the up-arrow key to maximum (100).
If your device isn't identified at all, it may require more current than a universal serial bus port on a Raspberry Pi can supply. A powered universal serial bus hub is the ideal solution for this.
If you have difficulty connecting after installing the Download application, please ensure that connection to The Pirate Bay site is not limited.
To download the files, you'll also require a BitTorrent application for your RPi, such as transmission. To install this, launch your terminal or access your RPi through SSH and type the following command:
The Transmission homepage has instructions about getting started and utilizing the application. You should always download files that have permission from the copyright holder.
Please remember that whatever you speak and any text documents you provide are transferred to Google servers for translation if you use Google text or speech Commands.
Google maintains that none of this information is kept on its servers. Even if this is the case, any data communicated through the worldwide web can be decrypted by any skilled third party or a hacker. Google, however, encrypts your connection to minimize the risk of this happening.
If you like this voice command tool, you might want the program to launch automatically every time the Rpi is powered on. If this is the case, launch the terminal from your RPi or access it via SSH and execute the command below:
The above command opens the script that controls which programs run whenever your Raspberry Pi is booted. By default, this script is doing nothing. Type the following line of code directly above the one reading exit 0:
To save any changes, use Ctrl+X, enter yes, and press enter key. At this point, you can restart the Raspberry Pi to ensure that it is working.
Launch your Rpi terminal, type the command below, and press enter to see a list of active processes.
Noise from air conditioners and heaters can damage your audio and make it impossible for the program to understand what you're saying. The only other alternative is to turn these systems off during recording unless the entire system is redesigned to be more acoustically friendly. However, upon listening to the audio, it becomes clear and annoying.
Computer hardware cooling fans are also sources of mechanical noise. These can be disabled manually and for a limited period. Besides that, try isolating the disturbance in another space or utilizing an isolation box as an alternative.
We learned how to configure our raspberry pi for voice control. We also looked at a few basic commands used to control the raspberry pi and the software used. However, In the following tutorial, we will learn how to tweet on Raspberry pi.
Hello readers, I hope you all are doing great. In our previous tutorial, we discussed the implementation of LED interfacing and blinking program with Raspberry Pi Pico using MicroPython programming language. So continuing with our previous tutorial, in this tutorial we will learn how to control the LED brightness using PWM (pulse width modulation technique).
As we mentioned above, in our previous tutorial we implemented the LED blinking program with a Raspberry Pi Pico board. Blinking an LED means turning ON and OFF and thus the process involves only two states that are ‘1’ (HIGH) and ‘0’ (LOW). But, sometimes it is required to change the digital output between these two (ON and OFF states) for example changing the LED brightness. PWM or Pulse Width Modulation technique is used to change the brightness of the LED.
Raspberry Pi Pico (RP2040) offers 40 pins which include power supply pins, General Purpose Input Output (GPIOs) pins, ADC, PWM etc. where most of the pins are multifunctional except power supply pins. Almost all the GPIO pins (30 pins) can be used to implement pulse width modulation technology.
Fig. 1 Raspberry Pi Pico Pi-Out
RP2040 offers 16 PWM channels and each channel is independent of another. Means we can set the duty cycle and frequency for one channels without affecting the others. These PWM channels are represented in the form of slices or groups and each slice contains two PWM outputs channel (A/B). There are total 8 slices and hence 16 channels. The pin B from PWM (A/B) can also be used as an input pin for duty cycle and frequency measurement.
The PWM channel provided in RP2040 are of 16 bit resolution which means maximum PWM resolution is 2^16 or ranges between 0 to 65536.
For more information on Raspberry Pi Pico’s PWM channels you can visit the Raspberry Pi organization’s official website: https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
Before programming the Raspberry Pi Pico for PWM implementation let’s first understand the concept of Pulse Width Modulation.
Fig. 2 Pulse width modulated signal
Pulse Width Modulation (or PWM) is a modulation technique used for controlling the power delivered to a load or external/peripheral devices without causing any power loss by pulsing the direct current (DC) and varying the ON time of the digital pulse. Using a digital input signal, the Pulse Width Modulation technique produces modulated output signals.
The following factors influence the behaviour of a pulse width modulated signal:
Frequency : Technically, frequency means “number of cycles per second”. When we toggle a digital signal (ON and OFF) at a high frequency, the result is an analog signal with a constant voltage level.
The number of cycles per second defined by a signal's frequency is inversely proportional to the time period. PWM frequency is determined by the clock source. The frequency and resolution of PWM are inversely proportional.
Duty Cycle : It is the ratio of ON time (when the signal is high) to the total time taken to complete the cycle.
Duty Cycle =
Fig. 3 Duty cycle
Resolution: A PWM signal's resolution refers to the number of steps it can take from zero to full power. The resolution of the PWM signal can be changed. For example, the Raspberry Pi Pico module has a 1- 16 bit resolution, which means we can set up to 65536 steps from zero to full power.
Various applications of Pulse Width Modulation technique are:
We have already published tutorials on how to download and install the above-mentioned software components.
Follow the given link for a detailed study of Raspberry Pi Pico: https://www.theengineeringprojects.com/2022/04/getting-started-with-raspberry-pi-pico.html
To program the Raspberry Pi Pico board there are various development environments available (like uPyCraft IDE, Visual Studio Code, Thonny IDE ect.) and multiple programming languages as well.
In this tutorial, we are going to use Thonny IDE to program the Raspberry Pi Pico board.
We have already published a tutorial on installing Thonny IDe for Raspberry Pi Pico Programming. Follow the given link to install the IDE: https://www.theengineeringprojects.com/2022/04/installing-thonny-ide-for-raspberry-pi-pico-programming.html
Fig. 4 New Project
Fig. 5 Select Interpreter
Image: 6 MicroPython for raspberry Pi Pico programming
Image: 7 Ready to program
In this example code we will implement the pulse width modulation on the digital output pin (GPIO 14). The brightness of the will vary from minimum to maximum brightness back and forth. The maximum possible resolution is 16 bit that is 2^16 (or 0 – 65535). Let’s write and understand the MicroPython program for PWM implementation:
The first task is importing library files necessary for PWM implementation. We are importing two libraries first one is to access the GPIO pins and another one is to implement pulse width modulation techniques. We also need to import ‘time’ library file to add some delay.
Fig. 8 Import libraries
To define the GPIO pin to be used as a PWM pin a ‘PWM()’ function is used which further contains the ‘Pin()’ function that is passing the PWM GPIO (14) pin number.
The PWM function is further represented using a ‘led’ object. If you are not familiar with the PWM pin details like to which slice and channel the pwm pin belongs, you can get the respective details using print(led) function.
Fig. 9 declare object
The led.freq() command is used to set frequency rate at which the digital pulse will be modulated.
Fig. 10 Frequency of modulation
Inside the while loop we are using two for() loops. First one to change the LED brightness from minimum to maximum resolution (‘0’ to ‘65525’ ).
Fig. 11
Another for loop() is used to set the LED brightness from maximum resolution (65535) to ‘0’ (minimum resolution).
The process will be repeated back and forth due to the ‘while()’ loop.
Fig. 12
Fig. 13 Save the program
Fig. 14 Save the program
Fig. 15 Run the saved program
from machine import Pin, PWM
import time
led = PWM(Pin(14))
print(led)
led.freq(1000)
while True:
for duty in range(0, 65535):
led.duty_u16(duty)
print(duty)
time.sleep(0.001)
for duty in range(65535, 1):
led.duty_u16(duty)
print(duty)
time.sleep(0.001)
Let’s interface a peripheral LED with raspberry Pi Pico. As mentioned in the code description the GPIO 14 pin is configured as PWM pin. Connect the LED with raspberry Pi Pico board. The connections of LED with Raspberry Pi Pico board are shown in Table 1.
Table 1
Schematic of LED interfacing with raspberry Pi Pico is shown below:
Image: 16 LED Interfacing with Raspberry Pi Pico
Fig. 17 Brightness level 1
Fig. 18 Brightness level 2
Fig. 19 Brightness level 3
Fig. 20 PWM pin details
Fig. 21
Fig. 22 Plotter
Fig. 23 Rising PWM output 0 to 65535 (brightness increasing)
Fig. 24 PWM output maximum to 0
Now let’s take another example where we will interface multiple LEDs (16) with Raspberry Pi Pico board and then will implement pulse width modulation on those LEDs.
The procedure of interfacing and programming with Thonny IDE using MicroPython will remain similar to the previous example.
Fig. 25 Interfacing Multiple LEDs with Pico
Let’s write the code:
from machine import Pin, PWM
import time
led_1 = PWM(Pin(5)) # declaring led_x object for PWM pins
led_2 = PWM(Pin(6))
led_3 = PWM(Pin(8))
led_4 = PWM(Pin(9))
led_5 = PWM(Pin(10))
led_6 = PWM(Pin(13))
led_7 = PWM(Pin(14))
led_8 = PWM(Pin(15))
led_9 = PWM(Pin(16))
led_10 = PWM(Pin(17))
led_11 = PWM(Pin(18))
led_12 = PWM(Pin(19))
led_13 = PWM(Pin(20))
led_14 = PWM(Pin(21))
led_15 = PWM(Pin(22))
led_16 = PWM(Pin(26))
print(led_1)
def led_freq(x):
led_1.freq(x)
led_2.freq(x)
led_3.freq(x)
led_4.freq(x)
led_5.freq(x)
led_6.freq(x)
led_6.freq(x)
led_7.freq(x)
led_8.freq(x)
led_9.freq(x)
led_10.freq(x)
led_11.freq(x)
led_12.freq(x)
led_13.freq(x)
led_14.freq(x)
led_15.freq(x)
led_16.freq(x)
led_freq(1000) # setting pulse width modulation prequency
while True:
for duty in range(0, 65535): # Increasing LED broghtness
led_1.duty_u16(duty)
led_2.duty_u16(duty)
led_3.duty_u16(duty)
led_4.duty_u16(duty)
led_5.duty_u16(duty)
led_6.duty_u16(duty)
led_7.duty_u16(duty)
led_8.duty_u16(duty)
led_9.duty_u16(duty)
led_10.duty_u16(duty)
led_11.duty_u16(duty)
led_12.duty_u16(duty)
led_13.duty_u16(duty)
led_14.duty_u16(duty)
led_15.duty_u16(duty)
led_16.duty_u16(duty)
print(duty) # Print the duty Cycle
time.sleep(0.001)
for duty in range(65535, 0): # deccresing LED brightness
led_1.duty_u16(duty)
led_2.duty_u16(duty)
led_3.duty_u16(duty)
led_4.duty_u16(duty)
led_5.duty_u16(duty)
led_6.duty_u16(duty)
led_7.duty_u16(duty)
led_8.duty_u16(duty)
led_9.duty_u16(duty)
led_10.duty_u16(duty)
led_11.duty_u16(duty)
led_12.duty_u16(duty)
led_13.duty_u16(duty)
led_14.duty_u16(duty)
led_15.duty_u16(duty)
led_16.duty_u16(duty)
print(duty)
time.sleep(0.001)
As we mentioned in the introduction part raspberry Pi Pico has 8 PWM slices and 16 PWM channels. So in this example code we are interfacing 16 LEDs with PWM pins.
Most of the code instructions and commands are similar to the previous example. Here we declare 16 different led objects for 16 different GPIO pins (PWM pins).
Fig. 26 Declaring ‘led’ object
Fig.27 PWM frequency
In the images attached below, we can see the variation in LED brightness.
Fig. 28 Minimum Brightness Level
Fig. 29 Intermediate Brightness Level
Fig. 30 Maximum Brightness Level
In this tutorial we demonstrated the implementation of pulse width modulation on LEDs with Raspberry Pi Pico module and MicroPython programming language.
Continuing with this tutorial, in our upcoming tutorial we will discuss the interfacing of a servo-motor with raspberry pi Pico and we will also implement PWM on servo motor to control the direction of rotation.
This concludes the tutorial, we hope you find this of some help and also hope to see you soon with a new tutorial on Raspberry Pi Pico programming.
Because of SQL database errors, users are unable to access their valuable data, and it is their responsibility to fix the issues promptly to make sure that there are no severe data loss issues. There are some predominant database corruption errors and issues. You may promptly resolve them to avoid undesirable severe data loss. We will know more about database corruption errors, issues, and perfect solutions for fixing SQL server database problems.
Usually, there are three main reasons behind database failure. Let us examine each of them and identify ways to recover and restore your lost data.
If a computer or server is shut down improperly, or if it encounters a power outage or surge or something occurs that abruptly interrupts the process of writing data to the files, there are chances of the OS files getting corrupted or damaged severely. This may lead to critical data loss. After encountering such a crisis, you are advised to repair or at least, examine the filesystem to safeguard against any data loss in the future. For modifying or mounting a file system, a repair may be necessary. Even though a thorough check may not report or reveal any severe damage, you might still need to repair the filesystem.
Another effective way of repairing the corrupt or compromised database is by utilizing database console commands like CHECKDB, DBCC, or DBCC DEBREPAIR. These commands could help fix minor database issues. However, they are not efficient enough to tackle or resolve critical corruption cases.
Hardware failures will be including memory issues, bad disk sectors, disk crashes, and even disk with errors, among many other issues. Hardware failures could be because of design errors, overloading, and poor quality control at the time of fabrication, and degradation of mechanical parts. Software failures will be including issues associated with software like DBMS software, operating system, application programs, etc.
Irrespective of how trustworthy, your DBMS seems, it is not in a position to guarantee a failure-free seamless transaction each time. To prevent any kind of database failure, the most logical and proactive step is to consult with expert DBAs. Once the overall database health is analyzed, you may rest assured to avoid serious problems down the line.
Users should regularly back up their SQL database to restore the database, in case of corruption or damage. Backup is certainly the most effective way of dealing with corruption. Keep in mind that some data may be missing between the time when disaster struck and the last backup. You may consider using commands like DBCC CHECKDB to examine and resolve corruption issues. However, you may fail to repair and restore severely corrupted files using this command.
You may use SQL data recovery tools recommended by experts to repair and resolve corrupt database file issues due to a lack of a backup. Some cutting-edge tools are helpful in the recovery of deleted objects, and they even display a preview. SQL recovery could prove to be a daunting and stressful job. However, you may use some advanced SQL recovery tools for getting your databases back into action!