Raspberry: Difference between revisions

From 太極
Jump to navigation Jump to search
Line 578: Line 578:
* https://github.com/discoverycode/discoverybot_api The Discovery Bot
* https://github.com/discoverycode/discoverybot_api The Discovery Bot


The battery it includes is [http://www.amazon.com/Nokia-BL-5C-Extended-Li-Ion-Battery/dp/B0006HP7NC/ref=sr_1_1?ie=UTF8&qid=1439255229&sr=8-1&keywords=nokia+battery+bl+5c Nokia BL-5C] 1020mAh 3.7V 3.8Wh ~ $5.35 US.
The battery it includes is [http://www.amazon.com/Nokia-BL-5C-Extended-Li-Ion-Battery/dp/B0006HP7NC/ref=sr_1_1?ie=UTF8&qid=1439255229&sr=8-1&keywords=nokia+battery+bl+5c Nokia BL-5C] 1020mAh 3.7V 3.8Wh ~ $5.35 US. Note that the battery has 3 pins. One of them labelled as T is for [http://electronics.stackexchange.com/questions/10588/why-are-there-3-pins-on-some-batteries temperature].


== Ryanteck Budget Robotics Kit ==
== Ryanteck Budget Robotics Kit ==

Revision as of 21:15, 10 August 2015

Raspberry Pi

Miscellaneous

# /etc/network/interfaces  file
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
allow-hotplug wlan0
  wpa-ssid "YOURSSID"
  wpa-psk "YOURPASSWORD

Different generations

Displayport connection

Does not work if I use a hdmi to displayport converter. In general, 'step up' is not working but 'step down' is OK. See discussion.

Under voltage

he red LED going out is an indicator that the supply voltage is too low. You should also see a small coloured square in the top corner of the screen. See the posts

Install minimal browser

http://c-mobberley.com/wordpress/index.php/2013/04/30/raspberry-pi-best-fastest-web-browser-for-gui-usage/

Note that at the end of sudo make install, it will create an item in the menu -> Internet. From the installation output,

sudo install -g dialout web /usr/bin
sudo install -g audio piradio /usr/local/bin
sudo chmod +x /usr/local/bin/piradio
sudo cp ./web.desktop /usr/share/applications
sudo cp ./minimalwebbrowser.png /usr/share/pixmaps
sudo cp ./web.1.gz /usr/share/man/man1
sudo cp ./web-omxplayer.sh /usr/local/bin
sudo chmod +x /usr/local/bin/web-omxplayer.sh

Assign .local domain to Raspberry Pi

Avahi Daemon = Bonjour = Zeroconf = UDP multicast

http://www.howtogeek.com/167190/how-and-why-to-assign-the-.local-domain-to-your-raspberry-pi/

So I can use ssh [email protected] to access RPi.

sudo apt-get update
sudo apt-get install avahi-daemon
# No reboot is necessary for raspberry pi

# from other machines or even Raspi itself
ping raspberrypi.local

The idea was first discovered in Beaglebone.

HDMI screen resolution

If the screen size is small (i.e. you can see black margins on 4 sides), uncomment the line about disable_overscan=1.

# sudo nano /boot/config.txt
disable_overscan=1

HDMI monitor

RCA video output resolution

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=47527

Memory

When I use 'free -m' or 'htop' command in Raspbian, I see the total memory size only 373MB (Beaglebone black shows 496MB in htop). The reason is Raspbian reserved 128MB for GPU. See

cat /boot/config.txt

Watch youtube with Raspbian

Probably a practical approach is to use 'youtube-dl' program to download the video and then use 'omxplayer' to play it (not streaming anyway).

Startup script

sudo nano /etc/init.d/NameOfYourScript # Create script in /etc/init.d

sudo chmod 755 /etc/init.d/NameOfYourScript # Make script executable

sudo /etc/init.d/NameOfYourScript start # Test starting the program

sudo /etc/init.d/NameOfYourScript stop # Test stopping the program

# Register your script to be run at start-up and shutdown, run the following command:
sudo update-rc.d NameOfYourScript defaults

# If you ever want to remove the script from start-up, run the following command:
sudo update-rc.d -f  NameOfYourScript remove

Benchmark

Installation

Make sure to use a class 10 (micro)SD card to avoid a hanging problem. This rule applies to other SoC device like Beaglebone and Udoo.

Download an image

The best way of using Raspberry Pi is being able to run multiboot; that is, we have a list of operating systems we can choose to boot.

  • NOOBS
  • BerryBoot (just a simple operating system installer, the camera cannot be enabled. The multiple choices of OSs in BerryBoot is now available in NOOBS)

Format a SD card using SD Formatter (Windows & Mac)

Install an image to a SD card

For example, if I want to install coder, I first download/uncompress the file. Then from the linux command line (assume microSD card is on /dev/sdc)

sudo umount /dev/sdc*
sudo dd bs=4M if=Downloads/coder_v0.4/raspi.img of=/dev/sdc
sudo sync

If I want to watch the progress, I can open another terminal and issue

sudo pkill -USR1 -n -x dd

Monitor the progress using pipe viewer

sudo apt-get install pv
dd if=/dev/urandom | pv | dd of=/dev/null

Remote desktop

Connection to Raspberry Pi with tightvnc

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


A simple password like 'raspberry' would work. If we need to reset the password, use vncpasswd command.

# Server side
sudo apt-get install tightvncserver
tightvncserver
# You will require a password to access your desktops.
# Password: 
# Warning: password truncated to the length of 8.
# Verify:   
# Would you like to enter a view-only password (y/n)? n
#
# New 'X' desktop is raspberrypi:1
#
# Creating default startup script /home/pi/.vnc/xstartup
# Starting applications specified in /home/pi/.vnc/xstartup
# Log file is /home/pi/.vnc/raspberrypi:1.log
ps -ef | grep tightvnc
# pi        3134     1  0 16:59 pts/0    00:00:00 Xtightvnc :1 -desktop X -auth /home/pi/.Xauthority 
# -geometry 1024x768 -depth 24 -rfbwait 120000 -rfbauth /home/pi/.vnc/passwd -rfbport 5901 -fp 
# /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X# 11/100dpi/ -co /etc/X11/rgb
# pi        3217  2666  0 17:01 pts/0    00:00:00 grep --color=auto tightvnc

vncserver             # This line seems not necessary
vncserver –kill :1

# Client side; the most common mistake is to forget to add the port number to the IP address.
sudo apt-get install xtightvncviewer
xtightvncviewer 10.42.0.37:1
# It does not work if I just use raspberrypi.local:1 as the address

To start the tightvnc automatically when boot up, check out http://www.penguintutor.com/linux/tightvnc or my note on BBB.

Also note if the server uses '/usr/bin/vncserver :0', then the client uses 'xtightvncviewer 10.42.0.37'. But if the server uses '/usr/bin/vncserver :1', the client should uses 'xtightvncviewer 10.42.0.37:1', etc. Got the idea!

Note that to troubleshoot the message "GDBus Error:org freedesktop.PolicyKit1 Error.Failed; An Authentication agent already exixts for the given subject", follow the instruction at this message.

Connection from Raspberry Pi to Ubuntu

Follow the instruction and install xtightvncviewer using sudo apt-get and it works. To run the vnc client, just type 'xtightvncviewer' on the terminal.

Another instruction of using tightvnc is at http://www.penguintutor.com/linux/tightvnc.

I have successfully to follow the instruction at http://www.hiddentao.com/archives/2013/09/17/setting-up-tightvnc-on-ubuntu-12-04/ to connect to Ubuntu 12.04 (Unity desktop) from Xubuntu. After launching the following line in my local machine

ssh -L 5901:localhost:5901 [email protected]

I open another terminal window and type the following in my local machine

xtightvncviewer localhost:5901

the Ubuntu desktop appears on my local machine.

Connection from Raspberry Pi to Windows (RDP) with freerdp or rdesktop

The idea is to use Raspberry Pi as a thin client. For example, I can open two remote desktop connections to two separate Windows VMs and the RPi is still quite free in terms of its resource.

http://blog.pi3g.com/2013/04/use-windows-remote-desktop-on-the-raspberry-pi/

Method 1 Use xfreerdp program. Use Ctrl+Alt+Enter to toggle between full and regular screen. Non-full-screen-mode is useful if we want to monitor the RPi resource usage while we are using the remote desktop connection.

1. Open a root terminal. Run
apt-get update
apt-get install freerdp
2. Open a regular terminal. Run
xfreerdp -u brb -x l -z 192.168.1.4

Method 2 We can also use rdesktop program. rdesktop is a free, open source client for Microsoft's proprietary RDP protocol. See wiki.archlinux.org for more tips and tricks about rdesktop.

1. Open a root terminal and run
apt-get update
apt-get install rdesktop
2. Open a regular terminal and run (-f means full screen. Or we can use -g 1280x700 to specify the display resolution)
rdesktop -f -u brb 192.168.1.4

Method 3 There is also an interesting project called RPi-TC/Raspberry Pi Thin Client project. I have not tried it yet.

Raspbian

Raspbian package repository URL

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

Create a custom kernel using Vagrant

Emulate Raspbian on Linux/Windows

Iceweasel browser

I cannot even open the https://ubuntu-mate.org/raspberry-pi/ website using Iceweasel (3.8.2). It returns Oops! It was not possible to show this website. The website at https://ubuntu-mate.org/raspberry-pi/ seems to be unavailable. The precise error was: SSL handshake failed.

I can open the website perfectly on my Nexus 9 Chrome.

Also the feedly.com does not work. Too bad!!!

Firefox browser

$ sudo apt-get install firefox
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package firefox is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'firefox' has no installation candidate

OpenElec

I use NOOBS to install OpenElec with Raspbian.

Still there is no a regular web browser. Not a joke. Remember OpenElec is installed in multiboot mode through NOOBS. Probably a better approach is to consider Arch-Linux.

There is a program called 'Web viewer'. Wonder when would it be useful.

Need to change 2 settings in order to get date & time correctly.

SMS server

Arch Linux

Kodi can be installed in ArchLinux by installing the kodi-rbp package. See wiki.archlinux.org.

Kodi

  • Install Kodi on Raspbian
  • For some reason, I did not find 'Display Mode' option in the System > Settings > System > Video Output in the OpenElec. When I install Kodi (14.2 Mar 27 2015) in Ubuntu 14.04, I can see this option.

LXDE (same as Lubuntu) X11 desktop environment used by Raspbian OS

Inside .config/lxpanel is a directory with the name of your current lxsession profile - and inside this is a further subdirectory called panels.Each file in this directory is the definition of a single panel. See Magpi33.pdf.

Screenshots

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 

We can use the same procedure to add Midori to the quick launch bar.

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.

Clustering

with 2 Pis

This Linux Journal article teaches how to run GlusterFS Server on two Raspberry Pis. This is also called redundant filesystem. So if one Pi is down, the other keeps the system up.

Hadoop

Qt on Raspberry Pi

Check out https://qt-project.org/wiki/Qt-RaspberryPi

Native build Qt

http://qt-project.org/wiki/Native_Build_of_Qt5_on_a_Raspberry_Pi

Qt-Creator

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=31&t=43545

Raspberry Pi 2

Raspberry Pi 2 (Armv7 with quad core cpu and 1GB RAM) brings its hardware to the minimum requirements for several interesting projects. I got one from my local microcenter store ($35 + tax).

One interesting thing is the Raspbian or Docker supports Raspberry Pi 1 and 2 (different ARM architectures).

Ubuntu Snappy

Some more information about ubuntu snappy (username/password is ubuntu/ubuntu):

Suppose I connect my Raspberry Pi 2 get its internet through my computer's USB-ethernet adapter. Then once RPi 2 is on, I can open my browser on my host PC and go to http://webdm.local:4200/. It shows

SnappyRaspPi.png

Note that the SNAPPY UBUNTU CORE image for RPi seems buggy. For example,

ubuntu@localhost:~$ sudo su
root@localhost:/home/ubuntu# dpkg-reconfigure tzdata
cp: cannot create regular file '/etc/localtime.dpkg-new': Read-only file system

Current default time zone: 'America/New_York'
Local time is now:      Thu Jan  1 01:01:42 UTC 1970.
Universal Time is now:  Thu Jan  1 01:01:42 UTC 1970.

debconf: DbDriver "config": could not write /var/cache/debconf/config.dat-new: Read-only file system

root@localhost:/home/ubuntu# snappy info
release: ubuntu-core/devel
frameworks: webdm
apps: 
root@localhost:/home/ubuntu# snappy versions
Traceback (most recent call last):
  File "/usr/bin/snappy", line 25, in <module>
    status = Main().__main__()
  File "/usr/lib/python3/dist-packages/snappy/main.py", line 195, in __main__
    return callback(args)
  File "/usr/lib/python3/dist-packages/snappy/main.py", line 334, in _do_versions
    click_versions = ClickDataSource().versions(all)
  File "/usr/lib/python3/dist-packages/snappy/click.py", line 189, in versions
    all_updates_list = repo.get_upgradable()
  File "/usr/lib/python3/dist-packages/click/repository.py", line 183, in get_upgradable
    headers={"content-type": "application/json"})
  File "/usr/lib/python3/dist-packages/click/network.py", line 70, in http_request
    curl.perform()
pycurl.error: (60, 'server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none')

Docker

http://blog.hypriot.com/heavily-armed-after-major-upgrade-raspberry-pi-with-docker-1-dot-5-0

GPIO experiments

Connect to console using TTL/Serial cable

I purchased the TTL cable through dealextream.com. The RaspPi is power by the microUSB (Or we can use the 5V pin on TTL module to connect to 5V on RaspPi. If I try to use 3.3V pin on TTL module to connect to either 3.3V or 5V on RaspPi, it does not work). The connection is done by

   RaspPi    TTL
   =========
   5V          5V
   GND       GND
   TX (14)   RX
   RX (15)   TX

Note that it takes 45 seconds for the screen to respond when I tested it using Putty. The ACT and PWR lights should be on. The tuturial on adafruit is helpful.

Ftdi2ttlRaspPi.png

C libraries

GPIO layout

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

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

The following cheatsheet was taken from http://raspi.tv/wp-content/uploads/2013/04/raspberry-pi-gpio-cheat-sheet.jpg

Raspberry-pi-gpio-cheat-sheet.jpg

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 (I2C)

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

Kodi/XBMC

The USTV VoD and Navi-X work well. Just download the zip files in the linux and install them from xbmc -> system -> add ons -> install from local zip files.

Stepper motor

Tiddlybot

The battery it includes is Nokia BL-5C 1020mAh 3.7V 3.8Wh ~ $5.35 US. Note that the battery has 3 pins. One of them labelled as T is for temperature.

Ryanteck Budget Robotics Kit

https://www.indiegogo.com/projects/ryanteck-budget-robotics-kit-for-raspberry-pi

The software control is based on Spacebrew

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

Power Raspberry Pi by Lipo batteries

Add a push button

Use a Simple Button to Control LED

http://raspi.tv/2013/rpi-gpio-basics-6-using-inputs-and-outputs-together-with-rpi-gpio-pull-ups-and-pull-downs

The following site has some elaboration about 'pull down' of resistors. http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/buttons_and_switches/

Using a servo motor, PWM

http://learn.adafruit.com/adafruits-raspberry-pi-lesson-8-using-a-servo-motor?view=all

LED dimming using software PWM (pulse-width modulation)

http://raspi.tv/2013/how-to-use-soft-pwm-in-rpi-gpio-pt-2-led-dimming-and-motor-speed-control

Reading analog input using external ADC (analog to digital converter) MCP3008

http://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi/overview

MCP23017 GPIO expander (extra 16 pins)

Serial Peripheral interface (SPI)

http://www.brianhensley.net/2012/07/getting-spi-working-on-raspberry-pi.html

Camera

raspivid -o myvid.h264 -t 60000   
# 60 seconds. Default is 6 seconds which generates 10MB for 1080p, 6.4MB for 720p.
raspivid -o myvid.h264 -w 1280 -h 720   # 1280 x 720 instead of 1920 x 1080
raspivid -o myvid.h264 -w 1280 -h 720 -rot 180 # rotation 180 degree
raspivid -o myvid.h264 -w 1280 -h 720 -b 8000000  
# “8000000” is a bitrate of 8000Kbs (kilo bits per second) or 8Mb (8 mega bits per second). 
# The default is usually 17000000.

# convert h264 to mp4
sudo apt-get install -y gpac
MP4Box -fps 30 -add myvid.h264 myvid.mp4

# play the video
omxplayer myvid.h264
omxplayer myvid.mp4
sudo usermod -a -G motion pi
sudo chown motion:motion /home/pi/images
sudo service motion start

To rotate the image, change 'rotate 0' to 'rotate 180' by sudo nano /etc/motion.conf (still not right).

Dash Cam

Live streaming

Live streaming and a slightly updated one using MJPG-streamer which I have tested and it works (Jan 25, 2015). At the end, we only need to run ./start_stream.sh script to start it and then I can view the live stream by opening http://raspberrypi.local:9000/stream.html using chrome browser.

A better way to start the script is to integrate it in the boot-up. Combing both the start and stop scripts, we can create a script and save it under /etc/init.d directory. The combined script /etc/init.d/camera_stream.sh is shown below:

#! /bin/sh
# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    if pgrep mjpg_streamer > /dev/null
    then
      echo "mjpg_streamer already running"
    else
      LD_LIBRARY_PATH=/opt/mjpg-streamer/ /opt/mjpg-streamer/mjpg_streamer -i \
           "input_raspicam.so -fps 15 -q 50 -x 640 -y 480" -o \
           "output_http.so -p 9000 -w /opt/mjpg-streamer/www" > /dev/null 2>&1&
      echo "mjpg_streamer started"
    fi
    ;;
  stop)
    if pgrep mjpg_streamer
    then
      kill $(pgrep mjpg_streamer) > /dev/null 2>&1
      echo "mjpg_streamer stopped"
    else
      echo "mjpg_streamer not running"
    fi
    ;;
  *)
    echo "Usage: /etc/init.d/camera_stream {start|stop}"
    exit 1
    ;;
