Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
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
AU$14.99 AU$42.99
Paperback
AU$53.99
Subscription
Free Trial
Renews at AU$24.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

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 : 9781785882180
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
AU$24.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
AU$249.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 AU$5 each
Feature tick icon Exclusive print discounts
AU$349.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 AU$5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total AU$44.97 AU$122.97 AU$78.00 saved
Building a Home Security System with Raspberry Pi
AU$53.99
Raspberry Pi Android Projects
AU$53.99
Raspberry Pi Home Automation with Arduino - Second Edition
AU$45.99
Total AU$44.97AU$122.97 AU$78.00 saved Stars icon
Banner background image

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

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.