Raspberry Pi: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
Brian Wilson (talk | contribs)
 
(50 intermediate revisions by the same user not shown)
Line 3: Line 3:
{| border=1
{| border=1
|-
|-
|| violet || 3B+ || BT B8:27:EB:A3:E7:69 || WLAN b8:27:eb:5c:18:96 || eth0 b8:27:eb:09:4d:c3
|| [[pi5]] || 5 4GB || BT 43:45:c0:00:1f:ac || WLAN d8:3a:dd:c1:be:60 || eth0 d8:3a:dd:c1:be:5f 
|-
|-
|| okapi || 0w || || WLAN || eth0
|| [[Violet]] || 3B+ || BT B8:27:EB:A3:E7:69 || WLAN b8:27:eb:5c:18:96 || eth0 b8:27:eb:09:4d:c3
|-
|-
|| zebra || 0w || || WLAN || eth0
|| [[Tenrec]] || 4B || BT || WLAN || eth0 || 05/2020
|-
|| [[Okapi]] || 0w || || WLAN || eth0
|-
|| [[Zebra]] || 0w || || WLAN || eth0
|-
|| [[WuKong]] || WuKong Pi H3 Zero || || WLAN || eth0 || From Seeed Studio 5/23
|-
|| [[Golden]] || 3B || || WLAN ioPhat || eth0
|}
|}


== Bluetooth scan results ==
== Bluetooth ==
 
sudo apt install bluetooth blueman python-gobject python-gobject-2


