A mobile chatbot essentially used to make citizens interact with trees and foster their empathy for trees as organisms in our daily life.
We use Python 3.11.2
with pip
as package manager and virtualenv
to create isolate virtual environments.
- Raspberry Pi Zero v1.1
- 16GB micro SD card
- micro USB -> USB adapter
- USB splitter (to have two USB slots)
- USB speaker box
- Bluetooth Lavalier microphone with USB receiver
- Enviro+ hat including the PM sensor to measure particles in the air
The chatbot uses Rasbian OS (Bookworm) to save some RAM and energy. Please note that we use the latest Bookworm release in which Python v3.11.2 is pre-installed.
- Install Rasbian Bookworm OS by using the Raspberry Pi Imager to flash your SD card.
In case you use an older OS of Raspbian you could go with Python v9 (pre-installed).
Install the ALSA service utilities and follow steps below.
Run sudo apt install -y mpg123
to play mp3 files on raspberry.
sudo alsactl init
- list available playback devices (speaker) on RasPi
aplay -l
- list available capture devices (microphone) on RasPi
arecord -l
- Set both devices as default and edit
sudo vim /etc/asound.conf
If your speaker is on card 1, device 0, and your microphone is on card 0, device 0, your /etc/asound.conf might look like this:
# Default speaker
pcm.!default {
type hw
card 2
device 0
}
ctl.!default {
type hw
card 2
}
# Default microphone
pcm.!default {
type hw
card 3
device 0
}
ctl.!default {
type hw
card 0
}
- Restart the ALS service to apply the changes:
sudo systemctl restart alsa
In order to increase the volume of your speaker e.g. to 80% you can run amixer set Master 80%
You should test your speaker and microphone configurations:
Record 5sec: arecord -D hw:0,0 -f cd -t wav -d 5 -r 44100 -c 1 test-record.wav
Play your recording: aplay test-recording.wav
First install git to be able to pull the enviro+ repository.
sudo apt update
sudo apt install git
Follow this introduction to install enviro+: https://learn.pimoroni.com/article/getting-started-with-enviro-plus#installing-the-enviro-python-library
Activate the virtual environment with source ~/.virtualenvs/pimoroni/bin/activate
.
You should now be able to explore and run all example codes without retrieving any error messages.
Next, pull this GitHub Repository by running git clone https://github.com/technologiestiftung/talking-treebot
.
Navigate into the folder cd talkding-treebot
and run pip install -r requirements.txt
. All the packages and libraries need to run the
- Install the same Python version you are using on your Raspberry Pi (ideally v3.11.2 any other version like v9 also works)
- Install
venv
and create a virtual environment:python3.11 -m venv treebot-env
and activate itsource treebot-env/bin/activate
- Install
pip
and install missing packages withpip install [the-missing-package]
or simply runpip install -r requirements.txt
An older version of this project was using a headless OS (without screen, keyboard, mouse) which is why we needed to connect to the Raspberry via SSH.
- run
ping raspberrypi
- copy the IP address and run
ssh talkingtreebot@[copied-IP-adress]
(e.g. 192.168.4.123) - connect with username and password
If you can't find the raspberry in your network, check if you laptop and the raspberry are connected to the same Wifi. To see all devices that are connected to your network run arp -a
Furthermore, we use magic wormhole to transfer files from the raspberry to our computer.
- Install on Raspberry Pi running
sudo apt install magic-wormhole
- Install on MacOS running
brew install magic-wormhole
In case you are using a Raspberry Pi with arm64 architecture (which is the case Raspi v4) you can improve your developer experience connect your Visual Studio Code IDE.