Thursday, October 29, 2015

DragonBoard 410c

DragonBoard 410c

This DragonBoardTM 410c based on 96BoardsTM specification features the Qualcomm® SnapdragonTM 410 processor, a Quad-core ARM® CortexTM A53 at up to 1.2GHz clock speed per core, capable of 32-bit and 64-bit operation.96Boards is a 32-bit and 64-bit ARM® Open Platform hosted by LinaroTM with the intension to serve the software/ maker and embedded OEM communities.DragonBoard 410c supports Android 5.1 and Linux based on Ubuntu at launch with planned support for Windows 10 and offers advanced processing power, WLAN, Bluetooth, and GPS, all packed into a board the size of a credit card. It is designed to support feature-rich functionality, including multimedia, with the Qualcomm® AdrenoTM 306 GPU, integrated ISP with up to 13 MP camera support, and 1080p HD video playback and capture with H.264 (AVC). *** Note: This listing is for the DragonBoard only, and does not include a power supply. A DragonBoard with a power supply is also available as a kit, or power supplies are available separately from Arrow's online store.
  • Qualcomm® SnapdragonTM 410 processor, a Quad-core ARM® CortexTM A53 at up to 1.2GHz clock speed per core
  • 1GB LPDDR3 533MHz
  • WLAN 802.11b/g/n 2.4GHz, Bluetooth 4.1, On-board GPS
  • High speed and low speed expansion connector
  • Supports Android 5.1, Ubuntu Linux, Windows 10

DragonBoard 410c Tutorials


DragonBoard 410c Tutorials From https://developer.qualcomm.com/hardware/dragonboard-410c/tutorial-videos



Modifying Kernel for UART Configuration on DragonBoard™ 410c
In this tutorial you’ll learn how to make kernel changes and rebuild to configure low-speed UART on the DragonBoard™ 410c featuring the Qualcomm® Snapdragon™ 410 processor, which in this video is running Android.

Using GPIOs on low speed connector on DragonBoard™ 410c
In this tutorial where we are running Android, you’ll learn how to export and toggle the GPIO pins on the DragonBoard 410c, featuring the Qualcomm Snapdragon 410 processor. We’ll end the tutorial showing you how to use the GPIO pins to connect and blink an LED.

Loading Linux-based Ubuntu on DragonBoard™ 410c
This tutorial shows you how to flash Linux based on Ubuntu on the DragonBoard 410c, which featured the Qualcomm Snapdragon 410 processor. You’ll need a micro SD card of at least 1GB for these easy flashing instructing.

Interfacing I2C Grove Digital Light Sensor on DragonBoard 410c
This tutorial video provides a detailed step-by-step process for how to Interface an I2C sensor and make kernel changes for the DragonBoard 410c, which features the Qualcomm Snapdragon 410 processor.

New member of Windows 10 IoT Core - DragonBoard410c

Microsoft announced to add the DragonBoard 410c, which features the Qualcomm® Snapdragon™ 410 processor to the family of supported Windows 10 IoT Core devices! You can get started here, and select your device of DragonBoard410c.


The DragonBoard™ 410c based on Linaro 96Boards™ specification features the Qualcomm® Snapdragon™ 410 processor, a Quad-core ARM® Cortex™ A53 at up to 1.2GHz clock speed per core, capable of 32-bit and 64-bit operation. WLAN, Bluetooth, and GPS, all packed into a board the size of a credit card.

Sunday, October 25, 2015

PolaPi - Instant-Printing-Point-and-Shoot camera using Raspberry Pi


A kind of a Polaroid camera, based on Raspberry Pi 2.
Details : https://hackaday.io/project/7176-polapi
- Raspberry Pi 2
- Raspberry Camera Module
- 4mm F1.0 CCTV lens
- Adafruit Thermal 57mm Printer, hacked for smooth printing
- Adafruit 320x280 TFT screen
- 3A 5v voltage regulator
- 7.4v 3.6Ah Li-po battery
- Buttons and hand made case
- Java programming.

Programming the Raspberry Pi, Second Edition: Getting Started with Python

An updated guide to programming your own Raspberry Pi projects

Programming the Raspberry Pi, Second Edition: Getting Started with Python

Learn to create inventive programs and fun games on your powerful Raspberry Pi―with no programming experience required. This practical book has been revised to fully cover the new Raspberry Pi 2, including upgrades to the Raspbian operating system. Discover how to configure hardware and software, write Python scripts, create user-friendly GUIs, and control external electronics. DIY projects include a hangman game, RGB LED controller, digital clock, and RasPiRobot complete with an ultrasonic rangefinder.
  • Updated for Raspberry Pi 2
  • Set up your Raspberry Pi and explore its features 
  • Navigate files, folders, and menus 
  • Write Python programs using the IDLE editor 
  • Use strings, lists, functions, and dictionaries 
  • Work with modules, classes, and methods 
  • Create user-friendly games using Pygame 
  • Build intuitive user interfaces with Tkinter 
  • Attach external electronics through the GPIO port 
  • Add powerful Web features to your projects

Saturday, October 24, 2015

Raspberry Pi Android Projects

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

Raspberry Pi Android Projects

