I could not leave well enough alone, so it was back to the Orange Pi Zero to see if I could install Google Assistant. That was the plan, and I did manage it but there were complications along the way. Not least of which was the fact that I could not log into the OPiZ with either WiFi or Ethernet. So I had to flash the SD card with an OS image again and decided to try DietPi this time around. I was impressed with that distribution of Debian Jessie (light or server) and I did manage to install Google Assistant after jumping through a few hoops.
Google Assistant
has changed. There were no details about that operation in this but
it does change how Google Assistant
is launched, at least
the first time it is used.
Also, the DietPi image is now up to Stretch (Debian 9) so that a number of extra steps described below are no longer needed.
I should rewrite this post, but I am currently working on a similar project using a Raspberry Pi 3 which takes precedence.
Table of Contents
- WiFi Woes
- Installing DietPi
- Which Linux Distribution?
- Testing the OPiZ Audio
- Installing Python 3
- Installing Google Assistant
- Some Like It Hot
Looking back at what I was doing with the OPiZ, I can guess why it would no longer connect to the local area network. I probably disabled the Ethernet interface to save power and hence reduce the heat generated by the H2+ SOC. At the same time, the wireless connection had a static IP address for testing the Domoticz server. That is a no, no on the OPiZ because, apparently, the WiFi cannot have a static address without connecting to the LAN with Ethernet. And since the Ethernet was disabled, well you can see where that is going.
Others have also had problems with the WiFi on the OPiZ. In his December 2016 blog entitled The Orange Pi Zero, Pete Scargill goes on at length about it and more or less gives up on the device because of it. Apparently, he had not changed his mind in September of this year, saying that ... the WIFI on the Orange Pi Zero was and is basically rubbish (though that is possibly down to implementation rather than hardware – others may know better) in Orange Pi Time. However, in answers to comments, he does seem to have found uses for the OPiZ, presumably in stand alone applications or when using an Ethernet connection.
Since an OS image had to be installed again, why not use DietPi mentioned by Pete Scargill? With luck, a recent update may have solved the network interface problems.
The latest compressed image file (DietPi_OrangePiZero-armv7-(Jessie).7z
,
as of November 6, 2017) can be downloaded from dietpi.com.
I followed the Getting started instructions and did not edit the
dietpi.txt
file so that the WiFi interface was not enabled.
As before, an Ethernet connection to the OPiZ was needed to
set it up. I performed a Quick scan
using Zenmap/Nmap and found the OPiZ at 192.168.0.136
Then the GPL License
screen was displayed
and after I accepted its terms, the OS was automatically updated from version 145 to version 157. Patience must be exercised, in particular when the swap file is created or recreated which takes quite a while.
When a new ssh
session is opened, then the
configuration screen will be displayed.
The first thing I did was to run the configuration utility
DietPi-Config
. I will not go into details, DietPi-Config
is a pretty straight forward configuration utility.
In Audio Options
, I changed the sound card to default
3.5mm Analogue
which is found on the extension board purchased with
the OPiZ.
In Language/Regional Options
, I changed the
Timezone
to America/Moncton
which is the
nearest city in my time zone.
In Security Options
, I changed the Root Password
and the Hostname
, to domopiz
.
In Network Options: Adapters
, I enabled the WiFi
interface, set the credentials for my network. This was done using the
Scan
option although it can be done with the Manual
option. Finally I enabled Auto Reconnect
.
The system will now ask to reboot. Do so. It would probably be a good time to power down the system, disconnect the Ethernet cable and power up the OPiZ to verify that WiFi does work. You may find that it does take some time for the OPiZ to log on to the network.
I should mention that I modified the WiFi router so that it will assign a fixed IP address to the OPiZ. Having a fixed IP address is a very good thing when running a headless server. In principle, the address could have been fixed in the previous step but, as stated before, there are reports of problems and I was impatient to get on with installing Google Assistant.
Back in dietpi-software
, I changed the SSH Server
from Dropbear to OpenSSH which
is needed for SFTP
transfers with FileZilla.
At this point, I stopped logging in as root
and used
the already defined user dietpi
(password: dietpi
).
As of November 26, 2017 the distribution will be updated to version V158. The proportions of RAM and storage used are different.
This is a good time to change the user password
Adding the OPiZ to the list of sites in FileZilla was not a problem
but a connection could not be established even though it was obvious that FileZilla was connecting to the board:
Status: Connecting to 192.168.0.25... Response: fzSftp started, protocol_version=2 Command: open "dietpi@192.168.0.25" 22 Command: Pass: ******** Error: Connection timed out after 20 seconds of inactivity Error: Could not connect to server Status: Waiting to retry...
As usual a solution can be found on the web (I am sorry that I forgot to
note where in order to give proper credit). The bash
configuration file had to be modified.
# ~/.bashrc: executed by bash(1) for non-login shells. # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac # Note: PS1 and umask are already set in /etc/profile. You should not # need this unless you want different defaults for root. # PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ ' # umask 022 # You may uncomment the following lines if you want `ls' to be colorized: export LS_OPTIONS='--color=auto' eval "`dircolors`" alias ls='ls $LS_OPTIONS' alias ll='ls $LS_OPTIONS -l' alias l='ls $LS_OPTIONS -lA' ...
I also removed the comments to the colour options for the directory listing
command ls
. This also added some aliases. From now on
ll
will be the equivalent of ls -l
and l
the equivalent of ls -lA
. The -A
switch means that
all will be listed including hidden files and directory except for the current
and parent directory (".
" and "..
").
That completed my initial configuration of DietPi on the Orange Pi Zero.
The initial log in screen shows quite a bit of information as seen above. In particular, the top line identifies the distribution
but it is quickly erased to be replaced by the DietPi log on screen.
I tried the usual commands to identify the Linux distribution and kernel version.
The often recommended lsb_release
command cannot be used,
at it is not installed.
So the OPiZ is running Debian GNU/Linux 8.9 (jessie) and the kernel is Linux 3.4.113. Armbian is a "[l]ightweight Debian ... based distribution specialized for ARM developing boards. Compiled from scratch". And DietPi is a pared down image of Armbian with added utilities.
This is not the newest Debian distribution. Currently, there is a Debian 9 (Stretch) Raspbian image for the Raspberry Pi.
The above was written on November 26. Earlier today, I upgraded the system and found Armbian updated to 5.35 with a new bootloader. It looks like the change was done five days ago.
The contents of the other information files, /etc/os-release
,
/etc/issue
, /etc/issue.net
and
/etc/debian_version
have not changed except for
/etc/armbian.txt
which has disappeared.
The IMAGE_TYPE went from stable
to
user-built
; hope that is not an ominous development.
For the most part I followed the instructions give in How to Setup an Orange Pi Zero DIY Smart Speaker with Google Assistant SDK.
The first step was to test the audio hardware. I powered down the OPiZ, plugged in the expansion board and then connected powered speakers to the expansion board. I put everything in the case also purchased at the same time as the Orange Pi Zero. As can be seen, it makes for a small neat package.
After opening an ssh
session over WiFi as user
dietpi
, I made sure that dietpi
is part of the
audio
group.
Had dietpi
not been a member of audio
, it would
have been a simple matter to join the group:
The first step in testing the audio hardware is to record sounds through
the microphone to a temporary file sample.wav
.
Then it's playback time to ensure that the speakers are getting the audio output.
It works! And I did not have to adjust playback and recording volumes.
All that remains is to create the asound
configuration
file. Again I followed the instructions at CNX as
modified to use the built-in microphone.
pcm.!default { type asym capture.pcm "mic" playback.pcm "speaker" } pcm.mic { type plug slave { pcm "hw:0,0" format S16_LE } } pcm.speaker { type plug slave { pcm "hw:0,0" } }
Python is not installed by default in DietPi but
version 3 as well as python3-dev
and python3-venv
are required for Google Assistant.
Since doing this at the beginning of the month, I have learned a few things about Python, its virtual environments and the package utilitypip
. Some of what I gathered is explained here: Python 3 virtual environments in DietPiNovember 26, 2017.
There are numerous steps before finally hearing a bad pun (is there such
a thing as a good pun?) from Mme Google in reply to a "Hey google, tell me a
joke". First you have to jump through hoops at Google Cloud Platform
creating a project. As part of that process, you get to download a "secret"
file containing a key identifying the project. Then the Google
Assistant library
and Google authorization tool
are
downloaded to the OPiZ and the authorization tool is used in combination
with the secret key to complete the binding of Google Assistant
and
the project. And I forgot, you must also activate Voice & Audio Activity
in the Google Activity Controls page
in your Google
account, which of course means you must have such an account.
Again I followed the CNX instructions Setting Up Google Assistant on Orange Pi Zero. To be honest I muddled through and doubt that I could explain what I did. You could find further help in Voice Control by Google Assistant written by Takanobu Fuse. And as one would expect, there are YouTube presentations.
The long and the short of it, is that you should end up with a file
with a very long file name that looks like
client_secret_00000000-0123456xxx.apps.googleusercontent.com.json
in the dietpi
home directory. From then on here is what I did.
Installation of the Google libraries
Authorization
The command is so long that I broke it up into three parts. The "\"
at the end of the first two lines is the continuation symbol and the
> at the start of the last two lines is displayed by bash
as a prompt for the rest of the command.
Testing Google Assistant
And that is it.
And Google assistant answered "its eight forty-five".
CtrlC stops the assistant.Using Google Assistant
Of course all the installation steps do not need to be repeated. From now on, Google Assistant can be used as follows:
Auto-starting Google Assistant
The final step is to make sure that Google Assistant automatically starts up when the OPiZ is powered up or reset. Again, I merely adapted what CNX proposed; this stuff is way over my pay scale.
[Unit] Description=google assistant service After=network.target ntpdate.service [Service] Type = idle Environment=VIRTUAL_ENV=/home/dietpi/env/ Environment=PATH=/home/dietpi/env/bin:/usr/local/sbin:/usr/local ExecStart=/home/dietpi/env/bin/google-assistant-demo WorkingDirectory=/home/dietpi StandardOutput=inherit StandardError=inherit Restart=always User=dietpi [Install] WantedBy=multi-user.target Alias=google-assistant.service
All I had to do was to adjust the user name. The service can be enabled and started. This needs to be done only once.
Test this by powering down the OPiZ and then powering it up. You will have to wait a few seconds before talking to Mme Google, just be patient.
The running temperature of the H2+ SOC is a concern as I mentioned in the first look at the Orange Pi Zero. While the photograph indicated that the OPiZ was in the small case, it was in fact outside the case and being run in a cool room.
That is not too bad, but the fact is that when everything is in the
case, the temperature does reach unsafe levels, or so says cpu
.
Indeed, I have been running Google Assistant for the
last twenty minutes or so with talk radio in the background at normal
conversation level. Even though the room temperature is only 20° C, the
OPiZ reports a temperature of 63° C which is "running hot, not recommended"
and the cpu frequency has been lowered from 1008 MHZ to 648 MHZ on all four
cores.
It would be comforting if it were possible to get down to acceptable levels with passive cooling. That will not be easy. For one thing there is not much room for a heat sink between the main board and the expansion board which are only 9.5 mm apart. Furthermore the H2+ rises about 1.8 mm high above the main board. The chip is only 14 mm square but there is room around it. I think it should be possible to put a rectangular 17×22 mm heat sink that is 6 mm high on the chip. I have ordered some hardware and I will see what can be done.
I also plan on drilling holes in the bottom plate of the case to increase air flow. The trouble is that the board sits just 2.5 mm above the plate so it will block most air movement from the bottom to the top. But I think there is nothing to lose in trying.
There will be a report on the success, or lack thereof, of these measures when that slow boat from China comes in with my tube of thermal paste and heat sinks.
In the mean time, I decided to try once more to lower the heat by disabling
some of the hardware to reduce power consumption. The Armbian utility h3consumption
remains available on
DietPi. Using it to check the default settings, the
graphics processor is inactive, which makes sense given the absence of an
HDMI output on the OPiZ. I don't think that was the case with stock Armbian. I have learned my lesson and will not play with the
network interfaces but I decided to disable the USB ports since these are
not being used. It probably will not reduce the heat generated by the H2+ in
any significant way, but it may reduce overall power consumption which could
make the OPiZ a bit less finicky about its power supply.