Add USB audio (playback and mic) support to Raspberry Pi

https://learn.adafruit.com/usb-audio-cards-with-a-raspberry-pi/instructions

Plug in USB audio card and boot Pi

dmesg | grep cm109
dmesg | grep Headphone
dmesg | grep C-Media
dmesg | grep General
dmesg | grep Jabra (*)

On Raspbian Stretch:

sudo nano /usr/share/alsa/alsa.conf

  1. defaults.ctl.card 0
  2. defaults.pcm.card 0

change 0 to 1

Playback

speaker-test -c2
sudo apt-get unstall mpg123
mpg123 http://ice1.somafm.com/u80s-128-mp3

List audio devices

aplay -l

To force a specific device/sub-device use the command below

speaker-test -c2 -D plughw:1,0
aplay –device=hw:1,0 test.wav

alsamixer – c 1

Recording

arecord –device=hw:1,0 –format S16_LE –rate 44100 -c1 test.wav
aplay –device=hw:1,0 test.wav

I want to buy Raspberry Pi and parts in the UK

I do not endorse nor do I receive any benefits in cash or kind for click throughs. Use at your own risk

These companies supply project kits

Prepare an SDCard with Noobs for RaspberryPi

  • fdisk -l
  • insert card
  • fdisk -l
  • identity the device e.g. /dev/mmcblk0
  • fdisk /dev/mmcblk0
    • delete partitions (d)
    • list partitions (p)
    • create a partition (n)
    • change partions type (t)
      • use Hex code for fat32 is b
    • Make bootable (a)
    • write partition table (w)
  • format the partition
    • mkfs.vfat /dev/mmcblk0p1

download Noobs
sha256sum <filename>
unzip to partition created above

A very verbose and mega helpful guide can be found here

 

Nova Modem setup on Pi and using SMS capabilities

Activate hologram sim

Connect nova modem to pi

  • lsusb – should show modem detected as U-Blox device
  • miniterm.py – should show a number of u-blox tty devices
    • U-blox allows parallel execution of tasks.
  • Install the hologram library (wrapper over u-blox)
  • hologram modem -h
  • hologram modem type
  • hologram modem operator
  • hologram modem signal

Test cellular connectivity

  • ifconfig wlan0 down
    • bring down the wireless interface to ensure data is send over cellular
  • ping google.com
    • fails
  • hologram modem connect
  • ifconfig (should show ppp0)
  • ping google.com
    • succeeds
    • be cautious of data usage as connectivity is now over ppp over cellular
  • hologram modem disconnect
  • ifconfig wlan0 up

Test SMS

  • hologram send -h
  • hologram send –sms “message” –destination destination-number(use + format) –devicekey key
  • hologram receive –sms
    • waits for incoming messages

Using the hologram library

 

Backgrounding tasks in Linux with nohup and screen

Notes made while following along lecture in the course “Running Kali on Raspberry Pi” by Dr. Polstra on Pentest Academy

nohup

  • nohup –help (Run command, ignoring hangup signals. Basic command line direction)
  • nohup ls / -lR &
    • Runs the ls /-lR command in the background (&)
    • nohup ensures that output is written to nonhup.out and that command runs even if connection to terminal is lost
  • ls
  • logout (to simulate a loss of connection)
  • ssh -X root@<ip-add>
  • nano nohup.out

Expermiment with a script

create loopy.sh

#!/bin/bash
while true
do
echo “Computing..”
sleep 2

  • nohup ./loopy.sh &
  • tail -f nohup.out
  • nohup ./loopy.sh > loopy.out &
  • tail -f loopy.out

screen

  • which screen
  • no output imples scream not installed
  • apt update
  • apt install screen
  • screen
  • ps
  • ps -ef [pipe] grep screen
  • [CTRL A] ? — shows commands available in screen
  • [Return] to end
  • [CTRL A C] for a new screen
  • top
  • [CTRL A N] for next screen
  • vi
  • [CTRL A N] to scroll between top and vi
  • [CTRL A P] for previous
  • [CTRL A D] to detach from a screen
  • screen -r (to go back to where you started)
  • [CTRL A H] or log of sessions
    • ls -l
      • hardcopy.0
      • cat hardcopy.0
  • [CTRL A M] – to setup alterts
    • echo “starting”; sleep 10; echo “done”
    • will flash alert on the screen when there is output
  • [CTRL A X] to lock a screen
  • [CTRL A K] to kill the window