About This Book
  • Manage most of the fundamental functions of Raspberry Pi from your Android phone
  • Use the projects created in this book to develop even more exciting projects in the future
  • A project-based learning experience to help you discover amazing ways to combine the power of Android and Raspberry Pi
Who This Book Is 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.

What You Will Learn
  • Install the tools required on your Pi and Android to manage and administer the Pi from Android
  • Share your files between different Android devices using the Pi as a server
  • Set up the Pi to live-stream the camera in surveillance mode and customize Android to receive this content
  • Turn your Pi into a media center and control it from your Android
  • See your Android display on a large screen using Raspberry Pi
  • Connect your car's dashboard to your Android device using Raspberry Pi
In Detail
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.

Style and approach
A quick and easy-to-follow guide that will show how you can add up the power of Pi and Android by combining them.

Tuesday, October 20, 2015

Getting Started with Python and Raspberry Pi

Learn to design and implement reliable Python applications on the Raspberry Pi using a range of external libraries, the Raspberry Pis GPIO port, and the camera module

Getting Started with Python and Raspberry Pi

About This Book
  • Learn the fundamentals of Python scripting and application programming
  • Design user-friendly command-line and graphical user interfaces
  • A step-by-step guide to learning Python programming with the Pi
Who This Book Is For
This book is designed for those who are unfamiliar with the art of Python development and want to get to know their way round the language and the many additional libraries that allow you to get a full application up and running in no time.

What You Will Learn
  • Fundamentals of Python applications
  • Designing applications for multi-threading
  • Interacting with electronics and physical devices
  • Debugging applications when they go wrong
  • Packaging and installing Python modules
  • User interface design using Qt
  • Building easy to use command-line interfaces
  • Connecting applications to the Internet
In Detail
The Raspberry Pi is one of the smallest and most affordable single board computers that has taken over the world of hobby electronics and programming, and the Python programming language makes this the perfect platform to start coding with.

The book will start with a brief introduction to Raspberry Pi and Python. We will direct you to the official documentation that helps you set up your Raspberry Pi with the necessary equipment such as the monitor, keyboard, mouse, power supply, and so on. It will then dive right into the basics of Python programming. Later, it will focus on other Python tasks, for instance, interfacing with hardware, GUI programming, and more. Once you get well versed with the basic programming, the book will then teach you to develop Python/Raspberry Pi applications.

By the end of this book, you will be able to develop Raspberry Pi applications with Python and will have good understanding of Python programming for Raspberry Pi.

Style and approach
An easy-to-follow introduction to Python scripting and application development through clear conceptual explanations backed up by real-world examples on the Raspberry Pi.

Sunday, October 18, 2015

Raspberry Pi + Python + mxgxw/MFRC522-python - Dump RFID Tag data one-by-one, and detect tag remove

Last post about RFID Tag "Raspberry Pi 2 + MFRC522-python - Dump RFID Tag data using mxgxw/MFRC522-python" demo the Dump.py from mxgxw/MFRC522-python. It loop to read and display RFID Tag data, not easy for checking. So I modify it to dump RFID Tag data one-by-one, and detect card remove.

pyDump1.py, exit once tag data dump finished.
#!/usr/bin/env python
# -*- coding: utf8 -*-

import RPi.GPIO as GPIO
import MFRC522
import signal

continue_reading = True

# Capture SIGINT for cleanup when the script is aborted
def end_read(signal,frame):
    global continue_reading
    print "Ctrl+C captured, ending read."
    continue_reading = False
    GPIO.cleanup()

# Hook the SIGINT
signal.signal(signal.SIGINT, end_read)

print "Place card please..."

# Create an object of the class MFRC522
MIFAREReader = MFRC522.MFRC522()

# This loop keeps checking for chips. If one is near it will get the UID and authenticate
while continue_reading:
    
    # Scan for cards    
    (status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)

    # If a card is found
    if status == MIFAREReader.MI_OK:
        print "Card detected"
    
    # Get the UID of the card
    (status,uid) = MIFAREReader.MFRC522_Anticoll()

    # If we have the UID, continue
    if status == MIFAREReader.MI_OK:

        # Print UID
        print "Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3])
    
        # This is the default key for authentication
        key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]
        
        # Select the scanned tag
        MIFAREReader.MFRC522_SelectTag(uid)

        # Dump the data
        MIFAREReader.MFRC522_DumpClassic1K(key, uid)

        # Stop
        MIFAREReader.MFRC522_StopCrypto1()
        
        print "--- Finished ---"
        continue_reading = False
        
GPIO.cleanup()



pyDump2.py, wait tag remove after data dump. I assume tag removed if 5 times of MIFAREReader.MFRC522_Request() not OK.
#!/usr/bin/env python
# -*- coding: utf8 -*-

import RPi.GPIO as GPIO
import MFRC522
import signal

continue_reading = True

# Capture SIGINT for cleanup when the script is aborted
def end_read(signal,frame):
    global continue_reading
    print "Ctrl+C captured, ending read."
    continue_reading = False
    GPIO.cleanup()

# Hook the SIGINT
signal.signal(signal.SIGINT, end_read)

print "Place card please..."

# Create an object of the class MFRC522
MIFAREReader = MFRC522.MFRC522()

# This loop keeps checking for chips. If one is near it will get the UID and authenticate
while continue_reading:
    
    # Scan for cards    
    (status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)

    # If a card is found
    if status == MIFAREReader.MI_OK:
        print "Card detected"
    
    # Get the UID of the card
    (status,uid) = MIFAREReader.MFRC522_Anticoll()

    # If we have the UID, continue
    if status == MIFAREReader.MI_OK:

        # Print UID
        print "Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3])
    
        # This is the default key for authentication
        key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]
        
        # Select the scanned tag
        MIFAREReader.MFRC522_SelectTag(uid)

        # Dump the data
        MIFAREReader.MFRC522_DumpClassic1K(key, uid)

        # Stop
        MIFAREReader.MFRC522_StopCrypto1()
        
        # wait card removed 
        print "--- Remove Card ---"
        card_removed = False
        card_removed_counter = 5

        while not card_removed:
            (status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
            if status != MIFAREReader.MI_OK:
                card_removed_counter = card_removed_counter-1
                if card_removed_counter==0:
                    card_removed = True
            else:
                card_removed_counter = 5
                
        print "--- Card removed---"
        print "Place card again please..."





- For setup of RFID Reader, refer "Raspberry Pi 2 + MFRC522-python, to read RFID tag".
- For mxgxw/MFRC522-python, refer "Raspberry Pi 2 + MFRC522-python - Dump RFID Tag data using mxgxw/MFRC522-python".

Saturday, October 17, 2015

"Unboxing" the Intel Compute Stick

Check out what comes in the box with the Intel® Compute Stick (model: STCK1A32WFC), Intel’s tiny Windows-based computer. While the Intel® Compute Stick can fit in the palm of your hand, it's what we fit inside of it that is truly remarkable. The Intel® Compute Stick has 2GB of RAM, 32GB of storage, built-in WiFi, Bluetooth 4.0, and comes pre-loaded with Windows® 10. Included in the box is a Quick Start Guide, HDMI extension cable, power adapter with USB cable, and international plug adapters.

Connect. Compute. It’s that simple.


Learn more: http://www.intel.com/computestick

Remote develop C/C++ program from Windows 10, run on Raspberry Pi, using NetBeans IDE

This post show how to develop C/C++ program on Netbeans IDE run on Windows 10, set up remote host on raspberry Pi. Such that you can run the program on Raspberry Pi remotely.




Local client host (the PC you used to develop):
Windows 10
Netbeans IDE 8.0.2 with C/C++ plugins (https://netbeans.org/community/releases/80/cpp-setup-instructions.html#downloading)
C/C++ compiler: 32-bit MinGW(https://netbeans.org/community/releases/80/cpp-setup-instructions.html#mingw)

Remote host (The target remote platform to run the program):
Raspberry Pi 2
Raspbian Jessie (2015-09-24)

Follow the steps in the video:



Test code, C++:
#include <iostream>

using namespace std;

int main(int argc, char** argv) {

    std::cout << "Hello World!\n";
    
#ifdef __linux__
    std::cout << "__linux__\n";
#elif defined(__unix__)
    std::cout << "__unix__\n";
#elif defined(_WIN64)
    std::cout << "Windows 64\n";
#elif defined(_WIN32)
    std::cout << "Windows 32\n";
#endif

#if __WORDSIZE == 64
    std::cout << "64 bit\n";
#else
    std::cout << "32 bit\n";
#endif

    return 0;
}

Reference:
https://netbeans.org/kb/docs/cnd/remote-modes.html
https://netbeans.org/kb/docs/cnd/remotedev-tutorial.html#setup

Related:
Remote run JavaFX on Raspbian Jessie, from Netbeans/Windows 10


Friday, October 16, 2015

Python + OpenCV: generate Histograms of images


Python + OpenCv example run on Raspberry Pi 2 to generate Histograms of images, pyHist.py
from PIL import Image
import numpy as np
from matplotlib import pyplot as plt
import cv2

img = Image.open('photo.jpg')
#img = Image.open('b.png')
imgArr = np.asarray(img)

plt.subplot(221), plt.imshow(img)

color = ('r','g','b')
for i,col in enumerate(color):
    histr = cv2.calcHist([imgArr],[i],None,[256],[0,256])
    plt.subplot(222), plt.plot(histr,color = col)
    plt.xlim([0,256])

plt.xlim([0,256])

plt.show()



Reference: http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_imgproc/py_histograms/py_histogram_begins/py_histogram_begins.html

Python + OpenCV: convert RGB to HSV and reverse


Python + OpenCV example run on Raspberry Pi 2 to convert RGB to HSV and reverse from HSV to RGB, pyCV_cvtImage.py.
import sys
import cv2

print("Python version: \n" + sys.version)
print("cv2 version: " + cv2.__version__)

#img1 and img2 must be in same size
img1 = cv2.imread('Raspberry_Pi_Logo.png', 1)
hsv1 = cv2.cvtColor(img1, cv2.COLOR_RGB2HSV)
h,s,v = cv2.split(hsv1)
hsv2 = cv2.merge((h,s,v))
img2 = cv2.cvtColor(hsv2, cv2.COLOR_HSV2RGB)

cv2.imshow('img1',img1)
cv2.imshow('hsv1',hsv1)
cv2.imshow('h', h)
cv2.imshow('s', s)
cv2.imshow('v', v)
cv2.imshow('hsv2',hsv2)
cv2.imshow('img2',img2)

cv2.waitKey(0)
cv2.destroyAllWindow()


Thursday, October 15, 2015

GPIO Zero - a simple interface to GPIO for Raspberry Pi

GPIO Zero is a simple interface to everyday GPIO components used with Raspberry Pi, with very little code, you can quickly get going connecting your physical components together.

This video show my first try of GPIO Zero on raspberry Pi 2/Raspbian Jessie.


Connection (LED and Button):
Run IDLE with sudo, enter the simple code to test:
Python 2.7.9 (default, Mar  8 2015, 00:52:26) 
[GCC 4.9.2] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> from gpiozero import LED, Button
>>> led=LED(2)
>>> button=Button(3)
>>> button.when_pressed=led.on
>>> button.when_released=led.off
>>> 


Wednesday, October 14, 2015

Raspberry Pi LED Blueprints

Design, build, and test LED-based projects using the Raspberry Pi

Raspberry Pi LED Blueprints

About This Book
  • Implement real LED-based projects for Raspberry Pi
  • Learn to interface various LED modules such as LEDs, 7-segment, 4-digits 7 segment, and dot matrix to Raspberry Pi
  • Get hands-on experience by exploring real-time LEDs with this project-based book
Who This Book Is For
This book is for those who want to learn how to build Raspberry Pi projects utilising LEDs, 7 segment, 4-digits 7 segment, and dot matrix modules. You also will learn to implement those modules in real applications, including interfacing with wireless modules and the Android mobile app. However, you don't need to have any previous experience with the Raspberry Pi or Android platforms.

What You Will Learn
  • Control LEDs, 7 segments, and 4-digits 7 segment from a Raspberry Pi
  • Expand Raspberry Pi's GPIO
  • Build a countdown timer
  • Build a digital clock display
  • Display numbers and characters on dot matrix displays
  • Build a traffic light controller
  • Build a remote home light control with a Bluetooth low energy module and Android
  • Build mobile Internet-controlled lamps with a wireless module and Android
In Detail
Blinking LED is a popular application when getting started in embedded development. By customizing and utilising LED-based modules into the Raspberry Pi board, exciting projects can be obtained. A countdown timer, a digital clock, a traffic light controller, and a remote light controller are a list of LED-based inspired project samples for Raspberry Pi.

An LED is a simple actuator device that displays lighting and can be controlled easily from a Raspberry Pi. This book will provide you with the ability to control LEDs from Raspberry Pi, starting from describing an idea through designing and implementing several projects based on LEDs, such as, 7-segments, 4-digits 7 segment, and dot matrix displays.

Beginning with step-by-step instructions on installation and configuration, this book can either be read from cover to cover or treated as an essential reference companion to your Raspberry Pi. Samples for the project application are provided such as a countdown timer, a digital clock, a traffic light controller, a remote light controller, and an LED-based Internet of Things, so you get more practice in the art of Raspberry Pi development.

Raspberry Pi LED Blueprints is an essential reference guide full of practical solutions to help you build LED-based applications.

Style and approach
This book follows a step-by-step approach to LED-based development for Raspberry Pi, explained in a conversational and easy-to-follow style. Each topic is explained sequentially in the process of building an application, and detailed explanations of the basic and advanced features are included.

Monday, October 12, 2015

Raspberry Pi 2 + MFRC522-python - Dump RFID Tag data using mxgxw/MFRC522-python


Last post "Raspberry Pi 2 + MFRC522-python, to read RFID tag" show how to setup SPI on Raspberry Pi 2/Raspbian Jessia, and git clone rasplay/MFRC522-python to read id of RFID tag. It provide a example read.py only.

Here is another GitHub project mxgxw/MFRC522-python (A small class to interface with the NFC reader Module MFRC522), it provide examples of Dump.py, Read.py and Write.py also.

To set up SPI on Raspberry Pi 2/Raspbian Jessia, refer to last post.

This video show how to "git clone https://github.com/mxgxw/MFRC522-python" and run Dump.py to dump data of a brand new RFID key.



You can download APK of my Android exercise in my another blog, Android NFC: readBlock() for MifareClassic, to dump data in RFID tag; to compare the dumped data. Tested on brand new 1K MifareClassic RFID Tag only.


Next:
- The example of Dump.py repeat to display the tag data, not easy for checking. I modify it to display once, and also detect card removed. Read "Raspberry Pi + Python + mxgxw/MFRC522-python - Dump RFID Tag data one-by-one, and detect tag remove".


Raspberry Pi Sense HAT - AstroPi

Raspberry Pi Sense HAT - AstroPi

Possibilities include: Determining orientation
Detecting speed
Measure environmental conditions (temperature and humidity.)
The bright 8 x 8 RGB LED display can be used to display sensor data or games. An on-board directional joystick provides a human interface for navigation and input.
Compatible with Raspberry Pi B+, A+, and Pi 2

Product Description
The Raspberry Pi Sense HAT attaches via the Pi's 40pin GPIO port to read and display sensor data from a host of built-in sensors. Based on the same hardware that is currently in orbit on the International Space Station, the Sense HAT lets you create applications, experiments, and games.

Technical Specifications:
Gyroscope - angular rate sensor: +/-245/500/2000dps
Accelerometer - Linear acceleration sensor: +/-2/4/8/16 g
Magnetometer - Magnetic Sensor: +/- 4/8/12/16
Gauss Barometer: 260 - 1260 hPa absolute range (accuracy depends on the temperature and pressure, +/- 0.1 hPa under normal conditions)
Temperature sensor (Temperature accurate to +/- 2 degC in the 0-65 degC range)
Relative Humidity sensor (accurate to +/- 4.5% in the 20-80%rH range, accurate to +/- 0.5 degC in 15-40 degC range)
8x8 RGB LED matrix display
Small 5 button joystick
Compatible with Raspberry Pi B+, A+, and Pi 2

ASTRO PI The Raspberry Pi Sense HAT is being used in conjunction with the Raspberry Pi Foundation to perform science experiments aboard the International Space Station (ISS).

Raspberry Pi 2 + MFRC522-python, to read RFID tag

CAUTION@2016-08-19:
Somebody comment no need set device tree, check the comments (in the comments below and in the video: https://www.youtube.com/watch?v=0aVtZvkuHTA) first, before you try.



This post show the steps I install MFRC522-python (https://github.com/rasplay/MFRC522-python) on Raspberry Pi 2/Raspbian Jessie (2015-09-24), to read RFID tags (key and card) using RFID Reader, RFID-RC522.



Connection between RFID-RC522 Reader and Raspberry Pi 2:
RFID-RC522 pin NamePin #Raspberry Pi 2 Pin name
SDA24GPIO8
SCK23GPIO11
MOSI19GPIO10
MISO21GPIO9
IRQ-no connection
GNDGNDGND
RST22GPIO25
3.3V13V3

Steps:
1 - Enable SPI using Raspberry Pi Configuration


2 - Install python-dev and SPI-Py
$ sudo apt-get install python-dev
$ git clone https://github.com/lthiery/SPI-Py.git
$ cd SPI-Py
$ sudo python setup.py install


3 - Download MFRC522-python, MFRC522 Python Library for Raspberry Pi
(https://github.com/rasplay/MFRC522-python)
$ git clone https://github.com/rasplay/MFRC522-python.git


Unfortunately it is still not work!

Then I follow dzasa steps in this thread https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=106313 to solve the problem.

4 - Enable device tree
Edit /boot/config.txt to add the line:
device_tree=on


5 - Install latest version of bcm2835, C library for Broadcom BCM 2835 as used in Raspberry Pi; version 1.46 currently.
(http://www.airspayce.com/mikem/bcm2835/)
# download the latest version of the library, say bcm2835-1.xx.tar.gz, then:
$ tar zxvf bcm2835-1.xx.tar.gz
$ cd bcm2835-1.xx
$ ./configure
$ make
$ sudo make check
$ sudo make install


Then reboot.

6 - Test it:
$ cd MFRC522-python
$ sudo python read.py



Updated@2016-01-30:
when we using MFRC522 it will set GPIO port mode to GPIO.BOARD. So simply you can't access using GPIO ports when it is in this mode using GPIO pins numbers. But you can access any GPIO ports according to GPIO.BOARD representation.  ~ refer to Unknown comment below.


Next:
Raspberry Pi 2 + MFRC522-python - Dump RFID Tag data using mxgxw/MFRC522-python

Related:
- Arduino Uno + RFID-RC522, MFRC522 library example DumpInfo
- Android NFC: readBlock() for MifareClassic, to dump data in RFID tag

Sunday, October 11, 2015

Python + OpenCV: create negative image

Example to generate negative image:


import sys
import cv2

print("Python version: \n" + sys.version)
print("cv2 version: " + cv2.__version__)

#img1 and img2 must be in same size
img1 = cv2.imread('Raspberry_Pi_Logo.png', 1)
img2 = (255-img1)

cv2.imshow('img1',img1)
cv2.imshow('img2',img2)

cv2.waitKey(0)
cv2.destroyAllWindow()




Edit the example "Capture Raspberry Pi Camera image, display on OpenCV, Matplotlib PyPlot and Tkinter GUI" to generate negative image from the picamera captured image.

import picamera
import picamera.array
import time
import cv2
from matplotlib import pyplot as plt
import Tkinter 
import Image, ImageTk
import sys

def capturePiCam():
    with picamera.PiCamera() as camera:
        cap=picamera.array.PiRGBArray(camera)
        camera.resolution = (640, 480)
        camera.start_preview()
        time.sleep(3)
        camera.capture(cap,format="bgr")
        global img
        img =cap.array
        img = (255-img)

#- display on OpenCV window -
def displayAtOpenCV():
    cv2.namedWindow('imageWindow', cv2.WINDOW_AUTOSIZE)
    cv2.imshow('imageWindow',img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

#- display with matplotlib -
def displayAtPyplot():
    plt.figure().canvas.set_window_title("Hello Raspberry Pi")
    plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
    plt.xticks([]), plt.yticks([])  # to hide tick values on X and Y axis
    plt.show()
    
#- display on Tkinter -
def displayAtThinter():
    root = Tkinter.Tk() 
    b,g,r = cv2.split(img) 
    img2 = cv2.merge((r,g,b))
    img2FromArray = Image.fromarray(img2)
    imgtk = ImageTk.PhotoImage(image=img2FromArray) 
    Tkinter.Label(root, image=imgtk).pack() 
    root.mainloop()

def displayUsage():
    print("usage: ")
    print("python pyCV_picam.py 1 - display wiyh OpenCV window")
    print("python pyCV_picam.py 2 - display with matplotlib")
    print("python pyCV_picam.py 3 - display with Tkinter")

if len(sys.argv) != 2:
    displayUsage()
    sys.exit()
    
opt = sys.argv[1]

if opt=="1":
    print("display wiyh OpenCV window")
    capturePiCam()
    displayAtOpenCV()
elif opt=="2":
    print("display with matplotlib")
    capturePiCam()
    displayAtPyplot()
elif opt=="3":
    print("display with Tkinter")
    capturePiCam()
    displayAtThinter()
else:
    displayUsage()


Python + OpenCV: split and merge - to exchange color channel

Example to use OpenCV split() and merge() to separate color channel, and re-construct image with red and blue color channel exchanged.


import sys
import cv2

print("Python version: \n" + sys.version)
print("cv2 version: " + cv2.__version__)

#img1 and img2 must be in same size
img1 = cv2.imread('Raspberry_Pi_Logo.png', 1)
b,g,r = cv2.split(img1)
img2 = cv2.merge((r,g,b))

cv2.imshow('img1',img1)
cv2.imshow('img2',img2)
cv2.imshow('r', r)
cv2.imshow('g', g)
cv2.imshow('b', b)
cv2.waitKey(0)
cv2.destroyAllWindow()


Python + OpenCV: Arithmetic Operations on Images - add(), addWeighted() and subtract()



import sys
import cv2
import numpy
import urllib

print("Python version: \n" + sys.version)
print("cv2 version: " + cv2.__version__)
print("numpy version: " + numpy.__version__)
print("urllib version: " + urllib.__version__)

#img1 and img2 must be in same size
img1 = cv2.imread('Raspberry_Pi_Logo.png', 1)
img2 = cv2.imread('opencv-logo-white.png', 1)
imgAdd = cv2.add(img1, img2)
imgAddWeighted = cv2.addWeighted(img1, 0.7, img2, 0.3, 0)
imgSub = cv2.subtract(img1, img2)

cv2.imshow('img1',img1)
cv2.imshow('img2',img2)
cv2.imshow('imgAdd',imgAdd)
cv2.imshow('imgAddWeighted',imgAddWeighted)
cv2.imshow('imgSub',imgSub)
cv2.waitKey(0)
cv2.destroyAllWindow()



Reference: http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_core/py_image_arithmetics/py_image_arithmetics.html

Saturday, October 10, 2015

Learning Python Network Programming

Utilize Python 3 to get network applications up and running quickly and easily

Learning Python Network Programming

About This Book
  • Leverage your Python programming skills to build powerful network applications
  • Explore steps to interact with a wide range of network services
  • Design multithreaded and event-driven architectures for echo and chat servers
Who This Book Is For
If you're a Python developer or a system administrator with Python experience and you're looking to take your first steps in network programming, then this book is for you. Basic knowledge of Python is assumed.

What You Will Learn
  • Develop an understanding of network stacks and the power of encapsulation
  • Design high-performance network server applications
  • Implement socket-based network applications using asynchronous models
  • Build client applications for major web APIs, including Amazon S3 and Twitter
  • Interact with e-mail servers using SMTP, POP3, and IMAP protocols
  • Deal with remote network servers using SSH, FTP, SNMP, SMB/CIFS, and LDAP protocols
  • Work with IP addresses including Geo-IP lookups
  • Download objects from the Web and craft custom HTTP requests with urllib and the Requests library
In Detail
Network programming has always been a demanding task. With full-featured and well documented libraries all the way up the stack, Python makes network programming the enjoyable experience it should be.

Starting with a walkthrough of today's major networking protocols, with this book you'll learn how to employ Python for network programming, how to request and retrieve web resources, and how to extract data in major formats over the Web. You'll utilize Python for e-mailing using different protocols and you'll interact with remote systems and IP and DNS networking.

As the book progresses, socket programming will be covered, followed by how to design servers and the pros and cons of multithreaded and event-driven architectures. You'll develop practical client-side applications, including web API clients, e-mail clients, SSH, and FTP. These applications will also be implemented through existing web application frameworks.

Remote control Raspberry Pi from Windows 10 using Remote Desktop App

Updated@2016-06-15:
No longer work after Microsoft update Remote Desktop for Windows 10 recently.

Fortunately, Remote Desktop Connection to Raspberery Pi is still work:)

~ read "Microsoft Remote Desktop for Windows 10 updated, cannot connect RPi again ...!".

With Microsoft Remote Desktop app, you can remote control Raspberry Pi from Windows 10 PC.


In Raspberry Pi, install xrdp
$ sudo apt-get install xrdp

In Windows 10 Store, install Remote Desktop app by Microsoft Corporation.


Host:
Raspberry Pi 2 running Raspbian Jessie (2015-09-24) with XRDP installed
Client:
Windows 10, with Microsoft Remote Desktop App

Related:
- Remote Desktop Connection from Windows 10 to Raspberry Pi xrdp

Thursday, October 8, 2015

Python/OpenCV, get image properties - number of row, column, color channel


import sys
import cv2
import numpy
import urllib

print("Python version: \n" + sys.version)
print("cv2 version: " + cv2.__version__)
print("numpy version: " + numpy.__version__)
print("urllib version: " + urllib.__version__)

url = 'http://goo.gl/41cgQr'
data = urllib.urlopen(url)
img = numpy.asarray(bytearray(data.read()), dtype='uint8')
img = cv2.imdecode(img, cv2.IMREAD_COLOR)

print("")
print "image info"
print "#row #column #channel"
print img.shape
print "#row * #column * #channel"
print img.size

cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyWindow('image')



Tuesday, October 6, 2015

Learn Raspberry Pi 2 with Linux and Windows 10 2nd Edition

Learn Raspberry Pi 2 with Linux and Windows 10

Learn Raspberry Pi 2 with Linux and Windows 10 will tell you everything you need to know about working with Raspberry Pi 2 so you can get started doing amazing things. You'll learn how to set up your new Raspberry Pi 2 with a monitor, keyboard and mouse, and how to install both Linux and Windows on your new Pi 2.

Linux has always been a great fit for the Pi, but it can be a steep learning curve if you've never used it before. With this book, you'll see how easy it is to install Linux and learn how to work with it, including how to become a Linux command line pro. You'll learn that what might seem unfamiliar in Linux is actually very familiar. And now that Raspberry Pi also supports Windows 10, a chapter is devoted to setting up Windows 10 for the Internet of Things on a Raspberry Pi.

Finally, you'll learn how to create these Raspberry Pi projects with Linux:
  • Making a Pi web server: run LAMP on your own network
  • Making your Pi wireless: remove all the cables and retain all the functionality
  • Making a Raspberry Pi-based security cam and messenger service
  • Making a Pi media center: stream videos and music from your Pi
What you’ll learn
  • How to install both Linux and Windows 10 on your Raspberry Pi 2
  • How to customize your Pi's desktop environment
  • Essential commands for putting your Pi to work
  • Basic network services - the power behind what Pi can do
  • How to make your Pi totally wireless by removing all the cables
  • How to turn your Pi into your own personal web server
  • How to turn your Pi into a spy
  • How to turn your Pi into a media center
Who this book is for
Raspberry Pi users who are new to Linux and the Linux command line, and who want to get a taste of the new Windows 10 for Raspberry Pi 2.

Table of Contents
1: Your First Bite of Raspberry Pi
2: Surveying the Landscape
3: Getting Comfortable
4: The File-Paths to Success
5: Essential Commands
6: Editing Files on the Command Line
7: Managing Your Pi
8: A LAMP of Your Own
9: WiPi: Wireless Computing
10: The Raspberry sPi
11: Pi Media Center
12. Installing Windows 10!
13. TOR
Appendix. Doing It by Hand – Writing an SD Card Image

Monday, October 5, 2015

Using Yocto Project with BeagleBone Black

Unleash the power of the BeagleBone Black embedded platform with Yocto Project

Using Yocto Project with BeagleBone Black

About This Book
  • Build real world embedded system projects using the impressive combination of Yocto Project and Beaglebone Black
  • Learn how to effectively add multimedia to your board and save time by exploiting layers from the existing ones
  • A step-by-step, comprehensive guide for embedded system development with hands-on examples
Who This Book Is For
This book is ideal for system developers with knowledge and experience of embedded systems. Knowledge of BeagleBone Black is assumed, while no knowledge of Yocto Project build system is necessary.

What You Will Learn
  • Develop a successful package or image with the help of the BitBake tool
  • Generate a recipe for some trendy console-based games
  • Boot up BeagleBone using images created with Yocto Project
  • Customize the root file system using a custom layer
  • Create a home surveillance solution using a webcam attached to the BeagleBone USB port
  • Turn BeagleBone into a Wi-fi access point by attaching a USB dongle
  • Build different versions of the helloworld recipe
In Detail
The Yocto Project produces tools and processes that enable the creation of Linux distributions for embedded software, independent of the architecture. BeagleBone Black is a platform that allows users to perform installation and customizations to their liking, quickly and easily.

Starting with a basic introduction to Yocto Project's build system, this book will take you through the setup and deployment steps for Yocto Project. You will develop an understanding of BitBake, learn how to create a basic recipe, and explore the different types of Yocto Project recipe elements. Moving on, you will be able to customize existing recipes in layers and create a home surveillance solution using your webcam, as well as creating other advanced projects using BeagleBone Black and Yocto Project.

By the end of the book, you will have all the necessary skills, exposure, and experience to complete projects based on Yocto Project and BeagleBone Black.

Install python-gphoto2 on Raspberry Pi/Raspbian Wheezy - success



Refer to the previous post "Install and test python-gphoto2 (Python interface to libgphoto2) on Raspberry Pi 2/Raspbian Jessie", success to install but fail to run. In order to verify the steps, I redo it on Raspberry Pi (1st generation, NOT 2)/Raspbian Wheezy.

Install gphoto2 and libgphoto using gphoto2-updater script. Both gphoto2 and libgphoto2 installed are version 2.5.8.


Then install python-gphoto2:
$ sudo apt-get install python-pip
$ sudo apt-get install python-dev
$ sudo pip install gphoto2

It seem much better.

Sunday, October 4, 2015

Install PyQt4 on Raspberry Pi

o install PyQt4 for Python 2 on Raspberry Pi
$ sudo apt-get install python-qt4

for Python 3
$ sudo apt-get install python3-pyqt4



Example: hello.py
import sys
from PyQt4.QtGui import *

from PyQt4.QtCore import QT_VERSION_STR
from PyQt4.Qt import PYQT_VERSION_STR
from sip import SIP_VERSION_STR

a = QApplication(sys.argv)       

w = QWidget()
w.resize(320, 240)
w.setWindowTitle("Hello World!") 

label = QLabel()
info = "Qt version:" + QT_VERSION_STR + \
       "\nSIP version:" + SIP_VERSION_STR + \
       "\nPyQt version:" + PYQT_VERSION_STR
label.setText(info)

hbox = QHBoxLayout()
hbox.addWidget(label)
w.setLayout(hbox)

w.show() 
 
sys.exit(a.exec_())


PyQt4 hello.py run on Python 2

PyQt4 hello.py run on Python 3

Install and test python-gphoto2 (Python interface to libgphoto2) on Raspberry Pi 2/Raspbian Jessie - fail

python-gphoto2 is a comprehensive Python interface (or binding) to libgphoto2.

Before install python-gphoto2, we have to install libgphoto2, I run the gphoto2-updater script to install gphoto2 and libgphoto2 on Raspberry Pi 2/Raspbian Jessie. After finished, gphoto2 2.5.8 and libgphoto2 2.5.4 will be installed.


- Install python-dev
sudo apt-get install python-dev

- install python-gphoto2 with pip
sudo pip install gphoto2

If you installed with pip the example files should be in /usr/share/python-gphoto2/examples or /usr/local/share/python-gphoto2/examples or somewhere similar. Otherwise they are in the examples sub-directory of your working directory. In Raspbian Jessie, it should be in /usr/local/share/python-gphoto2/examples.

Connect a digital camera to your Raspberry Pi, switch it on, and unmount it before access with Python, and try one of the example programs:

$ python camera-summary.py


In my first test, I can run example of camera-summary.py to list details of the connected camera, but fail to capture image, with Segmentation fault!



In order to verify the steps, I redo it on Raspberry Pi (1st generation, NOT 2)/Raspbian Wheezy. Read "Install python-gphoto2 on Raspberry Pi/Raspbian Wheezy - success".


Updated@2015-12-03:
After install both gphoto and libgphoto2 of the same version 2.5.9, we can install python-gphoto2 and capture image successful.


Saturday, October 3, 2015

Python on Raspberry Pi to control DSLR with python-piggyphoto and libgphoto2


This post show how to control DSLR (Nikon D7000) with Raspberry Pi 2 (running Raspbian Jessie), using Python 2, with libgphoto2 and piggyphoto. The camera connect to Raspberry Pi via USB.


piggyphoto is a Python bindings for libgphoto2. You have to install libgphoto2.

To install piggyphoto for Python 2, enter the command:
$ sudo apt-get install python-piggyphoto

Try in Python 2:
import piggyphoto

C = piggyphoto.camera()
print C.abilities
C.capture_preview('prev.jpg')
C.capture_image('image.jpg')


Reference: https://github.com/alexdu/piggyphoto

Remote run JavaFX on Raspbian Jessie, from Netbeans/Windows 10


This video show how to setup Remote Java SE Platform in Netbeans IDE running on Windows 10, deploy JavaFX application running on Raspberry Pi 2/Raspbian Jessie. Actually, it's same as in Raspbian Wheezy.




Related:
- Remote develop C/C++ program from Windows 10, run on Raspberry Pi, using NetBeans IDE

Friday, October 2, 2015

Official Raspberry Pi Foundation Case For Model B+ & Raspberry Pi 2 Model B

Official Raspberry Pi Foundation Case For Model B+ & Raspberry Pi 2 Model B

Official case of the the Raspberry Pi Foundation
Preassembled 5 part enclosure--Removable Lid for easy access to the camera and display ports--Removable Top Frame--Removable Side Panels with easy access to the GPIO port
Designed with Pi HAT's in mind
Dimensions: 96mm x 70mm x 25mm
Compatible with the Raspberry Pi 2 Model B and Raspberry Pi Model B+