Showing posts with label Raspberry Pi. Show all posts
Showing posts with label Raspberry Pi. Show all posts

Monday, January 05, 2015

Huawei USB dongle


I always forget the colour of the indication light on 3G dongles, to know when its connected, and the signal strenght. Hopefully this will help:


http://mybroadband.co.za/vb/showthread.php/526134-Balance-checking-of-MTN-prepaid-SIM-in-remote-device

http://bigcowpi.blogspot.com/2013/03/pi-3g-router-query-signal-quality-and.html

Green, blinking twice every 3sThe USB Stick is powered on.
Green, blinking once every 3sThe USB Stick is registering with a 2G network
Blue, blinking once every 3sThe USB Stick is registering with a 3G/3G+ network
Green, solidThe USB Stick is connected to a 2G network.
Blue, solidThe USB Stick is connected to a 3G network
Cyan, solidThe USB Stick is connected to a 3G+ network.

Pi: detailed setup


Some notes I took when I setup the Pi. I have since Imaged the SD card, so I wont have to go through this again


General


  1. sudo raspi-config
    1. Change hostname
    2. Change user pi password
    3. Change timezone

Setup darkice

  1. sudo apt-get install lame libtwolame0 - to install lame required to have mp3 support
  2. install darkice binary package already compiled for mp3 supprt
  3. sudo cp /usr/share/doc/darkice/examples/darkice.cfg /etc/ - to configure darkice
  4. edit crontab for time script
  5. add record and stream scripts to rc.local for starting up at boot

Setup USB sound card

  1. modify alsa-base to make USB sound card the first (0) device
  2. reboot
  3. check that sound card is picked up correctly. Run following commands:
  4. cat /proc/asound/cards
  5. amixer 
  6. arecord -l
  7. aplay -l
  8.  Set sound levels: alsamixer 
  9. arecord -f S16_LE -D hw:0,0 -r 48000 test.wav
  10. aplay test.wav

Create seperate FAT32 extension - this useful to store recordings on a seperate partition to prevent / from overfilling, and to make it FAT32 so that it can be mounted in a Windows machine

  1. sudo apt-get install dosfstools
  2. sudo cfdisk /dev/mmcblk0 - Using the keyboard create a new primary partition in the free space, and change the type to FAT32 which is option 0B (W95 FAT32). Select Write to save the changes, then select Quit.
  3. reboot
  4. sudo cfdisk /dev/mmcblk0p3
  5. sudo mkfs.msdos /dev/mmcblk0p3

Setup 3G USB dongle

  1. sudo apt-get install sg3-utils
  2. sudo /usr/bin/sg_raw /dev/sr0 11 06 20 00 00 00 00 00 01 00
  3. echo 'SUBSYSTEMS=="usb", ATTRS{modalias}=="usb:v12D1p1F01*", SYMLINK+="hwcdrom", RUN+="/usr/bin/sg_raw /dev/hwcdrom 11 06 20 00 00 00 00 00 01 00"' > /etc/udev/rules.d/10-HuaweiFlashCard.rules
  4. modify /etc/network/interfaces

Reverse SSH tunnel
  1. ssh-keygen -t rsa
  2. copy key to server
  3. insert ssh reverse command to /etc/rc.local
syslog


webmin




Pi: USB sound card nightmare


As a follow on to the previous post about the raspberry Pi

I bought two USB sound cards from Matrix Warehouse. They were these two C-Media based chipsets:

7.1: http://www.amazon.com/Channel-External-Sound-Audio-Adapter/dp/B007HISGRW/ref=sr_1_3?ie=UTF8&qid=1382967519&sr=8-3&keywords=usb+sound+card
5.1: http://www.amazon.com/Virtual-5-1-surround-External-Sound-Card/dp/B000N35A0Y/ref=pd_bxgy_pc_img_y

The 7.1 was only giving static. It turns out that the mic I was using was broken, but I learned quite abit about Linux sound tool sets.

