39,59 €
This book follows a tactical plan that will guide you through the implementation of Banana Pro and its configurations. You will then learn the various programming languages used with Banana Pi with the help of examples. In no time at all, you’ll be working on a wireless project that implements AirPlay servers, hotspots, and so on. Following this, you’ll develop a retro-style arcade kiosk game. Then we’ll move on to explore the multimedia features of Banana Pro by designing and building an enclosure for it. After this, you’ll learn to build a remote-controlled smart car and we’ll examine how to control a robotic arm. The book will conclude with the creation of a home sensor system that has the ability to expand or shrink to suit any home.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 300
Veröffentlichungsjahr: 2015
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: December 2015
Production reference: 1211215
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78355-238-2
www.packtpub.com
Authors
Ruediger Follmann
Tony Zhang
Reviewers
Lalith Gallage
Nikolaos Margaris
Paul Mundt
Rob Seder
Commissioning Editor
Edward Bowkett
Acquisition Editor
Meeta Rajani
Content Development Editor
Anish Sukumaran
Technical Editor
Chinmay S. Puranik
Copy Editor
Sonia Michelle Cheema
Project Coordinator
Izzat Contractor
Proofreader
Safis Editing
Indexer
Hemangini Bari
Graphics
Disha Haria
Production Coordinator
Conidon Miranda
Cover Work
Conidon Miranda
Ruediger Follmann was born in 1968 in Germany. He studied electrical engineering at RWTH Aachen, Germany, and received his PhD from the University of Duisburg-Essen, Germany. He has worked for IMST GmbH, Germany, for more than 20 years, where he heads the RF circuits and system integration department. IMST is a design and development company with more than 170 employees. He uses embedded boards in many different projects, for example, in order to control MMICs or hybrid electronics. Follmann is the author of many technical articles as well as Das Raspberry Pi Kompendium, Springer.
Tony Zhang was born in 1990 in China. He studied control science and engineering at HIT, China, and received his master's degree in 2015. Since 2014, Tony has been working with LeMaker community, where he is the cofounder and is heading the R&D department.
Lalith Gallage is a charted IT professional with more than 12 years of experience in information communication technology, including embedded control designing, industrial automation, and CMS (SharePoint Server, Joomla, sensenet, Umbraco, and Odoo) customization. He has published several articles on the CodeProject website (http://www.codeproject.com/) and enjoys writing in his free time.
He is currently working at Sri Lanka Telecom and is a guest lecturer at many leading institutes in Sri Lanka in the fields of microcontroller and C# programming. In his free time, he likes to relax in his aquaponic garden.
He has expertise in several known languages, such as C++, C#, Python, PLSQL, PHP, and ASP.NET. He is also proficient in certain hardware platforms such as Arduino, Raspberry Pi, Banana Pi, Rabbit, and PIC.
His professional qualifications include a masters degree in IT from Cardiff Metropolitan University, UK, BIT from the University of Colombo, Sri Lanka, national diploma in engineering sciences (electronics and telecommunication) from Sri Lanka, and CITP from the UK.
Nikolaos Margaris currently works as a senior frontend developer on a collaboration and communication software that uses AngularJS and NodeJS. He enjoys clean and performant JavaScript code and tests it too. In his spare time, he likes reading about new technologies and wandering through the IoT world. Good music and some retro PC/console games have always added flavor to his life. Reviewing this book was an enjoyable experience for him, and he hopes to come across more opportunities like this one. You can find out more about him at http://www.nikolaosmargaris.gr/.
All thanks to my soul mate, Vaya. Her love and patience gives meaning to my life.
Paul Mundt is the founder and managing director of Adaptant Solutions AG, a software and solutions company focused on providing adaptable technologies and solutions needed to enable cross-sectorial data utilization and exploration in an evolving data regulation and compliance landscape.
Previously, Paul was the CTO of OS & Virtualization, and director of the system software department at Huawei's European Research Center, leading an R&D department responsible for the future OS and virtualization strategy and architecture, focusing on the areas of heterogeneous systems, convergence of Cloud and HPC, and the future data center architectures.
Earlier, at Renesas, he was responsible for establishing both the initial open source strategy and vision, while leading the organization to consistently become one among the top 10 contributors to the Linux kernel, resulting in wide-reaching system software and IP consolidation across a diverse MPU/MCU product portfolio.
He has more than 15 years of experience in both Linux kernel development and technology management across a diverse range of domains (HPC, embedded, enterprise, and carrier grade). He has also previously worked for Nokia, TimeSys, and MontaVista in various technical and leadership positions.
Rob Seder has been involved in information technology for over 20 years. He has been a technophile and geek from an early age. His day job primarily involves working on Microsoft .NET technologies, but he also invests heavily in Linux, Mac, IoT, automation, 3D printing, and other interesting infrastructures or development technologies. Rob has mostly worked in financial and insurance industries over the years, and he enjoys keeping himself up to date with the most current technologies that are available.
You can find Rob's blog at http://blog.robseder.com or contact him at @RobSeder on Twitter.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
The book mainly focuses on some popular applications and projects using Banana Pro. It first introduces the basic usage of Banana Pro, including its hardware and software, and then some applications, such as a multimedia center and laser engraver. The sole purpose of this book will be to show what you can do with Banana Pro through a number of projects, ranging from home automation projects, cameras around the house, and robotics.
This book follows a tactical plan that will guide you through the implementation of Banana Pro and its configurations. You will then learn the various programming languages used with Banana Pi with the help of in-depth examples.
Chapter 1, Introduction to Banana Pro, introduces the Banana Pro single board computer. It explains all its available interfaces as well as the installation of the Linux OS, which will be used in this book.
Chapter 2, Programming Languages, explains several programming languages, such as Python, C/C++, and Scratch. In several examples, the usage of these programming languages is shown through a step-by-step approach.
Chapter 3, Wireless Projects, introduces wireless projects. It shows how Banana Pro can be used as a wireless hotspot or print server. Additionally, the serving of web pages is explained in combination with content management systems. Finally, a measurement server is set up in order to control an electronic circuit.
Chapter 4, AnArcade Cabinet, describes how to turn Banana Pro into an arcade cabinet. A step-by-step approach shows you how to install and configure different game emulations. This chapter also describes the steps required to set up a cabinet house with the help of a joystick and an LCD display for Banana Pro.
Chapter 5, A Multimedia Center, introduces the usage of Banana Pro as a multimedia center. You will be shown how a DVB receiver is set up through a series of steps. This receiver allows the recording of TV transmissions, watching DVDs, and listening to audio CDs.
Chapter 6, Remote Controlling a Smart Monitor Car, teaches you how to make a small mobile car with the remote monitor function. It describes how to realize the IP camera function on Banana Pro. It also shows you how to set up a small mobile car. Finally, you will see how a web page can be used to control the car and view the video of the camera in the car.
Chapter 7, A Laser Engraver, shows the laser engraver made by Banana Pro along with a laser CPU. You will learn how to design the frame of the laser engraver and use different kinds of software on the Banana Pro. The laser CPU and PC can be used together to engrave patterns on some special types of material such as cardboard.
Chapter 8, Scratch—Building a Smart House, describes how to use Scratch and some other GPIO libraries together to control different sensors. Then, you will learn how to combine all the sensors together in a virtual small house to simulate the smart house.
You would need Banana Pro, an SD card (a minimum of 4 GB is recommended), an AC plug, a hard disk drive, and a USB DVB receiver (optional).
This book is for all embedded board enthusiasts who want to use their credit-card-sized computer boards for extraordinary projects. An example of LeMaker's Banana Pro computer as a home entertainment center or a arcade cabinet is described in a step-by-step approach. Get the most out of your embedded board using it in your daily lives or for challenging projects. This book is the perfect guide for these purposes.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: http://www.packtpub.com/sites/default/files/downloads/BananaPiBlueprints_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the ErrataSubmissionForm link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.
Embedded boards are part of our lives. We use them daily, and sometimes even without recognizing or knowing about them. They are included in mobile phones, washing machines, or implemented in our televisions. These little computers work in the background and consume very little power.
This chapter introduces Banana Pro. Banana Pro is an updated version of Banana Pi that's been designed by the LeMaker team (http://www.lemaker.org) from China. LeMaker is a charitable organization and aims to provide educational services by selling its Banana boards and building a community around this technology, similar to what the Raspberry Pi foundation in the UK has done.
Banana Pro is the current flagship of LeMaker. It is compatible with many Linux-based operating systems including Android. In this chapter, Banana Pro is introduced to you along with its connection possibilities. The most popular operating systems in the market today are explained here and the principal installation as well as the boot process is described.
There are already many add-ons available for Banana Pro, such as LCD modules in various sizes, a camera module, or modules that connect to GPIO pins. Sections of this chapter deal with the detailed installation of an LCD module, describing the step-by-step installation and operation of a camera module and provide background information on additional add-ons.
In particular, this chapter includes the following sections:
Since Raspberry Pi was born, a lot of new embedded boards have seen the light of day. A very popular one is Banana Pro. It came into the market in late 2014, is affordable ($45 USD), and offers many interfaces (Figure 1).
Banana Pro is the size of a credit card (92 mm x 60 mm and 48 g) and uses an Allwinner A20 system on chip. This includes a dual core CPU (ARM Cortex-A7, 1 GHz), a Mali 400 MP2 GPU, and a 1 GB SDRAM. Additionally, there is also a AP6181 Wi-Fi module onboard. Banana Pro makes use of the AXP209 Power Management Unit (PMU), which is very power efficient and allows power monitoring.
Figure 1: Banana Pro is a dual core computer featuring many connectors (source: http://en.wikipedia.org/wiki/Banana_Pro).
Table 1 summarizes the Banana Pro specifications. Everything is available to build a complete computer system, including a hard disk or connection to a television or computer screen. Both the Gb LAN and WLAN guarantee easy integration into networks and fast operation, for example, as NAS. USB sockets allow the usage of a keyboard, mouse, or even DVB receivers (refer to Chapter 4, An Arcade Cabinet). The 40-pin General Purpose Input Output (GPIO) header allows arbitrary experiments that feature different bus systems, such as CAN (Controller Area Network) or SPI (Serial Peripheral Interface). Different LEDs provide board statuses; CSI (Camera Serial Interface) and LVDS (Low Voltage Differential Signaling) interfaces are also available. The CSI interface can be used in order to connect a camera and LVDS interface that can be used for display connection purposes. Even an onboard microphone is implemented. The following are the Banana Pro specifications:
Components
Specification
System on chip
Allwinner A20, SATA 2, two USBs, and one Micro-USB
CPU
1 GHz Cortex-A7 dual-core
GPU
Mali 400 MP2, OpenGL 2.0/1.1 (hardware accelerated)
Memory
1 GB DDR3 SDRAM
Power
5V/2A using Micro-USB (DC and/or USB OTG)
PMU
AXP209
USB
Two USBs of the 2.0 version and one USB 2.0 OTG
Low level connectors
A 40-pin GPIO header, including UART, I2C, SPI, PWM, CAN, I2S, and SPDIF
Storage
A Micro-SD card, SATA 2.0, and a 2.5 inch hard disk power supply onboard
Network
10/100/1000 Ethernet RJ 45 and 150 Mbps Wi-Fi 802.11 b/g/n
Display
HDMI-A 1.4, a composite video (PAL and NTSC) (via 3.5 mm TRRS jack shared with an audio output), and LVDS/RGB/CPU display interface (DSI) for raw LCD panels. 11 HDMI resolutions from 640×480 to 1920×1080 plus various PAL and NTSC standards
Video
An HD H.264 2160p video decoding. A multiformat FHD video decoding, including Mpeg1/2, Mpeg4, H.263, H.264, and so on. An H.264 high-profile 1080p@30fps or 720p@60fps encoding
Camera
An 8-bit parallel camera interface
Audio outputs
HDMI, analog audio (via a 3.5 mm TRRS jack that's shared with composite video out), I2S audio (also potentially for audio input), and an electrical SPDIF audio output
Audio input
An onboard microphone
Buttons
A reset button, power button, and a U-boot button
LEDs
A power status LED (red), Ethernet status LED (blue), and a user-defined LED (green)
Other
An onboard IR receiver
Dimensions
92 mm x 60 mm and 48 gm
Table 1: Banana Pro specifications
Contrary to many other embedded boards, Banana Pro offers a SATA connector for the direct connection to a 2.5 inch hard disk connection. Moreover, for SSDs or a 2.5 inch hard disk, a power connector is onboard.
Note the correct polarity of the SATA/DC power connector. Compared to CubieBoard or Cubietruck, Banana Pro uses the concept of changed polarity. Therefore, when ordering a Banana Pro SATA/DC cable, be sure of the DC polarity (Figure 2).
Figure 2: The Banana Pro SATA/DC cable (source: Amazon.com)
All the connectors of Banana Pro are explained in Figure 3. These are as follows:
Figure 3: Connectors of Banana Pro
Figure 4: The USB OTG to USB adapter (source: Amazon.com)
Using an adapter cable (Figure 4), USB devices can be connected to this port.
Figure 5: The TRRS connector for Banana Pro. Pin 1 is audio left, pin 2 is audio right, pin 3 is video out and pin 4 is ground.
There are adapter cables available that separate audio and videos (Figure 6):
Figure 6: The TRRS splitter for audio and videos
In addition to the preceding connectors, Banana Pro offers a WLAN module that can also work as an access point. Banana Pro does not supply a real-time clock (RTC). However, there are RTC add-on boards available at http://www.wvshare.com/product/PCF8563-RTC-Board.htm.
Figure 7: The RTC add-on board for Banana Pro. Source: http://www.wvshare.com.
Banana Pro features several LEDs onboard. The red LED lights up as soon as DC power is supplied to the board. The blue LED shows Ethernet activity. The green and blue LEDs can be set individually. Chapter 2, Programming Languages, will show you how these LEDs can be programmed.
LeMaker offers several predefined images for download. These can be found at http://www.lemaker.org/product-bananapro-resource.html. Simply download the image file you want and copy it to a microSD card. The minimum required SD card size is 4 GB.
When using the Windows OS, WIN32 Disk Imager (http://sourceforge.net/projects/win32diskimager) can be used in order to transfer an image to an SD card. However, make sure that you select the correct drive for the Win32 Disk Imager. An incorrect drive may result in loss of data.
Figure 8: Win32 Disk Imager can be used in order to transfer Banana Pro image files to a microSD card (source: SourceForge.net)
Using Linux, image files can be transferred to a Micro SD card using the following command:
For uncompressed images, use the following command
For compressed images, replace /dev/sdX with your SD card. Note that the block size is set to 4M and will work most of the time. If it doesn't, try 1M, although this will take a considerably longer to complete.
There is one exception for Banana Pro using the Android operating system. Using Win32 Disk Imager or the dd command of Linux will not work here. Special software called PhoenixCard will be required. PhoenixCard for Windows can be downloaded from https://drive.google.com/file/d/0B_VynIqhAcB7NTg2UkRDdHRWX2s/edit. Before you do this, the SD card should be formatted by clicking on Format to Normal (Figure 9):
Figure 9: Copying Android to an SD card for Banana Pro by first formatting the SD card to normal
It is mandatory to select the Startup from the Write Mode. After formatting the card, click on the OK button in the Information window. In a second step, the Android image can be burned to the SD card (Figure 10). This step will take a few minutes to complete.
After writing any image to the microSD card, put the SD card into Banana Pro SD card slot and connect the DC power supply afterwards. This will boot your image. Currently, Banana Pro supports Android 4.4. Version 4.4 is available from this forum at http://www.bananapi.com/index.php/forum/adroid/117-android-4-4-for-banana-pi-beta-1-release-note.
Figure 10: Copying the Android OS to an SD card for Banana Pro by burning an image to an SD card
Set up your Banana Pro according to Figure 11 after you've copied the image to the SD card.
Depending on the chosen image, the first boot will take 20 to 30 seconds. The first boot on Android will take much longer, so be patient.
Some Android versions may require two micro USB power connectors at the same time. One must be supplied to the micro USB DC before boot, and the other one to the micro USB OTG. During my experiments with Android 4.2, one power supply connection was sufficient.
Figure 11: Setting up Banana Pro before the first boot (source: http://www.lemaker.org/cn/product-bananapro-guide.html)
This section presents some of the available operating systems for Banana Pro. Here, Android has briefly described some of the most important Linux distributions:
Figure 12: A screenshot of operating systems available on the LeMaker web page
LeMaker offers image versions for both Banana Pi and Banana Pro. However, be sure to download the correct image.
Figure 13
Although Android is based on Linux, both architectures are quite different. This can be seen even in the example of low-level C language routines, which Google exchanged for Android. In addition to this, Google prohibits all code that's licensed under GPL (GNU Public License). For this reason, Android only implements a rudimentary shell featuring only a few shell commands. Due to the C-library incompatibilities, normal Linux code, even if it's especially compiled for the ARM architecture, will not run under Android. Nevertheless, Android is a very popular operating system (OS) that's used by many phones and tablets. It fully supports graphic hardware in terms of accelerated video and 3D graphics. For this reason, the first Banana Pro version of Kodi (formerly known as XBMC and Xbox Media Centre) made use of an accelerated Android graphics library (refer to Chapter 4, An Arcade Cabinet).
Applications for Android can be developed using a special software development kit (SDK) and Java itself as most Android applications are based in Java. Although this book concentrates on Linux projects rather than Android projects, we will take a short look at Android on Banana Pro.
LeMaker provides three different Android images: one for a 5 inch TFT, the second for a 7 inch TFT, and the third using the HDMI cable as a video output. To install an Android OS, simply download the required version. You most probably want to start with the HDMI enabled version. Use PhoenixCard (as seen in the previous section) in order to write the image to an SD card. Insert this SD card and boot Android. After a while, the start screen of Android will be visible.
Figure 14: This is Android 4.4 running on Banana Pi/Pro (http://www.bananapi-kaufen.de/wp-content/uploads/2014/07/800px-Android_v2.jpg)
Android can be controlled by using a keyboard and mouse. Bluetooth and WLAN will work out of the box and some applications are already preinstalled.
Figure 15: Android 4.4 running on Banana Pro (source: bananapi.com)
There are a variety of Linux distributions available on the LeMaker download site (Figure 13). The most famous operating systems are Raspbian, Bananian, Lubuntu, and Gentoo. LeMedia
