R&D Publishing‎ > ‎

Raspberry Pi

Understand SPI Raspberry Pi | Raspi Timer Lamp Control  | Run Script at Startup | Fix Raspberry Pi USB Serial Path

No rule to make target '../rc-switch/RCSwitch.o', needed by 'send'.  Stop.
Go to the root folder of your project and do as follow:
git submodule init 
git submodule update 

Ubuntu Linux TL-WN725N TP-Link version 2 WiFi driver install

Quick List:: Do each command below as root or use sudo in front of commands *Tip:  Use command:       sudo su – The above command will give root permissions to your  command terminal window, and you want have to keep typing sudo before each commando

apt-get update
apt-get install linux-headers-$(uname -r)
apt-get update
apt-get install build-essential
apt-get install git
git clone https://github.com/lwfinger/rtl8188eu
cd rtl8188eu
make all
make install
insmod 8188eu.ko
ifconfig #(check to see if your wireless wlan cards is now listed)
#optional step ...reboot may be necessary
#sometimes a reboot helps pickup newly installed devices
DONE! Now you can use that sweet new wlan TP-LINK TL-WN725N  WiFi usb card!!

cd /var/lib/dpkg/updates
sudo rm *

# cpustatus
# Prints the current state of the CPU like temperature, voltage and speed.
# The temperature is reported in degrees Celsius (C) while
# the CPU speed is calculated in megahertz (MHz).
function convert_to_MHz {
let value=$1/1000
echo "$value"
function calculate_overvolts {
# We can safely ignore the integer
# part of the decimal argument
# since it's not realistic to run the Pi
# at voltages higher than 1.99 V
let overvolts=${1#*.}-20
echo "$overvolts"
temp=$(vcgencmd measure_temp)
volts=$(vcgencmd measure_volts)
if [ $volts != "1.20" ]; then
overvolts=$(calculate_overvolts $volts)
minFreq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq)
minFreq=$(convert_to_MHz $minFreq)
maxFreq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq)
maxFreq=$(convert_to_MHz $maxFreq)
freq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
freq=$(convert_to_MHz $freq)
governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
echo "Temperature: $temp C"
echo -n "Voltage: $volts V"
[ $overvolts ] && echo " (+0.$overvolts overvolt)" || echo -e "\r"
echo "Min speed: $minFreq MHz"
echo "Max speed: $maxFreq MHz"
echo "Current speed: $freq MHz"
echo "Governor: $governor"
exit 0
Setup PI for IR Remote GPIO for OpenElec
Use putty.exe (Google it) to connect sh to Pi, user name : "root", password "openelec"
Doing as follow
Check if the lircd.conf exist by File share from PC (example \\IP ADDRESS) find in Configfile directory, Please delete it
Code 1: modprobe 
Code 2: echo "modprobe lirc_rpi" >> /storage/.config/autostart.sh   // It is to tell RPI look lirc
Code 3: irrecord /storage/.config/lircd.conf 
Doing as guide on the screen but very important :

***Should press and hold your remote for RPI capture mask, space and gap form IR stream, Also press some others key for average calculation but dont stop hold
Pass this step and type KEY_ (UP, DOWN...) and point Remote to IR Receiver for PI learning.

That is all

Setting up WiFi connection for Screenly OSE

YouTube Video

Start by booting the Raspberry Pi, connected to a display and a keyboard. Open up the terminal and edit the network interfaces file:

$ sudo nano /etc/network/interfaces

This file contains all known network interfaces, it'll probably have a line or two in there already.

Change the first line (or add it if it's not there) to:

auto wlan0

Then at the bottom of the file, add these lines telling the Raspberry Pi to allow wlan as a network connection method and use the/etc/wpa_supplicant/wpa_supplicant.conf as your configuration file.

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

(ctrl-X, then type Y to quit and save)

The next step is to create this configuration file.

Configuring WiFi connection

Open up the wpa_supplicant.conf file in the editor.

$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Again, some lines might already be present, just add the following.


The other parameters are network specific, I can't tell you what you need. If you boot Raspbian to desktop, you can launc the wpa_gui (WiFi config) application and click 'Scan'. You'll find a list that has your network too with all flags you need. To do this on a RPi A you'll have to disconnect your keyboard and connect your dongle once the scanning list is open.

  • proto could be either RSN (WPA2) or WPA (WPA1).
  • key_mgmt could be either WPA-PSK (most probably) or WPA-EAP(enterprise networks)
  • pairwise could be either CCMP (WPA2) or TKIP (WPA1)
  • auth_alg is most probably OPEN, other options are LEAP and SHARED

Make sure it works

Reboot the Raspberry Pi and it should connect to the wireless network. If it doesn't, repeat above steps or get help from an adult.

A static IP

Since the goal of this tutorial is to be able to work with the RPi without external keyboard or display, you want to be ssh into it. The best way is to make sure it'll always have a static IP on your network.

Doing so is simple. Open the /etc/network/interfaces file again and add the following changes:

Change iface wlan0 inet dhcp into iface wlan0 inet static. This changes the wlan0 interface from DHCP to static.

Add the following lines before the wpa-conf line:

address # Static IP you want 
gateway # IP of your router

The Raspberry Pi will still be able to connect to the internet.

Wrapping up

With these changes you'll be able to always connect to your Raspberry Pi over your wireless network via ssh at the same, static IP. This means you can disconnect keyboard, mouse and display and have it plugged in a wall socket, anywhere, taking almost no space.

As an overview, my interfaces- and wpa_supplicant-files:

# /etc/network/interfaces
auto wlan0
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet static
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
# /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


Just edit interface file as below

# /etc/network/interfaces

auto lo
iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wireless-essid EVNCEPC OFFICE
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp


To scan for WiFi networks, use the command sudo iwlist wlan0 scan. This will list all available WiFi networks along with other useful information. Look out for:

  1. ESSID:"testing". This is the name of the WiFi network.
  2. IE: IEEE 802.11i/WPA2 Version 1. This is the authentication used; in this case it is WPA2, the newer and more secure wireless standard which replaces WPA1. This guide should work for WPA or WPA2, but may not work for WPA2 enterprise; for WEP hex keys see the last example here
    You will also need the password for the WiFi network. For most home routers this is located on a sticker on the back of the router. The ESSID (ssid) for the network in this case is testing and the password (psk) testingPassword.


Open the wpa-supplicant configuration file in nano:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Go to the bottom of the file and add the following:


In the case of the example network, we would enter:


Now save the file by pressing ctrl+x then y, then finally press enter.

At this point, wpa-supplicant will normally notice a change has occurred within a few seconds, and it will try and connect to the network. If it does not, either manually restart the interface with sudo ifdown wlan0 and sudo ifup wlan0, or reboot your Raspberry Pi with sudo reboot.

You can verify if it has successfully connected using ifconfig wlan0. If the inet addr field has an address beside it, the Pi has connected to the network. If not, check your password and ESSID are correct.


Run command

$sudo nano /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
Edit wpa_supplicant

$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

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

In this tutorial, I’m going to talk you through running Raspbian from a USB connected drive instead of from an SD card. Running from a USB connected Flash or Hard Drive has many advantages, the biggest being speed and reliability.

SD Cards have a limited read/write cycle, and when hosting a site with a MySQL database from a SD card, it won’t take long before you start getting corruptions and failures. USB Flash drives provide a cheap and reliable alternative. I’ve tested several USB Flash drives, and found Sandisk and Corsair to be the best for speed and reliability. This site is run off a 16GB Corsair Voyager 3 USB Flash drive.

Assumptions before we begin

I’m going to assume that you know your way around Terminal, and are using a Mac to perform these steps. You will still need an SD card to store the boot instructions to tell the Raspberry Pi to launch the OS from the USB; the Raspberry Pi’s can’t (yet) boot directly from a USB storage device.

Step 1 – Download Raspbian from Raspberry Pi

You will need the standard Raspbian OS image, you can download this from the official Raspberry Pi website. Once you’ve downloaded it, unzip it. It’s around 400mb in size, so should only take a couple of minutes over a broadband connection.

Step 2 – Install the Raspbian OS to your USB Flash drive

Plug in your USB stick and launch Terminal. The first thing we’re going to do is get the device identifier for your USB Flash drive. To do this run the following command:

diskutil list

The list of attached disks will show up with their identifiers. Important – make a note of the correct identifier, you can do some serious damage by choosing the wrong one!

In the screen shot above, I can see that /dev/disk2 is the correct identifier for my Sandisk USB Flash Drive. Yours may be different so change to suit your configuration. Next we’re going to unmount the USB Flash Drive. To do this enter the following command:

diskutil unmountDisk /dev/disk2

Yet again, be really careful to change disk2 to whatever your computer identifies the USB Flash Drive as. You will get a message saying

“Unmount of all volumes on disk2 was successful”.

Now we can begin the copy. For ease, I’ve changed the directory in Terminal to where the Raspbian image is located, which in this case is my downloads folder. If you’ve downloaded and unzipped the disk image to your downloads folder, running this command should take you there:

cd ~/Downloads/

Now run this command to begin the copy:

sudo dd bs=1m if=2013-02-09-wheezy-raspbian.img of=/dev/disk2

As with before, make sure you change disk2 to whatever your computer identifies as being the USB Flash Drive, and change 2013-02-09-wheezy-raspbian.img to whatever your image file is called. The blocks will now begin moving to your USB Flash Drive from the Raspbian OS image. This takes anything from 5 to 20 mins depending on the speed of your USB Flash Drive. Go stick the kettle on and have a brew!

Eventually, you will see something similar to the above, and it probably took a while too. The next step is to configure your SD Card to give the correct boot instruction to start the OS from the USB Flash Drive

Step 3 – Configure your SD card

Using Disk Utility, format your SD Card using FAT32. It’s dead easy, choose your SD Card from the devices listed on the right, then click on ‘Erase’, choose FAT32 in the Formats list and click on ‘Erase’.

Once you’ve done this, you’ll notice on your Desktop, there are two mounted volumes; one is your USB Flash Drive, the other is your SD Card.

Open up the USB Flash Drive volume and copy all the files from that onto your SD card. This copies the all-important files and instructions to tell your Raspberry Pi to boot from the USB Flash Drive. We’re almost done at this point, only one more step to go.

Step 4 – Change the boot path on your SD card

Once you’ve completed step 3, you need to change the default boot path to tell the Raspberry Pi to boot from your USB drive. Open a new Finder window and go to your SD card. Open up the file called cmdline.txt in TextEdit or similar and amend the line which reads:


To this:


This will instruct your Raspberry Pi to boot from the USB Flash Drive instead of from the SD card. Save the cmdline.txt file and close the Finder window. We’re almost done!

Step 4 – Boot from your USB Flash Drive on your Raspberry Pi

Now unmount both your USB Flash Drive and your SD card and pop them both into your Raspberry Pi and switch it on. If all goes well, it should boot from your USB Flash Drive which you’ll find substantially quicker than your SD Card.

Step 5 – Expand the Raspbian partition on your USB Flash drive to fill it

Finally, we’re just going to do a little housekeeping to utilise all the available space on your USB Flash drive as the method using raspi-config doesn’t work on USB Flash drives. This isn’t essential, but if you have the extra space on a USB Flash Drive, why not use it all?

From your Raspberry Pi, type the following command to start FDisk:

sudo fdisk /dev/sda

Then press p and enter to see the partitions. There should only be 2. What we’re going to do now is delete the Linux partition, but before we do this, we make a note of the start position for the linux partition sda2. Press d and then when prompted type 2 and then hit enter. This will delete the partition.

Now we’re going to create a new partition, and make it large enough for the OS to occupy the full space available on the USB Flash Drive. To do this type n to create a new partition, when prompted to give the partition type, press p for primary. Then it will as for a partition number, press 2 and hit enter.

You will be asked for a first sector, set this as the start of partition 2 as noted earlier. In my case this as 12280 but this is likely to be different for you.

After this it will ask for an end position, hit enter to use the default which is end of disk. Now type w to commit the changes. You will see a message about the Kernel using some table yaddah yaddah, just ignore this. Type the following to reboot:

sudo reboot

Once your Raspberry Pi has rebooted, we need to resize the partition. To do this type the following command:

sudo resize2fs /dev/sda2

Be patient, this will take some time. Once it’s done reboot again. Then type:

df -h

This will show the partitions and the space, you’ll see the full USB Flash Disk has all the space available now. That’s it, all done!