Raspberry: Difference between revisions

From 太極
Jump to navigation Jump to search
Line 20: Line 20:
* [http://m.linuxjournal.com/content/n900-slice-raspberry-pi?page=0,1 N900 as a remote display]
* [http://m.linuxjournal.com/content/n900-slice-raspberry-pi?page=0,1 N900 as a remote display]
* Use Raspberry Pi behind a proxy http://www.raspberrypi.org/phpBB3/viewtopic.php?f=63&t=13986
* Use Raspberry Pi behind a proxy http://www.raspberrypi.org/phpBB3/viewtopic.php?f=63&t=13986
* May 2013 issue of Linux Journal


= Remote desktop connection with tightvnc =
= Remote desktop connection with tightvnc =

Revision as of 22:03, 8 May 2013

Raspberry Pi

ARM architecture (armv6)

http://www.memetic.org/raspbian-benchmarking-armel-vs-armhf/

Miscellaneous

Remote desktop connection with tightvnc

http://www.howtogeek.com/141157/how-to-configure-your-raspberry-pi-for-remote-shell-desktop-and-file-transfer/2/

tightvncserver
vncserver :1 -geometry 1600×900 -depth 16 -pixelformat rgb565:
vncserver –kill :1

Raspbian package repository

http://archive.raspbian.org/raspbian/pool/main/r/r-base/

LXDE (same as Lubuntu)

Quick launch bar

To add lxterminal to quick launch bar,

Right click any empty space on taskbar
-> Panel Setting
-> Panel Preferences
-> Panel Applets
-> Application launch bar & Edit
-> Accessories & lxterminal 

Keyboard shortcut

The shortcuts are defined in the file ~/.config/openbox/lxde-rc.xml

For example,

  • open the lxpanelctl menu, click Ctrl + ESC.
  • open launch an application, click Windows + r.
  • Toggle full screen, Alt + F11.
  • Launch task manager, Ctrl + Alt + Del.

Get internet by sharing the internet from another machine

  • https://wiki.archlinux.org/index.php/Internet_Share
  • static iP. Set up host eth0 IP and then set up RPi IP:
    • In Windows, allow Internet sharing. An IP of 192.168.0.2 will be automatically assigned to the Laptop's network card. Make static IP of 192.168.0.2 in Rasp Pi. Enter subnet mask and gateway (192.168.0.1). Also make an entry in /etc/resolv.conf with nameserver=192.168.0.1. Reboot and Rasp Pi will get Net all right.
    • In Linux, An IP of 10.42.0.37 will be assigned to eth0 card. Make static IP of 10.42.0.37 in Rasp Pi. Enter subset mask and gateway (10.42.0.1). Also make an entry in /etc/resolv.conf with nameserver=10.42.0.1. Reboot and Rasp Pi will get Net all right.
    • Other thoughts:
sudo nano /etc/network/interfaces

iface eth0 inet static
address 192.168.100.1
netmask 255.255.255.0
network 192.168.100.0
broadcast 192.168.100.255
gateway 192.168.100.254

The gateway is important and in most cases will always point to your firewalls, switch or routers IP address.

In my current setting, the host machine's eth0 has IP 10.42.0.1 (inet addr). The RPi has IP 10.42.0.37 and gateway 10.42.0.1.

$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 wlan0
10.42.0.0       0.0.0.0         255.255.255.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0

And /etc/resolv.conf may be worth to be changed too. /etc/hostname and /etc/hosts are unnecessary.

An example of /etc/resolv.conf (set up linux DNS) shown from my RPi is

nameserver 10.42.0.1

But maybe another choice is nameserver 8.8.8.8.

Some tools for discovering the IPs in a network include Fing (iOS/Android) or Scapy (python).

IP scan tools

  • fing (ios, android, linux, windows). Command line usage
sudo fing -n 192.168.1.1/24

where /24 means 'network prefix' size 24 bits. Check wikipedia classless inter domain routing. For example, CIDR notation 192.168.100.0/24 would be equivalent to 192.168.100.0/255.255.255.0.

  • Angry ip scanner cross platform. open source. Basic knowledge on internet protocol. However, it is slow and show all instead of found ip's.
  • netbios. It does not discover linux boxes, however.

GPIO experiments

C libraries

GPIO layout

The following picture was taken from www.raspberrypi-spy.co.uk

Raspberry-Pi-GPIO-Layout-Revision-2.png

WebIOPi

WebIOPi is a REST framework and a webapp which allows you to control Raspberry Pi's GPIO. It does not require apache to be installed. So we can use web browser from Android to control the GPIO in Raspbery Pi ... Another choice is Web.py.

Run Python using webiopi module

sudo python -m webiopi 8000

Start/stop the background service

sudo /etc/init.d/webiopi start
sudo /etc/init.d/webiopi end

Start webiopi at startup:

sudo update-rc.d webiopi defaults

Note that we shall browse to http://localhost:8000/ instead of http://localhost:8000/webiopi. If something is still wrong, use a different port. The default user is "webiopi" and password is "raspberry".

It seems the code is still not stable. I kept getting a message "Error response" Error code 404. Message: Not Found. Error code explanation: 404 = Nothing matches the given URI.

Web.py

See the article The Python Pit - drive your Raspberry Pi with a mobile phone in http://www.themagpi.com/en/issue/9.

Circuit and Electronics

Blink a single LED

I follow the instruction in https://projects.drogon.net/raspberry-pi/gpio-examples/tux-crossing/gpio-examples-1-a-single-led/ to install gpio program/library in raspberry pi. Here is the result

  • without PI cobbler: http://www.youtube.com/watch?v=xWJZRK4W13Q
  • with PI cobbler: see the picture below. The soldering part is not easy for a beginner. Be sure to follow some instruction on youtube videos to begin with. Note that the white stripe is on the edge closest to the SD card.

SingleLED.jpg

import RPi.GPIO as GPIO  
import time  
# blinking function  
def blink(pin):  
        GPIO.output(pin,GPIO.HIGH)  
        time.sleep(1)  
        GPIO.output(pin,GPIO.LOW)  
        time.sleep(1)  
        return  
# to use Raspberry Pi board pin numbers  
GPIO.setmode(GPIO.BOARD)  
# set up GPIO output channel  
GPIO.setup(11, GPIO.OUT)  
# blink GPIO17 50 times  
for i in range(0,50):  
        blink(11)  
GPIO.cleanup()
  • Google: raspberry pi python led

16x2 LCD

http://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi. The '16x2' LCD means it can show 16 characters per row and there are 2 rows in total. Each character consists of 8x5 (height x width) dots.

RpyLCD.jpg

8x8 Matrix LED Backpack

http://learn.adafruit.com/matrix-7-segment-led-backpack-with-the-raspberry-pi/overview

MatrixLED.jpg

Another more versatile output from the 8x8 matrix is by using C program. See Mark Williams blog.

I also create a version of launching LED using R. See http://www.youtube.com/watch?v=TwoWrPp6_iw.

IR Remote with XBMC

http://learn.adafruit.com/using-an-ir-remote-with-a-raspberry-pi-media-center

Stepper motor

http://www.raspberrypi-spy.co.uk/2012/07/stepper-motor-control-in-python/

HummingBird robot

http://www.hummingbirdkit.com/learning/tutorials/raspberry-pi

Power Raspberry Pi by AA batteries

http://www.raspberrypi-spy.co.uk/2013/04/raspberry-pi-aa-battery-shoot-out/

This also teaches to know how long the battery will die by using Putty and linux command

watch -n 60 uptime

Other cool stuff

Wii Remote, bluetooth

http://www.raspberrypi-spy.co.uk/2013/02/nintendo-wii-remote-python-and-the-raspberry-pi/

Interfacing with a Wiimote

http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/wiimote/

Robot control

http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/robot_control/