esac

exit 0

Note that the following warning does not affect the streaming:

$ sudo update-rc.d camera_stream.sh defaults
update-rc.d: using dependency based boot sequencing
insserv: warning: script 'camera_stream.sh' missing LSB tags and overrides

Security Camera

Slow motion

http://www.averagemanvsraspberrypi.com/2015/07/raspberry-pi-camera-module-slow-motion-video.html

ESP8266

Connect an ESP8266 to your RaspberryPi

Other cool stuff

Dashboard/Kiosk by dashing.io

Go to space

OpenCV

Wii Remote, bluetooth

Interfacing with a Wiimote

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

Robot control

Compile R from source

Tested on R 3.0.1

  • cd R-3.0.1
  • ./configure --with-recommended-packages=no
  • sudo apt-get install openjdk-7-jdk
  • nano src/library/tools/R/install.R and pass "perl = TRUE" to sub()
SHLIB_EXT <- sub(".*= ", "", grep("^SHLIB_EXT", mconf, value = TRUE), perl = TRUE)
SHLIB_LIBADD <- sub(".*= ", "", grep("^SHLIB_LIBADD", mconf, value = TRUE), perl = TRUE)

to get rid of the error gcc: error: SHLIB_LIBADD: No such file or directory.

  • make

Google Coder

