Showing posts with label raspberry pi. Show all posts
Showing posts with label raspberry pi. Show all posts

Wednesday, 16 July 2014

mmal: mmal_vc_component_enable: failed to enable component: ENOSPC

This is a nasty bug with the Raspberry Pi camera module, which has not been resolved. Although I cannot guarantee that my solution will work for you, it fortunately did the trick for me.
  1. sudo apt-get update && sudo apt-get dist-upgrade  
  2. sudo rpi-update  

Make sure your  /etc/modprobe.d/raspi-blacklist.conf looks like this.


  1. sudo nano /etc/modprobe.d/raspi-blacklist.conf  
# blacklist spi and i2c by default (many users don't need them)

#blacklist spi-bcm2708
blacklist i2c-bcm2708

My /etc/modules config

  1. sudo nano /etc/modules

 # /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.


w1-gpio pullup=1
w1-therm
i2c-bcm2708
i2c-dev
spi-bcm2708
snd-bcm2835
lirc_dev
lirc_rpi gpio_out_pin=7

Test

  1. sudo reboot  
  2. raspistill -v -o image.jpg  

Sample output

raspistill Camera App v1.3.8

Width 2592, Height 1944, quality 85, filename image.jpg
Time delay 5000, Raw no
Thumbnail enabled Yes, width 64, height 48, quality 35
Link to latest frame enabled  no
Full resolution preview No
Capture method : Single capture

Preview Yes, Full screen Yes
Preview window 0,0,1024,768
Opacity 255
Sharpness 0, Contrast 0, Brightness 50
Saturation 0, ISO 0, Video Stabilisation No, Exposure compensation 0
Exposure Mode 'auto', AWB Mode 'auto', Image Effect 'none'
Metering Mode 'average', Colour Effect Enabled No with U = 128, V = 128
Rotation 0, hflip No, vflip No
ROI x 0.000000, y 0.000000, w 1.000000 h 1.000000
Camera component done
Encoder component done
Starting component connection stage
Connecting camera preview port to video render.
Connecting camera stills port to encoder input port
Opening output file image.jpg
Enabling encoder output port
Starting capture 0
Finished capture 0
Closing down
Close down completed, all components disconnected, disabled and destroyed

Raspberry Pi As A Radio Transmitter

GPIO Raspberry PiFirst thing you have to do is attach a jumper wire to GPIO 4. That's it for the hardware part.

The Software

The Code that does the job is called Pifm by icrobotics.co.uk .
  1. wget www.icrobotics.co.uk/wiki/images/c/c3/Pifm.tar.gz  
  2. tar -xvf Pifm.tar.gz  

Start Broadcasting

  1. sudo ./pifm sound.wav 100.5  
- sound.wav - the audio file which you would like to broadcast. only .wav will work.
- 100.5 - the FM frequency. usually between 87.5 and 108.0 MHz.

Monday, 16 June 2014

Automatically Check The Raspberry Pi's Temperature (+Prevent Overheating)

No need to install anything. Just open a terminal and execute the following command to get the temperature of your RasPi.
/opt/vc/bin/vcgencmd measure_temp

Automate the process

The below script will automatically reboot your Raspberry Pi should it reach a specified threshold (maxtemp). First of all make sure you can reboot/shutdown your raspi without linux asking you for a password. 

user@user:~$ sudo visudo
Add the following to the sudoers file. 
user ALL=NOPASSWD: /sbin/shutdown

The script

Save as temp.sh. Maxtemp specifies the temperature cut-off point, at which the Raspi will reboot. 
#!/bin/bash  
#title           :temp.sh  
#description     :Checks Temperature of Raspberry Pi and reboots at maxtemp.  
#author          :Mike M | www.linuxx.eu  
#notes           :Add "user ALL=NOPASSWD: /sbin/shutdown" to sudoers file   
  
temp=`/opt/vc/bin/vcgencmd measure_temp | cut -c 6-7`  
maxtemp=75  
if [ $temp -ge $maxtemp ]; then  
xmessage  "Alert! Temp above 75. System rebooting in 3 minutes"  
sudo /sbin/shutdown -r +3  
elif [ $temp -lt $maxtemp ]; then  
exit 0  
fi

Create a cronjob

user@user:~$ sudo crontab

Add the following

PATH=/usr/sbin:/usr/bin:/sbin:/bin
*/5 * * * * sh /home/user/temp.sh
This will run the temp.sh script every 5 minutes and make sure that the Raspberry Pi does not overheat.

Saturday, 14 June 2014

Streaming Video From Your Raspberry Pi Camera Module with VLC

If you want to build a surveillance cam you might want to have a look at motion, but for simple video streaming I 'd go for vlc.

Enable Camera Module

sudo raspi-config

Install VLC Media Player

sudo apt-get install vlc

Stream (RTSP)

 raspivid -o - -t 0 -n -w 800 -h 600 -fps 20 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264

- w: width
- h: heigt
- fps: frames per second

Viewing The RTSP Stream 

You need a video player capable of RTSP (e.g. VLC). Open a network stream:

rtsp://###.###.###.###:8554/

###.###.###.### is the IP address of your raspberry pi. Also, do not forget the '/'  at the end, otherwise it won't work.

Streaming Over HTTP

 raspivid -o - -t 0 -n -w 800 -h 600 -fps 20 | cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8554}' :demux=h264


Streaming Video From Your Rasperry Pi Camera Module with VLC
Camera Module

Sunday, 8 June 2014

How to Setup Wi-Fi On Your Raspberry Pi via the Command Line

Configure Your AP Details

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Make sure the file reads like this

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

network={
    ssid="SSID"
    proto=RSN
    key_mgmt=WPA-PSK
    pairwise=CCMP TKIP
    group=CCMP TKIP
    psk="yourkey"
}

Configuring the interface

 sudo nano /etc/network/interfaces

Add the following

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

sudo ifconfig wlan0 down
sudo ifconfig wlan0 up

Reboot. Done.

Configure WPA2 On Raspberry Pi
Model B