Babies and Linux: The Quest for A DIY Baby Monitor: The Sequel: I Have Too Many Raspberry Pi’s

Are you cheap? Did you just have a baby? Do you need a way of monitoring your newly minted progeny? Do you have Raspberry Pi’s for days? If you answered yes to all of the above, let me take you on a journey of self-discovery and command-line shenanigans.

The goal is to create an audio baby monitor for my spawn as she is now sleeping, sometimes, in her own room with as little cost as possible. We already have a Wyze Cam for video check-ins and motion sensing. We could use our current mobile devices and leave the stream up 24/7, but that is unrealistic. We will need our devices for other uses. Also, killing the batteries of these devices is not the most cost-effective or eco-friendly way of living.

The solution was to take a stockpile of existing equipment and bend it to my technological will. Taking two Raspberry Pi’s and a few other components and placing them into a magic blender of imagination and frustration to create a simple yet effective Linux powered audio baby monitor.

The setup is simple. An audio server and streaming client. A Raspberry Pi with a microphone array broadcasting audio over our home network 24/7, and a second Pi playing that audio 24/7 with some speakers. After some research Icecast2 and Darkice looked to be the most promising. The benefit of using this setup would include playing the audio on any device with a web browser on top of completing the initial goal. As for the client, Pi MusicBox fits the bill. Pi Musicbox works well on a Raspberry Pi 0w, supports network streaming, can start a stream at boot, and has a stream watchdog that will restart the stream after network loss or some other issue. Below are the part list and setup instructions.

Part List

Audio Server
  • Raspberry Pi 3
  • Micro SD Card 8Gb
  • Micro USB Power Supply
  • Any USB Microphone (I used a PS3 Eye)
  • Blue Tack (Optional – To cover LEDs)
Audio Client
  • Raspberry Pi 0w
  • Micro SD Card 8Gb
  • Micro USB Power Supply
  • USB Powered Speakers
  • OTG USB Hub
  • USB Sound Card (I used one from a Logitech headset I had lying around)

Putting it All Together

SD Card Preparation Server
Write the current Raspbian Buster to a SD card

Add ssh file to boot partition
        Open Notepad
        Click File and Save As
        Navigate to boot partition
        Change Save as type to All Files 
        Save as ssh

Add wpa_supplicant.conf to boot partition
        Open Notepad
        Add below code and change for your network
        Change Save as type to All Files 
        Navigate to boot partition
        Save as wpa_supplicant.conf 

Note: make sure both files are saved without .txt extension

Audio Server

Attach Microphone
Insert SD Card 
Boot Pi
SSH into Pi using it's network address, I used my routers DHCP page to find this
Next are the terminal commands
sudo raspi-config           #edit pi's differnt configs
Choose option 1             #to change the password to something else
Choose 2 and then 1         #to change the hostname (I chose icecast)
Choose 3 and then b2        #to have the Pi wait for a network connection at boot
Choose finish
Select reboot
SSH back into the Pi        #now you can use icecast.local or whatever you choose as the domain instead of the ip
sudo apt update && sudo apt upgrade -y
sudo apt install icecast2   #to install icecast2
Choose configure
Leave localhost
Change source password
Change relay password
Change admin password
Sudo apt install darkice
arecord -l                  #to see you microphone mine was at 1,0
sudo nano darkice.cfg       #creating the darkice config file

[general]
duration        = 0      # duration in s, 0 forever
bufferSecs      = 1      # buffer, in seconds
reconnect       = yes    # reconnect if disconnected
 
[input]
device          = plughw:1,0 # Soundcard device for the audio input
sampleRate      = 44100   # sample rate 11025, 22050 or 44100
bitsPerSample   = 16      # bits
channel         = 1       # 2 = stereo
 
[icecast2-0]
bitrateMode     = vbr       # constant bit rate ('cbr' constant, 'abr' average)
quality         = 1.0       # 1.0 is best quality (use only with vbr)
format          = vorbis       # format. Choose 'vorbis' for OGG Vorbis
bitrate         = 320       # bitrate
server          = localhost # or IP
port            = 8000      # port for IceCast2 access
password        = CHANGEME  # source password for the IceCast2 server
mountPoint      = CHANGEME.mp3  # mount point on the IceCast2 server .mp3 or .ogg
name            = CHANGEME
description     = CHANGEME

change passowrd to your source password from above and the other CHANGEME to whatever you like
lower bitrate to 192 if you encouter stuttering

hit crtl + x
hit y
hit enter

sudo nano darkice.sh       #creating the darkice shell command to run with crontab

#!/bin/bash
sudo /usr/bin/darkice -c /home/pi/darkice.cfg

hit crtl + x
hit y
hit enter

crontab -e

at the end add

@reboot sleep 20 && sudo /home/pi/darkice.sh

sudo reboot

open your browser and navigate to icecast.local:800 or yourip:8000 
play the stream to test

note tested in Chrome, Firefox, and Silk on desktop and mobile

SD Card Preparation Client

Write the current Pi MusicBox to a SD card
Navigate to boot 
Navigate to config folder
Open settings.ini
Type in your Network SSID and Network Key in the appropiate fields
Connect OTG Hub to Pi
Connect USB DAC
Connect speakers to DAC
Connect Speaks to USB Hub
Insert SD card
Boot the Pi
In a browser navigate to musicbox.local
Go to settings
Go to musicbox
Change root password
Change Autoplay URI to http://icecast.local:8000/yourmount.mp3 or http://yourserverip:8000/yourmount.mp3
Turn on Stream Watchdog
Go to Audio 
Change Initial Volume to your preference
Go to the bottom click Save
Click Apply Changes Now

Your Pi should reboot to playing the Audio

At this point, you should have a complete system setup. Now you can set up your devices where needed. You can also add as many clients you need permitting the bandwidth allows. I used hook and loop ties to attach the microphone to a crib bar and then applied blue tack to hide the LEDs. This setup is not cost-effective if you have to buy all the parts considering a cheap monitor on Amazon costs 16.95 at the time of writing. If you have the parts or are looking for an interesting project, get your Linux on. I want to thank Matt Kaar at http://mattkaar.com/ for inspiration. I used his original project as a base and adapted it to my needs. All hail our Penguin overlord!


Posted

in

by

Tags: