48 Silicon chip Australia’s electronics magazine siliconchip.com.au
This process is more involved than simply using the image file,
as described in the main body of this article, but gives you a lot
more options. We don’t recommend doing this with a Raspberry
Pi variant that lacks WiFi since that is a lot more fiddly. But you
could set up the SD card on a Raspberry Pi equipped with WiFi
and then plug it into a Pi Zero.
The first step involves writing a Raspbian Lite image to the
card, which is practically the same process as we described for
our custom image. These files are available for download from
http://www.raspberrypi.org/downloads/raspbian/
We used the November 2018 version of Raspbian Lite.
Write the Raspbian Lite image to the card using Win32-dis-
kimagewriter, Etcher or dd, as described in the text. Under Win-
dows, there should be two drives created, one named “boot” and
another that Windows cannot recognise. Windows will say that
it wants to format the unrecognised partition, but do not let it!
The initial contents of the boot drive are as shown in Fig.6.
Open this drive and find the file called “config.txt”, then open
it with a text editor such as Wordpad or Notepad++. Some ver-
sions of Notepad do not recognise the line endings that Linux
uses, and may not display the file correctly, so we do not recom-
mend that you use it.
Now scroll to the end of the file and make the four changes
shown in Fig.7.
The first and third enable the I2S output, to send data to the
DAC on the hat, and disable the default audio output (which is
via the HDMI display connector). The second configures the I^2 S
output to suit the DAC we are using. The fourth change allows the
console to be accessed over the UART serial port.
If you want to make any more changes to this file, now is the
time, as it will be easier to perform edits on a PC than on the Pi.
Save the file when finished.
Now create a text file on the boot drive named ‘wpa_
supplicant.conf’, and edit it to contain the following lines:
country=AU
ctrl_interface=DIR=/var/run/wpa_
supplicant GROUP=netdev
update_config=1
network={
ssid=”network”
psk=”password”
key_mgmt=WPA-PS
}
Change the “country”, “ssid” and “psk” values to match those
of your own WiFi network, and then save the file.
If you think you might want to use SSH to access the Pi, cre-
ate a file named “ssh” in the root of the boot drive. The file
doesn’t need to contain anything; it merely needs to exist.
Now safely remove the microSD card from your PC and insert it
into the Pi’s microSD card slot. Connect it to your host microcon-
troller, or whatever you are using to communicate with the Pi over
its UART serial port.
Power it up and open to the serial port on the Pi at 115,200 baud.
After about five seconds, you should see the screen fill with boot
messages. When the Pi connects to your WiFi network, a message
showing its IP address can be seen; this is handy if you wish to use
SSH for further communication.
After around a minute, you will see the login prompt, as shown
in Fig.8.
The default username is “pi” and the default password is “rasp-
berry”. Enter these, and you will end up at the command prompt,
from which we can continue to set up the Pi. Run the following com-
mand to update the package list, by typing the command and then
pressing Enter. It may take a few minutes, or even longer:
sudo apt update
Then run:
sudo apt-get install espeak-ng raspi-gpio madplay
This installs the espeak-ng, raspi-gpio and madplay pro-
grams. You may be prompted during the install; press “y” and
Enter to proceed. While the raspi-gpio program is not neces-
sary for the Speech Synthesiser, it will be handy if you wish to
use the Pi’s other GPIO (general purpose input/output) pins.
At this point, everything should be working sufficiently to allow the
Speech Synthesiser to function. It can be tested by running this
command at the prompt:
espeak-ng “testing”
You should hear the word “testing” coming through the speakers.
The next step is to set the microSD card to be read-only. Before
you do this though, you may wish to install more programs or copy
other files, as it will be easier now than later.
When we say we are setting the microSD card to be read-only, note
Step-by-step software set-up procedure
Fig.7: we’ve made four changes to the “config.txt” file
on our image, as shown here. These set up the Pi to
send audio to our DAC and amplifier board, and to turn
on the UART to enable serial communications.
Fig.8: if you can see the login prompt in your terminal
window, the Pi is booting correctly, and serial
communication is working.