Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Raspberry Pi Android Projects
Raspberry Pi Android Projects

Raspberry Pi Android Projects: Create exciting projects by connecting the Raspberry Pi to your Android phone

eBook
$20.98 $29.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Raspberry Pi Android Projects

Chapter 2. Server Management with Pi

In the first half of this project, we will move from a desktop-based console to a text-based one that gives more power to the user and lets you perform more advanced tasks compared to the desktop. We will access the Pi's Linux console from an Android device and control it remotely. In the second half, we will send and receive files between the Pi and Android through FTP. We will even combine the two parts by managing our newly installed FTP server remotely using the text-based console. In this chapter, we will even install database and web servers on to the Pi to show how to manage them later on. To make it even more fun, we will implement a simple but useful mini project that makes use of both web and database servers. The following topics will be covered:

  • Remote console to the Pi from Android
  • Exchanging files between the Pi and Android
  • A simple database and web server implementation
  • Simple management of servers

Remote console to the Pi from Android

The administrators of Linux and Unix computers have been using text-based command-line interfaces called shell for many years to manage and administer their servers. As the Pi's OS, Raspbian, is a Linux variant, the most natural way to access and issue commands or check the status of running programs, services, and different servers on the Pi is again by issuing commands on this text-based shell. There are different shell implementations but the one that is used on Raspbian by default is bash. The most well-known way of accessing shell remotely on a Linux server is through the Secure Shell protocol known, in general, as SSH.

Note

Secure Shell (SSH) is an encrypted network protocol used to send shell commands to a remote machine in a secure way. SSH does two things for you. It enables, through different tools, such as the ones we will present to you in a moment, you to send commands to the remote machine and it does this using a secure channel established...

Exchanging files between the Pi and Android

In the second part of this chapter, we will use the Pi as an FTP server to share files between our Android devices or send files to the Pi to view them on a larger screen that you connect to the Pi HDMI port. The FTP server we will use is vsftpd. It is a lightweight FTP server used in many small projects. To install it on our Pi, we use the following command:

sudo apt-get install vsftpd

The preceding command will even start the FTP service.

However, we should make some changes in the configuration of the FTP server to use it effectively. For this purpose, we need to edit the FTP server configuration file using this command:

sudo nano /etc/vsftpd.conf

Find the two lines containing #local_enable=YES and #write_enable=YES and remove the # comment sign at the beginning of these lines before you save and exit. These changes will enable the user pi to login and be able to send files to the Pi. To restart the FTP server, issue this command:

sudo service...

A simple database and web server implementation

Next, we'll take our project one step further and install both a database and web server, which we can administer later on using ConnectBot. We will even make it more fun by implementing a real project that makes use of these servers. The best candidate for this purpose is a sensor measurement scenario. We will connect a temperature/humidity sensor to our Pi and save the measurements into a database that we will install on the Pi, which a web server will make available to clients. We can later on manage these servers remotely, which is the main objective in this chapter.

Connecting the sensor

For the purpose of this project, we will use a sensor, DHT11, which measures both temperature and humidity, but for the sake of easier connections, we will use an off-the-shelf module called Keyes DHT11 or DHT11 for short, which contains these sensors.

Tip

There is even an improved version of DHT11, which is DHT22. It costs a little bit more but has...

Simple management of servers

The following command simply checks the status of the FTP server:

service vsftpd status

This command restarts the FTP server if there's any problem with it:

sudo service vstfpd restart

The service utility that we have used lets you restart the database and web server using these two commands:

sudo service mysql restart
sudo service apache2 restart

Use the following command to check the status of the MySQL server:

mysqladmin -u root -p status

If you believe that the database has grown too much in size, you can start the MySQL console and run a SQL query to see the database size:

mysql –u root –p
mysql> SELECT table_schema "DB", Round(Sum(data_length + index_length) / 1024 / 1024, 1) "Size in MB" 
FROM   information_schema.tables 
GROUP  BY table_schema;

You can even delete records that are older than three days using the following query:

select measurements;
delete from measurements where ttime < NOW() - INTERVAL 3 DAY;...

Summary

This chapter introduced you to the management of Raspberry Pi as a server and how to issue commands to it from Android. We installed an FTP server on the Pi and shared files between Android clients. To show an example of database and web servers, we implemented a useful project and learned to manage these servers remotely as well.

The next chapter will introduce you to the Pi camera and help you implement a surveillance solution.

Left arrow icon Right arrow icon

Description

Raspberry Pi is the credit card-sized, general purpose computer which has revolutionized portable technology. Android is an operating system that widely used in mobile phones today both on the high and low ends of the mobile phone market. However, there is little information about how to connect the two in spite of how popular both of them are. Raspberry Pi Android Projects starts with simple projects that help you access the command prompt and the desktop environment of Raspberry Pi from the comfort of your Android phone or tablet. Then, you will be introduced to more complex projects that combine the strengths of the Pi and Android in amazing ways. These projects will teach you how to manage services on the Pi from Android, share files between Android devices using the Pi as a server, administer and view the Pi’s camera from Android in surveillance mode, and connect your car to the Pi and make data more accessible using Android. The introductory projects covered will be useful each time you need to access or administer your Pi for other purposes, and the more advanced projects will continue to be valuable even after you become an expert on Pi. By the end of this book, you will be able to create engaging and useful projects that will help you combine the powers of both Android and Raspberry Pi.

Who is this book for?

The target audience for this book includes Raspberry Pi enthusiasts, hobbyists, and anyone who wants to create engaging projects with Android OS. Some knowledge of Android programming would be helpful.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 25, 2015
Length: 138 pages
Edition : 1st
Language : English
ISBN-13 : 9781785887024
Category :
Languages :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Sep 25, 2015
Length: 138 pages
Edition : 1st
Language : English
ISBN-13 : 9781785887024
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 110.97
Raspberry Pi Home Automation with Arduino - Second Edition
$32.99
Raspberry Pi Android Projects
$38.99
Building a Home Security System with Raspberry Pi
$38.99
Total $ 110.97 Stars icon

Table of Contents

7 Chapters
1. Make a Remote Desktop Connection to Your Pi from Anywhere Chevron down icon Chevron up icon
2. Server Management with Pi Chevron down icon Chevron up icon
3. Live Streaming of a Surveillance Camera from the Pi Chevron down icon Chevron up icon
4. Turn Your Pi into a Media Center Chevron down icon Chevron up icon
5. Missed Calls with Pi Chevron down icon Chevron up icon
6. The Vehicle Pi Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(2 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Carles Nov 12, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Another useful book to dust off that raspberry pi you have sitting on a shelf or go beyond lighting some leds with it.This title adds a new dimension to the myriad of existing ones by pairing the pi with and android phone to boost its capabilities. Don't get it wrong, you are not installing Android SO inside the pi but just the usual raspbian linux distribution. Keep that in mind before getting this book. If you are in search of that specific scenario, give it a look to all the other titles PACKT has into the matter that may suit you best.To get the most of this book it's advisable you have a little background in electronics (you'll tinker with some simple electronic components, sensors, leds and so on) and also some programming background (C, java or PHP will be enough to follow books examples).From this point the book will guide you through different real-life projects with a very practical, less theoretical, approach (winner way to learn imho) using the strong multimedia and IoT capabilities present on the Raspberry Pi 2 and today's smartphones.
Amazon Verified review Amazon
Perry Nally Dec 14, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book covers exactly what you need to know and do in order to use an android smart phone (or even android stick) to communicate via wi-fi or bluetooth with the pi 2. All the Linux and Android commands are given to setup a truly usable environment for creating a great IoT devices. This book goes a bit further by helping you understand what issues you may have and how to overcome them or gives extra resources if it's outside the scope of the book. I learned how to remote manage the pi from android, install, configure, and manage mysql database, a webserver, read from GPS and a temperature/humidity sensor, and how to connect the pi to your car OBD-II and stream that data to a google doc spreadsheet using your phone as a mobile hotspot. It also includes the basic things like installing a media center, a file server, and a security camera. But the meat of connecting it all up is the car data logger. In order to do the reading and streaming from Android, you get to create an Android App using Android Studio.This book may not be for everyone since the scenarios are so specific. For instance, I may not want Android to communicate with the pi through wi-fi or bluetooth, but some other connection. You'll need to figure out how to connect via a hard-wire/usb/other device on your own.However, though I wish there were more chapters to this book related to other connection methods between the pi and Android, I found it still very comprehensive for the tasks it was attempting to teach me. You can literally sit down and follow the examples word for word (you may need to be a bit creative if you're not using the same hardware/software versions) and have usable environments. I love that this book is so hands on and not so much theory.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.