PS. Code is based on node.js (shiny-server also depends on node.js).

http://pi.gadgetoid.com teaches us how to install Coder on a Raspberry Pi running on Raspbian. Note that Coder can turn Raspberry Pi into a web server. We can develop the code on a remote computer.

In fact, it is possible to run Code for Raspberry Pi on your own PC. Just run 7 lines of script at here. Note: My experience shows it is safe to use the version on Sep-17-2013; otherwise you'll get the following error when using 'nodejs server.js'

$ nodejs server.js
no certificate found. generating self signed cert.

module.js:337
    throw new Error("Cannot find module '" + request + "'");
          ^
Error: Cannot find module '/home/pi/coder/coder-base/apps/auth/app'

So the successful steps to install coder on Ubuntu is

  1. download zip file from Sep-17-2013 tree
  2. cd coder-base; npm install
  3. modify 'config.js'
  4. launch it by 'node server.js'.

I don't have to use sudo when I use 'npm install' and 'node server.js'.

The password requirement for coder is at least 6 characters, at least one lower case and at least 2 upper cases or numbers.

Also, on Ubuntu it will complain the user 'pi' does not exist. So we shall do this 'sudo adduser pi' too. Pick the same password as we use in coder (eg Raspberry99).

Update: After I played with it, I found Coder does not let us work on more than one HTML, CSS or Javscript file. This makes the development more difficult.