{| border=1
{| border=1
|-
|-
|| Charge 2 || BLE || F1:1D:85:35:B5:00
|| Charge 2 || BLE || F1:1D:85:35:B5:00
|-
|| Charge 3 || BLE || E0:75:52:DC:71:D3
|-
|| One || BLE || C7:B2:39:F6:BE:51
|-
|| Brian MOTO || BT || D4:63:C6:5B:28:56
|-
|| Julie MOTO || BT ||
|-
|-
|| Plover || BT || 3C:15:C2:DD:15:9D
|| Plover || BT || 3C:15:C2:DD:15:9D
Line 31: Line 33:
|-  
|-  
|| EY-SB battery charger || BT || 44:A6:E5:1F:FA:FD
|| EY-SB battery charger || BT || 44:A6:E5:1F:FA:FD
|-
|| WinkHub || BT || 00:21:CC:55:0A:B5
|-
|-
|| SC || BT || CC:58:00:00:09:64
|| SC || BT || CC:58:00:00:09:64
Line 42: Line 42:


I have printed a case for the old one, now I am [[Printing a Pi 2 case]]. Turns out making cases is one of the most fun things I have done with a Pi so far.
I have printed a case for the old one, now I am [[Printing a Pi 2 case]]. Turns out making cases is one of the most fun things I have done with a Pi so far.
== 1/1/2013 Happy New Year! ==
I got a heavy duty 7 port USB hub for it,
a nice cast al box, and now I want to make it work with my Lilliput 7" DisplayLink monitor.
To do that I will need to compile a kernel (ugh! back to doing that again!)
See also [[8track]] and [[Lilliput DisplayLink monitor]]


== Hardware ==
== Hardware ==
Line 58: Line 49:
* Pi Noir camera and cables for Pi and Pi Zero
* Pi Noir camera and cables for Pi and Pi Zero
* case with protoboard
* case with protoboard
* Startech industrial 7 port USB hub -- need power connector from digikey, ED2779-ND
* Startech industrial 7 port USB hub ([https://www.startech.com/Cards-Adapters/USB-2/Hub/Mountable-Rugged-Industrial-7-Port-USB-Hub~ST7200USBM  ST7200USBM])-- power connector from digikey, ED2779-ND NOTE: 7-24vdc input
* UBlox GPS
* UBlox GPS
* Alfa WiFi adapter
* Alfa WiFi adapter
* 7" Lilliput DisplayLink monitor with touchscreen
* 7" [[Lilliput DisplayLink monitor]] with touchscreen
* Apple bluetooth keyboard
* Apple bluetooth keyboard
* AData 32 GB Class 10 SDHC card
* AData 32 GB Class 10 SDHC card
Line 82: Line 73:
== Adafruit HDMI adapter ==
== Adafruit HDMI adapter ==


https://learn.adafruit.com/adafruit-5-800x480-tft-hdmi-monitor-touchscreen-backpack/raspberry-pi-config
These are adapters that connect a color LCD to an HDMI port.
I got one with touch and one without. I am using the touch enabled board with a 5" LCD,
also from Adafruit.
 
Copy the image to an SD card using balenaEtcher. Then mount the boot
partition and edit config.txt
 
[https://learn.adafruit.com/adafruit-5-800x480-tft-hdmi-monitor-touchscreen-backpack/raspberry-pi- Edit config.txt to enable the display]


  # uncomment if hdmi display is not detected and composite is being output
  # uncomment if hdmi display is not detected and composite is being output
Line 92: Line 90:
  hdmi_cvt=800 480 60 6 0 0 0
  hdmi_cvt=800 480 60 6 0 0 0
  hdmi_drive=1
  hdmi_drive=1
 
max_usb_current=1


Also...
Also...
Line 103: Line 99:
  touch ssh
  touch ssh


== Distro ==
Put the card into the Pi and power it up.


Raspian Stretch
With Raspian, I was done. With KivyPie I just get a pretty rainbow screen. Darn.
Could be this:


KivyPie
NOTE: startx is missing on this image, execute this command to install it:
sudo apt-get install fluxbox xinit x11-apps xclip
xsel lxterminal xterm xserver-xorg-video-fbturbo
 
I wonder how I get a prompt? I think I will need to ssh in.
 
== Installing Kivy from files onto Raspian ==
 
https://kivy.org/doc/stable/installation/installation-rpi.html
 
Seg faults -- fix it https://github.com/kivy/kivy/issues/6007


== DisplayLink kernel build ==
== DisplayLink kernel build ==
Line 157: Line 164:


Trying to get this sorted by following the instructions for wicd from this page:  
Trying to get this sorted by following the instructions for wicd from this page:  
http://wiki.debian.org/WiFi/HowToUse
[https://wiki.debian.org/WiFi/HowToUse http://wiki.debian.org/WiFi/HowToUse]


  apt-get install wicd
  apt-get install wicd
Line 165: Line 172:
=== Wardriving ===
=== Wardriving ===


apt-get install kismet
See [[WiFi Wireless Projects]] page
 
Given that wardriving is low priority, I am leaving kismet set-up for another rainy day.
 
(And it's rainy today! Heh. 12/8/2016)


== Bluetooth keyboard ==
== Bluetooth keyboard ==
Line 179: Line 182:
apt-get install bluez blueman
apt-get install bluez blueman


root@raspberrypi:/etc/default# hcitool scan
[/cdn-cgi/l/email-protection <nowiki>[email protected]</nowiki>]:/etc/default# hcitool scan
Scanning ...
Scanning ...
00:80:25:1C:C0:27 SMA001d SN: 2120048888 SN2120048888
00:80:25:1C:C0:27 SMA001d SN: 2120048888 SN2120048888
Line 194: Line 197:
  sudo apt-get install foxtrotgps gpsd
  sudo apt-get install foxtrotgps gpsd
  sudo dpkg-reconfigure gpsd gpsd-clients
  sudo dpkg-reconfigure gpsd gpsd-clients
== Big Buttons in the Pandemic April 2020 ==
I have been playing with using this Contour Shuttle Xpress as a media controller on [[Murre]]
and got this idea that it would be more fun to build a custom controller. Then I thought
"maybe a Pi Zero could do that?"
I have some rotary encoders and some giant arcade style buttons stashed. Hmm.
=== First off, how can I make the Pi look like an HID device? ===
Since I have "AutoHotKey" already installed in theory making the Pi into a keyboard should be all I need to do, and, voila!
[https://randomnerdtutorials.com/raspberry-pi-zero-usb-keyboard-hid/ Turn Your Raspberry Pi Zero into a USB Keyboard (HID)]
Also there is this [https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/ethernet-gadget Adafruit article about "Gadgets"]
But let's give the keyboard hack a try.
== A Clock Radio reinvigorated May 2020 ==
I want to hide a Pi Zero inside a beloved Panasonic RC-7243 clock radio to bring it into the present, streaming music and talking to us.
I am into the Proof of Concept stage, grabbing anything already at hand.
I am using [[Violet]] the Pi 3B+ as the dev platform but it's slowwwww so I ordered a Pi 4.
Upgraded Stretch on violet, and installed emacs.
Made a 1024 swapfile on the SSD, because builds mysteriously failed and got better with more memory.
Set up a webcam to act as a microphone.
Set the audio input to the webcam and output to the 3.5mm audio jack in .asoundrc file, see Alexa section.
See also the [[Tenrec]] page.
=== Music ===
PulseAudio is just broken for me anyway...
sudo apt purge pulseaudio
I started with Logitech Squeezebox client. I've been running the media server for years now.
To install the client
sudo apt install squeezelite
amixer cset numid=3 1
alsamixer
I daisy chained the audio output on the Pi into the Line In on [[Murre]] to share the speakers.
Use alsamixer to pump up the volume.
My Pi was muted by default which I switched with
amixer cset numid=2 1
You can do
'''amixer controls'''
  numid=3,iface=MIXER,name='PCM Playback Route'
  numid=2,iface=MIXER,name='PCM Playback Switch'
  numid=1,iface=MIXER,name='PCM Playback Volume'
  numid=5,iface=PCM,name='IEC958 Playback Con Mask'
  numid=4,iface=PCM,name='IEC958 Playback Default'
'''amixer cget numid=2'''
  numid=2,iface=MIXER,name='PCM Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : '''values=on'''    <--- this means it's unmuted
So far there is no /dev/mixer or /dev/sound/mixer so aumix does not work.
You can save the current mixer settings with
sudo alsactl store
Test output, you should hear "Front Left" and "Front Right". Or leave off the -twav to get lovely pink noise. (Ugh)
speaker-test -c2 -twav
I plugged in a USB sound card and then found its name with "aplay -L"
and some trial and error
speaker-test -c2 -twav -Dfront:CARD=Device
Set up and test input with USB mini microphone from Adafruit
https://learn.adafruit.com/usb-audio-cards-with-a-raspberry-pi/recording-audio
They tell you how to record and playback a file there.
This worked badly, the mic is defective. I switched back using to my camera for now, it works perfectly.
I will need to tap into the radio's audio amp for output or come up with another amp and speaker. In that case I will need a way to switch output between the Pi and the radio.
At this point I should be able to run the Squeezebox Client. Do NOT use port 9000. Refresh the web page to see the client in the list.
squeezelite -l
squeezelite -n okapi -s 192.168.123.2 -o speakerbonnet
I am getting an indication the output device is already in use. Huh.
=== Bluetooth A2DP audio sink ===
I want the Pi to be a sink for bluetooth audio so that I can play podcasts, youtube etc directly from my laptop, phone or Echo Flex.
First do this
sudo apt install bluealsa
Maybe this works, https://scribles.net/streaming-bluetooth-audio-from-phone-to-raspberry-pi-using-alsa/
Or maybe I will try pulseaudio again, sigh, I will probably break Okapi...
https://thecodeninja.net/2016/06/bluetooth-audio-receiver-a2dp-sink-with-raspberry-pi/
apt-get install pulseaudio-module-bluetooth bluez-tools
gpasswd -a pi pulse
gpasswd -a pi lp
gpasswd -a pulse lp
gpasswd -a pi audio
gpasswd -a pulse audio
sh -c "echo 'extra-arguments = --exit-idle-time=-1 --log-target=syslog' >> /etc/pulse/client.conf"
hciconfig hci0 up
# "I am a car stereo"
hciconfig hci0 class 0x200420
and now reboot to become a bluetooth car stereo... soon now... Okapi is only a Pi Zero W so it takes a few minutes... tick tock.
reboot
Ah, and she's back.
This is interesting,
[http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html use this tool] to
pick what you want your Pi to appear as.
I chose for Okapi to be Audio Device, Audio/Video, HiFi Audio Device = 0x200418
I could make it headphones or a car... I wonder what the differences are?
=== Saving power ===
Turn off HDMI output; in rc.local:
# Disable HDMI
/usr/bin/tvservice -o
Turn off LED
=== Alexa ===
I have a spare webcam so I used it for input. All I had to do was plug it in.
'''lsusb'''
Bus 001 Device 005: ID 046d:081d '''Logitech, Inc. HD Webcam C510'''
Bus 001 Device 004: ID 0424:7800 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: U0x46d0x81d [USB Device 0x46d:0x81d], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
Configure .asoundrc as per https://iotbytes.wordpress.com/connect-configure-and-test-usb-microphone-and-speaker-with-raspberry-pi/
Okay, it looks like there is audio. How to test?
arecord --format=S16_LE --duration=10 --rate=16000 out.wav
aplay out.wav
That worked. Then I got a tiny USB microphone from Adafruit. It works, too.
<pre>
cd ~/alexa
bash startsample.sh
You will need to authorize use for the Pi, see the link below.
+----------------------------------------------------------------------------+
|                                  Options:                                  |
| Wake word:                                                                |
|      Simply say Alexa and begin your query.                              |
| Tap to talk:                                                              |
|      Press 't' and Enter followed by your query (no need for the 'Alexa').|
| Hold to talk:                                                              |
|      Press 'h' followed by Enter to simulate holding a button.            |
|      Then say your query (no need for the 'Alexa').                      |
|      Press 'h' followed by Enter to simulate releasing a button.          |
| Stop an interaction:                                                      |
|      Press 's' and Enter to stop an ongoing interaction.                  |
| Privacy mode (microphone off):                                            |
|      Press 'm' and Enter to turn on and off the microphone.              |
| Playback Controls:                                                        |
|      Press '1' for a 'PLAY' button press.                                |
|      Press '2' for a 'PAUSE' button press.                                |
|      Press '3' for a 'NEXT' button press.                                |
|      Press '4' for a 'PREVIOUS' button press.                            |
| Settings:                                                                  |
|      Press 'c' followed by Enter at any time to see the settings screen.  |
| Speaker Control:                                                          |
|      Press 'p' followed by Enter at any time to adjust speaker settings.  |
| Firmware Version:                                                          |
|      Press 'f' followed by Enter at any time to report a different        |
|      firmware version.                                                    |
| Info:                                                                      |
|      Press 'i' followed by Enter at any time to see the help screen.      |
| Reset device:                                                              |
|      Press 'k' followed by Enter at any time to reset your device. This  |
|      will erase any data stored in the device and you will have to        |
|      re-register your device.                                            |
|      This option will also exit the application.                          |
| Reauthorize device:                                                        |
|      Press 'z' followed by Enter at any time to re-authorize your device. |
|      This will erase any data stored in the device and initiate          |
|      re-authorization.                                                    |
|                                                                            |
| Quit:                                                                      |
|      Press 'q' followed by Enter at any time to quit the application.    |
+----------------------------------------------------------------------------+
</pre>
I built Alexa using instructions I found on [https://pimylifeup.com/raspberry-pi-alexa/ this page],
with only a few hiccups that mostly went away with persistence. I still need to make her load on boot.


[[Category: Raspberry Pi]]
[[Category: Raspberry Pi]]
[[Category: Car Computer]]
[[Category: Car Computer]]
== Managing images ==
[[Managing Raspberry Pi images]]

Latest revision as of 01:52, 14 February 2024

Inventory

pi5 5 4GB BT 43:45:c0:00:1f:ac WLAN d8:3a:dd:c1:be:60 eth0 d8:3a:dd:c1:be:5f
Violet 3B+ BT B8:27:EB:A3:E7:69 WLAN b8:27:eb:5c:18:96 eth0 b8:27:eb:09:4d:c3
Tenrec 4B BT WLAN eth0 05/2020
Okapi 0w WLAN eth0
Zebra 0w WLAN eth0
WuKong WuKong Pi H3 Zero WLAN eth0 From Seeed Studio 5/23
Golden 3B WLAN ioPhat eth0

Bluetooth

sudo apt install bluetooth blueman python-gobject python-gobject-2

Charge 2 BLE F1:1D:85:35:B5:00
Plover BT 3C:15:C2:DD:15:9D
Stellar BT
Swift BT
EY-SB battery charger BT 44:A6:E5:1F:FA:FD
SC BT CC:58:00:00:09:64
??? 41:E5:79:41:3B:C7

My first edition Model B from 2012 got fried somehow, and it's passed beyond the Veil of Smoke into the Netherworld.

I have printed a case for the old one, now I am Printing a Pi 2 case. Turns out making cases is one of the most fun things I have done with a Pi so far.

Hardware

Related vaguely to the PI or usable with it

  • Pi Noir camera and cables for Pi and Pi Zero
  • case with protoboard
  • Startech industrial 7 port USB hub (ST7200USBM)-- power connector from digikey, ED2779-ND NOTE: 7-24vdc input
  • UBlox GPS
  • Alfa WiFi adapter
  • 7" Lilliput DisplayLink monitor with touchscreen
  • Apple bluetooth keyboard
  • AData 32 GB Class 10 SDHC card
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 010: ID 0eef:0001 D-WAV Scientific Co., Ltd eGalax TouchScreen
Bus 001 Device 011: ID 17e9:02a9 DisplayLink 
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 004: ID 047d:2043 Kensington 
Bus 001 Device 005: ID 0409:0050 NEC Corp. 7-port hub
Bus 001 Device 006: ID 0bda:817f Realtek Semiconductor Corp. RTL8188RU 802.11n WLAN Adapter
Bus 001 Device 009: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 012: ID 1546:01a4 U-Blox AG 
Bus 001 Device 007: ID 046d:c06c Logitech, Inc. Optical Mouse
Bus 001 Device 008: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

Adafruit HDMI adapter

These are adapters that connect a color LCD to an HDMI port. I got one with touch and one without. I am using the touch enabled board with a 5" LCD, also from Adafruit.

Copy the image to an SD card using balenaEtcher. Then mount the boot partition and edit config.txt

Edit config.txt to enable the display

# uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1
 
# uncomment to force a specific HDMI mode (here we are forcing 800x480!)
hdmi_group=2
hdmi_mode=87
hdmi_cvt=800 480 60 6 0 0 0
hdmi_drive=1

Also...

enable_uart=1

To enable ssh server

touch ssh

Put the card into the Pi and power it up.

With Raspian, I was done. With KivyPie I just get a pretty rainbow screen. Darn. Could be this:

NOTE: startx is missing on this image, execute this command to install it:
sudo apt-get install fluxbox xinit x11-apps xclip 
xsel lxterminal xterm xserver-xorg-video-fbturbo

I wonder how I get a prompt? I think I will need to ssh in.

Installing Kivy from files onto Raspian

https://kivy.org/doc/stable/installation/installation-rpi.html

Seg faults -- fix it https://github.com/kivy/kivy/issues/6007

DisplayLink kernel build

Some help with kernels and DisplayLink http://karuppuswamy.com/wordpress/2012/08/17/lilliput-displaylink-usb-monitor-um-70-17e902a9-with-raspberry-pi-on-raspbian/

Following Mitchtech kernel compile instructions with a few variations. I am using Linux Mint 14 as my build host. This installs the newest (4.7) compiler and creates symlinks. This step (building a working ARM tool chain) used to take days to figure out. Ah, progress! I love the Linux world I live in!

sudo apt-get install gcc-arm-linux-gnueabi git-core ncurses-dev

Fetching code

mkdir -p ~/src/raspberrypi
cd ~/src/raspberrypi
git clone https://github.com/raspberrypi/tools.git
git clone https://github.com/raspberrypi/linux.git
cd linux
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- bcmrpi_cutdown_defconfig
# enabled the DisplayLink module and disable many things I will never use
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k -j5
mkdir ../modules
make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/
cd ../tools/mkimage/
# Create kernel.img
./imagetool-uncompressed.py ../../linux/arch/arm/boot/Image
cp kernel.img /media/bwilson/8B12-9112/
sudo rm -rf /media/bwilson/29b6c2f5-5469-49f2-abd5-daa9149021cc/lib/modules/
sudo rm -rf /media/bwilson/29b6c2f5-5469-49f2-abd5-daa9149021cc/lib/firmware/
sudo cp -a lib/modules/ /media/bwilson/29b6c2f5-5469-49f2-abd5-daa9149021cc/lib
sudo cp -a lib/firmware/ /media/bwilson/29b6c2f5-5469-49f2-abd5-daa9149021cc/lib

Zoom zoom away we go. Put SD card in Pi. Connect monitor and boot. Worked on first try for me! Fabulous.

X11

Before diving in to the above instructions on how to get X11 going, I typed "startx" and it came up! Okay. Moving on. I need the touchscreen to work. It acts like it works but is not calibrated. I am using a mouse at the moment.

Wifi

ALFA AWUS036H works but does not show up in wpa_gui.

ALFA AWUS036NHR works. wpa_gui does not fit on the small monitor. This is a problem!

Trying to get this sorted by following the instructions for wicd from this page: http://wiki.debian.org/WiFi/HowToUse

apt-get install wicd

Could be the only problem was that bwilson was not a member of netdev

Wardriving

See WiFi Wireless Projects page

Bluetooth keyboard

The Zonet USB bluetooth adapter which I used in 8track does not work in the Pi. It identifies itself as ID 0a5c:2101 Broadcom Corp. BCM2045 Bluetooth

The Parani UD100 does though. I think I need a few more Parani's! They are cool.

apt-get install bluez blueman

[/cdn-cgi/l/email-protection [email protected]]:/etc/default# hcitool scan Scanning ... 00:80:25:1C:C0:27 SMA001d SN: 2120048888 SN2120048888 E8:06:88:4F:52:48 Apple Wireless Keyboard

Once confident that there really was a bluetooth device on the Pi, I ran blueman-assistant from the console and it worked! Presto! I wonder if it works after rebooting...

GPS stuff

Hardware: probably a UBlox AEK-4P with a mag mount antenna on the roof. Using the Ublox means I can connect the Pi via USB and the Kenwood radio via RS232 adapter.

sudo apt-get install foxtrotgps gpsd
sudo dpkg-reconfigure gpsd gpsd-clients

Big Buttons in the Pandemic April 2020

I have been playing with using this Contour Shuttle Xpress as a media controller on Murre and got this idea that it would be more fun to build a custom controller. Then I thought "maybe a Pi Zero could do that?"

I have some rotary encoders and some giant arcade style buttons stashed. Hmm.

First off, how can I make the Pi look like an HID device?

Since I have "AutoHotKey" already installed in theory making the Pi into a keyboard should be all I need to do, and, voila!

Turn Your Raspberry Pi Zero into a USB Keyboard (HID)

Also there is this Adafruit article about "Gadgets"

But let's give the keyboard hack a try.

A Clock Radio reinvigorated May 2020

I want to hide a Pi Zero inside a beloved Panasonic RC-7243 clock radio to bring it into the present, streaming music and talking to us.

I am into the Proof of Concept stage, grabbing anything already at hand. I am using Violet the Pi 3B+ as the dev platform but it's slowwwww so I ordered a Pi 4.

Upgraded Stretch on violet, and installed emacs. Made a 1024 swapfile on the SSD, because builds mysteriously failed and got better with more memory. Set up a webcam to act as a microphone. Set the audio input to the webcam and output to the 3.5mm audio jack in .asoundrc file, see Alexa section.

See also the Tenrec page.

Music

PulseAudio is just broken for me anyway...

sudo apt purge pulseaudio

I started with Logitech Squeezebox client. I've been running the media server for years now.

To install the client

sudo apt install squeezelite
amixer cset numid=3 1
alsamixer

I daisy chained the audio output on the Pi into the Line In on Murre to share the speakers. Use alsamixer to pump up the volume.

My Pi was muted by default which I switched with

amixer cset numid=2 1

You can do

amixer controls
  numid=3,iface=MIXER,name='PCM Playback Route'
  numid=2,iface=MIXER,name='PCM Playback Switch'
  numid=1,iface=MIXER,name='PCM Playback Volume'
  numid=5,iface=PCM,name='IEC958 Playback Con Mask'
  numid=4,iface=PCM,name='IEC958 Playback Default'
amixer cget numid=2
 numid=2,iface=MIXER,name='PCM Playback Switch'
 ; type=BOOLEAN,access=rw------,values=1
 : values=on     <--- this means it's unmuted

So far there is no /dev/mixer or /dev/sound/mixer so aumix does not work.

You can save the current mixer settings with

sudo alsactl store

Test output, you should hear "Front Left" and "Front Right". Or leave off the -twav to get lovely pink noise. (Ugh)

speaker-test -c2 -twav

I plugged in a USB sound card and then found its name with "aplay -L" and some trial and error

speaker-test -c2 -twav -Dfront:CARD=Device

Set up and test input with USB mini microphone from Adafruit

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

They tell you how to record and playback a file there. This worked badly, the mic is defective. I switched back using to my camera for now, it works perfectly.

I will need to tap into the radio's audio amp for output or come up with another amp and speaker. In that case I will need a way to switch output between the Pi and the radio.

At this point I should be able to run the Squeezebox Client. Do NOT use port 9000. Refresh the web page to see the client in the list.

squeezelite -l
squeezelite -n okapi -s 192.168.123.2 -o speakerbonnet

I am getting an indication the output device is already in use. Huh.

Bluetooth A2DP audio sink

I want the Pi to be a sink for bluetooth audio so that I can play podcasts, youtube etc directly from my laptop, phone or Echo Flex. First do this

sudo apt install bluealsa

Maybe this works, https://scribles.net/streaming-bluetooth-audio-from-phone-to-raspberry-pi-using-alsa/

Or maybe I will try pulseaudio again, sigh, I will probably break Okapi...

https://thecodeninja.net/2016/06/bluetooth-audio-receiver-a2dp-sink-with-raspberry-pi/

apt-get install pulseaudio-module-bluetooth bluez-tools
gpasswd -a pi pulse
gpasswd -a pi lp
gpasswd -a pulse lp
gpasswd -a pi audio
gpasswd -a pulse audio
sh -c "echo 'extra-arguments = --exit-idle-time=-1 --log-target=syslog' >> /etc/pulse/client.conf"
hciconfig hci0 up
# "I am a car stereo"
hciconfig hci0 class 0x200420

and now reboot to become a bluetooth car stereo... soon now... Okapi is only a Pi Zero W so it takes a few minutes... tick tock.

reboot

Ah, and she's back.

This is interesting, use this tool to

pick what you want your Pi to appear as.

I chose for Okapi to be Audio Device, Audio/Video, HiFi Audio Device = 0x200418 I could make it headphones or a car... I wonder what the differences are?

Saving power

Turn off HDMI output; in rc.local:

# Disable HDMI
/usr/bin/tvservice -o

Turn off LED

Alexa

I have a spare webcam so I used it for input. All I had to do was plug it in.

lsusb
Bus 001 Device 005: ID 046d:081d Logitech, Inc. HD Webcam C510
Bus 001 Device 004: ID 0424:7800 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: U0x46d0x81d [USB Device 0x46d:0x81d], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Configure .asoundrc as per https://iotbytes.wordpress.com/connect-configure-and-test-usb-microphone-and-speaker-with-raspberry-pi/

Okay, it looks like there is audio. How to test?

arecord --format=S16_LE --duration=10 --rate=16000 out.wav
aplay out.wav

That worked. Then I got a tiny USB microphone from Adafruit. It works, too.

cd ~/alexa
bash startsample.sh

You will need to authorize use for the Pi, see the link below.

+----------------------------------------------------------------------------+
|                                  Options:                                  |
| Wake word:                                                                 |
|       Simply say Alexa and begin your query.                               |
| Tap to talk:                                                               |
|       Press 't' and Enter followed by your query (no need for the 'Alexa').|
| Hold to talk:                                                              |
|       Press 'h' followed by Enter to simulate holding a button.            |
|       Then say your query (no need for the 'Alexa').                       |
|       Press 'h' followed by Enter to simulate releasing a button.          |
| Stop an interaction:                                                       |
|       Press 's' and Enter to stop an ongoing interaction.                  |
| Privacy mode (microphone off):                                             |
|       Press 'm' and Enter to turn on and off the microphone.               |
| Playback Controls:                                                         |
|       Press '1' for a 'PLAY' button press.                                 |
|       Press '2' for a 'PAUSE' button press.                                |
|       Press '3' for a 'NEXT' button press.                                 |
|       Press '4' for a 'PREVIOUS' button press.                             |
| Settings:                                                                  |
|       Press 'c' followed by Enter at any time to see the settings screen.  |
| Speaker Control:                                                           |
|       Press 'p' followed by Enter at any time to adjust speaker settings.  |
| Firmware Version:                                                          |
|       Press 'f' followed by Enter at any time to report a different        |
|       firmware version.                                                    |
| Info:                                                                      |
|       Press 'i' followed by Enter at any time to see the help screen.      |
| Reset device:                                                              |
|       Press 'k' followed by Enter at any time to reset your device. This   |
|       will erase any data stored in the device and you will have to        |
|       re-register your device.                                             |
|       This option will also exit the application.                          |
| Reauthorize device:                                                        |
|       Press 'z' followed by Enter at any time to re-authorize your device. |
|       This will erase any data stored in the device and initiate           |
|       re-authorization.                                                    |
|                                                                            |
| Quit:                                                                      |
|       Press 'q' followed by Enter at any time to quit the application.     |
+----------------------------------------------------------------------------+

I built Alexa using instructions I found on this page, with only a few hiccups that mostly went away with persistence. I still need to make her load on boot.

Managing images

Managing Raspberry Pi images