Skip to content

tommccallum/smartbot

Repository files navigation

Personal assistant

What to do if coming to this project for the first time, or back after a long hiatus...

Technologies

  • Raspberry Pi
  • Bluetooth Speaker

Software

  • Python 3
sudo apt install libbluetooth-dev
pip install pybluez

Techniques

  • Uses a FIFO file to communicate with mplayer instance to allow pause and plan

Similar projects

Text to Speech

Architecture

  • User Context manages the current operation of the bluetooth speaker
  • Each state adds sets of abilities to the User Context Queue
  • When each state has been loaded, it then calls UserContext.execute, which will then run each ability in turn

Permissions

  • Add user to the following: -- lp -- bluetooth -- www-data

PulseAudio

  • add the following to /etc/pulse/default.pa
load-module module-switch-on-connect

Note that I did this and was getting the following errors:

Jun 18 19:38:16 april bluetoothd[294]: Unable to get connect data for Headset Voice gateway: getpeername: Transport endpoint is not connected (107)
Jun 18 19:38:16 april bluetoothd[294]: connect error: Connection refused (111)
Jun 18 19:38:18 april bluetoothd[294]: connect error: Connection refused (111)

I removed the line, removed the device and re-paired.

  • install bluez for bluetooth
  • install python-gobject
  • pactl load-module module-bluetooth-discover
  • check /var/log/syslog if you get errors when trying to connect to bluetooth

Use this command to follow the system log as its connects:

journalctl --follow

Bluetooth

  • use bluetoothctl manually first to check connectivity
$ sudo bluetoothctl
> scan on
# wait for device to be detected
> trust XXX
> pair XXX
> connect XXX

Updatable programs.txt

sudo mkdir /opt/smartbot
sudo chown pi:www-data /opt/smartbot
sudo chmod g+ws /opt/smartbot
cp get_iplayer/programs.txt /opt/smartbot

Sensing distance

sudo hcitool lescan --passive
``
- this works once connected

sudo hcitool rssi

- https://www.quora.com/How-do-I-calculate-distance-in-meters-km-yards-from-rssi-values-in-dBm-of-BLE-in-android
Installation instructions for R-Pi from clean Raspbian lite image

* assumes connected to internet

- Dependencies
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install python-pip3 pulseaudio git mplayer apache2 php
$ pip3 install schedule evdev

- Download
$ git clone https://github.com/tommccallum/BluetoothMusicPlayer

- Install get_iplayer
$ git clone https://github.com/get-iplayer/get_iplayer
$ sudo perl -MCPAN -e shell
> install HTML::Entities
> install HTTP::Cookies
> install LWP::ConnCache


- Setup
$ mkdir -p $HOME/Radio/tmp
$ mkdir -p $HOME/Radio/keep

- Installation
$ cd BluetoothMusicPlayer
$ check_dependencies.sh
$ ./install_festival_voices.sh
$ cp scheduled/* /etc/cron.daily
$ ./retrieveChildrensProgrammes.sh

- Install Web Interface
$ sudo a2enmod cgi
$ ./install_web_interface.sh

About

Uses Raspberry Pi to stream music via wifi and play via bluetooth speaker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors