Soc ninja title

Raspberry pi 3 with Opencv and serial connection with a microcontroller


Components list
Qty. Component Provider Total Price
1 Raspberry Pi 3 Model B exp-tech 55,68 €
1 Raspberry Pi 3 Case exp-tech 11,25 €
1 2.5A 5V Power Supply exp-tech 9,99 €
1 usb camera with mjpeg codec
1 any HDMI TV

Download the last Raspbian Jessie Little

  • Unzip the image: 
  • Identify your sdcard:  $ sudo fdisk -l
  • copy the image to tour sdcard

$ sudo dd bs=1m if=<debian-image>.img of=/dev/<sdcard-disk> 

TRICK: If you want to monitor the progress of dd use:

$ sudo su -
# pv <debian-image>.img | dd bs=1m of=/dev/

Configure raspbian

sudo raspi-config
1 Expand Filesystem Ensures that all of the SD card storage is available to the OS
2 Change User Password Change password for the default user (pi)
4 Internationalisation Options > I3 Change keyboard layout (Select first opiton as default)
8 Advanced Options> SSH Enable remote command line access to your Pi using SSH.

Configure hostname:

$  sudo vim /etc/hostname 

#just as example
$  sudo vim /etc/hosts       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters       raspi_01

Setup multiple wifi networks with static IPs

Then disable the DHCP client daemon and switch to standard Debian networking:

$ sudo systemctl disable dhcpcd 
$ sudo systemctl enable networking
Configure static or dhcp network adddresses on your Pi in /etc/network/interfaces
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

# iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

# example of static configuration
iface work inet static

# example of dhcp configuration
iface home inet dhcp

# allow-hotplug wlan1
# iface wlan1 inet manual
#     wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Configure network wifi sids and passwords /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev



You can use your unencripted password in psk section or use wpa_passphrase to generate the network configuration:

$ wpa_passphrase HOME_SID
# reading passphrase from stdin

Install python-opencv and check the camera

Install python-opencv:

$ sudo apt-get update
$ sudo apt-get install python-opencv

List devices:

$ v4l2-ctl --list-devices
HD Webcam C615 (usb-3f980000.usb-1.4):

Check the current video mode for your USB webcam:

$ v4l2-ctl --all
Video input : 0 (Camera 1: ok)
Format Video Capture:
    Width/Height  : 640/480
    Pixel Format  : 'YUYV'
    Frames per second: 30.000 (30/1)

Check the available video modes for your USB webcam :

$ v4l2-ctl --list-formats
    Index       : 0
    Type        : Video Capture
    Pixel Format: 'YUYV'
    Name        : YUYV 4:2:2

    Index       : 1
    Type        : Video Capture
    Pixel Format: 'MJPG' (compressed)
    Name        : Motion-JPEG

$ v4l2-ctl --list-formats-ext
    Pixel Format: 'YUYV'
    Name        : YUYV 4:2:2
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 160x120
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps
    Pixel Format: 'MJPG' (compressed)
    Name        : Motion-JPEG
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)

Capturing video with v4l2 with libv4l support to convert any image format to RGB or YUV420

$ sudo apt-get install libv4l-dev python-dev
$ git clone
$ cd python-v4l2capture
$ ./ build
$ sudo ./ install

Download from:

If you found anything useful enough and you want to thank us for that, please consider donating to people who need it, like the NGO OXFAM. Thank you !


Comments are manually approved. Just be a bit patient :-)

There are currently no comments

New Comment


required (not published)


Recent Tweets