Mycroft AI in a safety Docker Container on a Raspberry Pi 3
I currently have my home automation running on a Raspberry Pi 4 with Home Assistant (hassio). My idea was to control the whole thing with a voice assistant. Since you can run the Mycroft in a Docker environment, I want to do the whole setup with only one Raspberry Pi. I don’t think that the Pi’s resources are sufficient, but it’s worth a try. The first attempts with a Raspberry Pi 3 show that it has to struggle with Mycroft via docker.
Required Hardware:
- Raspberry Pi 3/4 + standard cables
- Micro SD card min 8 GB
- Jack to jack cable
- Speaker with audio jack
- USB Microphone
- HMI cable and Monitor for first setup
Required Software
- Raspberry Pi OS arm64
- Docker for Raspberry Pi
- Mycroft Container
- Github Mycroft Sources
- Terminal for ssh connection
- Belena Etcher
- SD Formatter
Raspberry Pi setup
Most will know how to create a boot image on an SD card. With belena.io, the whole thing works very quickly and is actually self-explanatory. After inserting the SD card and starting Debian, you have to make the standard settings (WiFi setup, language, …).
The next step should be to enable the ssh interface under Debian (Settings -> Interface -> Activate SSH). Now you no longer need the monitor and you can continue to set up everything via the SSH terminal. An SSH terminal connection can be established with the Macbook with the following command:
sudo ssh pi@192.168.178.xx
Now we are on the Raspberry Pi and can do the first installations. The first thing you should do is bring Debian up to date with the following command:
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
Docker on Raspberry Pi
I stuck to this website when installing Docker. Many thanks for the clear instructions.
Get Mycroft Docker Development Environment
I tried to get the whole thing to work with the instructions on Github but failed again and again in some places. Ultimately, I found my own way that is similar to the Github guide.
Pull mycroft respository from GitHub
git clone https://github.com/MycroftAI/docker-mycroft.git
Build the docker image in the directory were you pulled the repository.
docker build -t mycroft .
Run the following command to start up mycroft:
docker run -d \
--name mycroft \
-v /home/pi/mycroft:/root/.mycroft \
-v /home/pi/mycroft_skills:/opt/mycroft/skills \
--device /dev/snd \
-e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native \
-v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native \
-v ~/.config/pulse/cookie:/root/.config/pulse/cookie \
-p 8181:8181 \
mycroft mycroftai/docker-mycroft:latest
Check if the docker container is up and running by typing:
pi@raspberrypi:~ $ docker ps -a
If you want to remove the docker container you have to type in:
pi@raspberrypi:~ $ docker rm mycroft
Your Docker container is now set up and is just waiting to be started. With the command “ sudo systemctl enable docker “, which is described under “ Docker on Raspberry Pi “, Docker is started automatically when booting.
The best thing to do after restarting is to check whether the Docker container is already there ( docker ps -a ). The command to start mycroft Container is:
docker start [container_ID]
Enter container:
docker exec -it mycroft /bin/bash
After Mycroft is running, the device must still be connected to the MycroftAI. To do this, you first have to register at mycroft.ai. For the device connection you have to excecute the following command:
./startup.sh
The speaker will let you know what to do ( register on mycroftAI ). A voice tell you to add the device ID. After that it will take a few moment until the terminal gui will appear.
By typing only ./start-mycroft.sh you will get an info which commands you can use. Now you can execute all the commands you want which are available, for example (simple audio test):
./start-mycroft.sh audiotest
With the command ./startup.sh cli the terminal cli will be opened like in the Picroft Image.
Install nano to edit container file
To change a file directly in the terminal you need an Editor. In my case I will use nano. To install vi you have to paste the following commands:
apt-get update
apt-get install nano