These posts were very helpfull:
http://computers.tutsplus.com/articles/using-a-usb-audio-device-with-a-raspberry-pi--mac-55876
http://www.raspberrypi.org/forums/viewtopic.php?p=314611#p314611
http://www.linuxcircle.com/2013/05/08/raspberry-pi-microphone-setup-with-usb-sound-card/

the 7.1

dmesg:
    3.303196] usb 1-1.5: new full-speed USB device number 4 using dwc_otg
[    3.434770] usb 1-1.5: New USB device found, idVendor=0d8c, idProduct=013c
[    3.449598] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    3.473047] usb 1-1.5: Product: USB PnP Sound Device
[    3.479635] usb 1-1.5: Manufacturer: C-Media Electronics Inc.      
[    3.513315] input: C-Media Electronics Inc.       USB PnP Sound Device as /devices/platform/bcm2708_usb/usb1/1-1/1-1.5/1-1.5:1.3/input/input0
[    3.551191] hid-generic 0003:0D8C:013C.0001: input,hidraw0: USB HID v1.00 Device [C-Media Electronics Inc.       USB PnP Sound Device] on usb-bcm2708_usb-1.5/input3
[    3.997860] udevd[156]: starting version 175
[    6.413474] bcm2708-i2s bcm2708-i2s.0: Failed to create debugfs directory

[    6.848620] usbcore: registered new interface driver snd-usb-audio

pi@pi-roshnee-lm ~/recordings $ cat /proc/asound/cards 
 0 [Device         ]: USB-Audio - USB PnP Sound Device
                      C-Media Electronics Inc. USB PnP Sound Device at usb-bcm2708_usb-1.5, full spee
 1 [ALSA           ]: bcm2835 - bcm2835 ALSA
                      bcm2835 ALSA
pi@pi-roshnee-lm ~/recordings $ lsusb 
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. 
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 0d8c:013c C-Media Electronics, Inc. CM108 Audio Controller

pi@pi-roshnee-lm ~/recordings $ amixer 
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch pswitch-joined penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 151
  Mono:
  Front Left: Playback 136 [90%] [-2.88dB] [on]
  Front Right: Playback 136 [90%] [-2.88dB] [on]
Simple mixer control 'Mic',0
  Capabilities: pvolume pvolume-joined cvolume cvolume-joined pswitch pswitch-joined cswitch cswitch-joined penum
  Playback channels: Mono
  Capture channels: Mono
  Limits: Playback 0 - 127 Capture 0 - 16
  Mono: Playback 98 [77%] [18.37dB] [off] Capture 14 [88%] [20.83dB] [on]
Simple mixer control 'Auto Gain Control',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [on]

pi@pi-roshnee-lm ~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

pi@pi-roshnee-lm ~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

pi@pi-roshnee-lm ~/pi_scripts $ arecord -f S16_LE -c1 -r44100 -t wav test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
^CAborted by signal Interrupt...
pi@pi-roshnee-lm ~/pi_scripts $ aplay test.wav 
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono


pi@pi-roshnee-lm ~/recordings $ arecord -D plughw:0 -r 48000 test.wav
Recording WAVE 'test.wav' : Unsigned 8 bit, Rate 48000 Hz, Mono
^CAborted by signal Interrupt...
pi@pi-roshnee-lm ~/recordings $ arecord -D plughw:0 -r 16000 test.wav
Recording WAVE 'test.wav' : Unsigned 8 bit, Rate 16000 Hz, Mono
^CAborted by signal Interrupt...
pi@pi-roshnee-lm ~/recordings $ arecord -f S16_LE -D plughw:0,0 -r 48000 test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
^CAborted by signal Interrupt...
pi@pi-roshnee-lm ~/recordings $ 


pi@pi-roshnee-lm ~/recordings $ cat /boot/cmdline.txt p. 
dwc_otg.lpm_enable=0 dwc_otg.speed=1 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
pi@pi-roshnee-lm ~/recordings $