Another choice is to run Cloud9 IDE on RPi. The Cloud 9 IDE was preinstalled on Beaglebone black/

Wolframe Mathematica

For some reason, the Mathematica is not shown on the menu (it only happened on self-installed version). We can start Mathematica from the command line

/usr/bin/mathematica

We can try a 3D plot like seen in youtube

Plot3D[Sin[x*y], {x,0,Pi}, {y,0,Pi}]

The following screenshot shows how to calculate the derivative of f(x)=sin(x)*exp(2x) using Wolfram.

  • Note that the language is case-sensitive. For example, sin[x] is not recognized and it should be Sin[x].
  • Wolfram language uses square brackets instead of parentheses for function's arguments.
  • See this page for Wolfram language & system documentation.
  • Another way is to type D[Sin[x] * Exp[2x], x]

WolframPi.png

Note that Mathematica is a GUI program so it is kind of slow when it is running on Raspberry Pi. The Wolfram program is a command line interface program so it is much faster although we can not do any plotting there.

Use RaspPi as Media Center

http://www.packtpub.com/raspberry-pi-media-center/book

Record TV

Bitcoin Miner

Turn Raspi into a hotspot / access point

Midi keyboard

Bike computer

https://www.raspberrypi.org/blog/bike-computer-for-the-myopic/ This build uses the Kindle as a display