Monday, January 21, 2013

Raspberry Pi Sending SMS Using Python


I connect my USB modem huawei E226 modem that working with  Raspberry Pi, and not all usb modem compatible with linux you must use usb modem that compatible to pi , and i am using ArchLinux

use lsusb and dmesg to know your modem working , install python in this case i use python2, because python3 not compatible for many application

your usb modem will installed at /dev/ttyUSB0



install python2 python2-serial
pacman -S python2 pyhton2-serial

because default python in arch linux is python3 you must make link to make python2 is default

ln /usr/bin/python2 /usr/bin/python


now you can sending sms using python script






Friday, January 18, 2013

Raspberry Pi and Usb Sound Card



I Have Usb Sound Card that uses cmedia chipset and im uses wheezy raspbian image, its not work properly, then im switch to Arch linux and my usb sound card work flawlessly :)

here s step :

Plug your usb sound card to raspberry pi then ,  check USB Sound card recognized by linux

dmesg

[ 1893.885590] usb 1-1.2: new full-speed USB device number 5 using dwc_otg
[ 1893.987344] usb 1-1.2: New USB device found, idVendor=0d8c, idProduct=000c
[ 1893.987380] usb 1-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 1893.987398] usb 1-1.2: Product: C-Media USB Headphone Set
[ 1894.029804] input: C-Media USB Headphone Set   as /devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2:1.3/input/input1
[ 1894.030729] hid-generic 0003:0D8C:000C.0001: input,hidraw0: USB HID v1.00 Device [C-Media USB Headphone Set  ] on usb-bcm2708_usb-1.2/input3


or

lsusb

Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 005: ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter
Bus 001 Device 004: ID 05a9:4519 OmniVision Technologies, Inc. Webcam Classic


then install alsa-utils alsa-firmware alsa-plugins
pacman -S alsa-utils alsa-firmware alsa-plugins




after install, then reboot raspberry pi

reboot

wait until system is up

then check the snd_usb_audio loaded by linux

lsmod

Module                  Size  Used by
ipv6                  297427  10
spidev                  5232  0
leds_gpio               2275  0
led_class               3586  1 leds_gpio
spi_bcm2708             4522  0
i2c_bcm2708             3759  0
snd_usb_audio         104017  0
snd_usbmidi_lib        18131  1 snd_usb_audio
snd_hwdep               5941  1 snd_usb_audio
snd_rawmidi            21144  1 snd_usbmidi_lib
gspca_ov519            32216  0
snd_seq_device          6466  1 snd_rawmidi
snd_pcm                77452  1 snd_usb_audio
gspca_main             20149  1 gspca_ov519
videodev              105941  2 gspca_main,gspca_ov519
snd_page_alloc          5177  1 snd_pcm
evdev                   9370  0
media                  13412  1 videodev
snd_timer              19790  1 snd_pcm
snd                    58415  7 snd_usb_audio,snd_hwdep,snd_timer,snd_pcm,snd_rawmidi,snd_usbmidi_lib,snd_seq_device

 


Its ok now , usb sound card ready to use, run alsamixer

alsamixer

set the speaker volume , mic and make sure that speaker not muted, test configuration using

speaker-test

speaker-test 1.0.26

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 2048 to 16384
Period size range from 1024 to 1024
Using max buffer size 16384
Periods = 4
was set period_size = 1024
was set buffer_size = 16384
 0 - Front Left
Time per period = 2.654825
 0 - Front Left


it will make  pink noise sound at your speaker

test recording your voice , plug headset at usb sound card


 arecord -d 10 test.wav


then playback again

 aplay test.wav

you will hear your recorded sound, sucess

have nice try, good luck











Raspberry Pi and USB Web Camera + Motion



I Have old usb web camera and i try to plug at my raspberry usb port, to know webcam detected and recongnized by linux then give a command :

dmesg

[   99.186841] usb 1-1.3: Product: USB Camera
[   99.186857] usb 1-1.3: Manufacturer: OmniVision Technologies, Inc.
[   99.602403] input: ov519 as /devices/platform/bcm2708_usb/usb1/1-1/1-1.3/input/input0
[   99.611564] usbcore: registered new interface driver ov519
[   99.762003] usbcore: registered new interface driver snd-usb-audio


or

lsusb

Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 05a9:4519 OmniVision Technologies, Inc. Webcam Classic



you will find that devices detected or not, my old webcam work with raspberry pi ....:)), its nice

then i try to stream to network with motion

pacman -S motion

check usb web cam frame size and pixel format  using

v4l2-ctl --list-formats-ext

 ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'JPEG' (compressed)
        Name        : JPEG
                Size: Discrete 320x240
                Size: Discrete 640x480



then edit motion configuration file

nano /etc/motion/motion.conf

set :


# V4L2_PIX_FMT_MJPEG   : 2  'MJPEG'
# V4L2_PIX_FMT_JPEG    : 3  'JPEG'
# V4L2_PIX_FMT_RGB24   : 4  'RGB3'
# V4L2_PIX_FMT_UYVY    : 5  'UYVY'
# V4L2_PIX_FMT_YUYV    : 6  'YUYV'
# V4L2_PIX_FMT_YUV422P : 7  '422P'
# V4L2_PIX_FMT_YUV420  : 8  'YU12'
 

v4l2_palette 3 # use pixel format according result from test above 
webcam_localhost off # to acess from outside

Start Motion

motion -n

acess from our PC with adress  http://[ipadressofdevices]:8081 using firefox, acess using internet explorer not working