I created Blue Dot after being asked many times at Picademy “how can I get rid of all these wires?”.
Blue dot is an android app (client) and really easy to use Python library which allows you to wirelessly control your Python projects, whether that is a light switch, remote camera, robot or anything else you can think of!
See the getting started guide for more info on 'getting started', or follow the tutorial below.
Installation & Use
These instructions assume your Raspberry Pi is running the latest version of Raspbian with Pixel.
You will need a Raspberry Pi with built-in Bluetooth (such as the Pi 3 or Pi Zero W) or a Raspberry Pi and a USB Bluetooth dongle.
Get the app
Download and install the Blue Dot app from the google play store.
If you are wondering why there is no iOS app? Its because iOS doesn't support Bluetooth serial comms; you can only really talk to 'standard devices' (cars, speakers, fitness trackers, etc).
Open a terminal (Menu > Accessories > Terminal) and type:
sudo apt-get install python3-dbus sudo pip3 install bluedotOr if you need to use Python 2 (please dont tho!):
sudo apt-get install python-dbus sudo pip install bluedot
In order to communicate over Bluetooth securely you need to pair your phone to your Raspberry Pi.
On your Android phone:
- Open Settings
- Select Bluetooth
- This will make your phone Discoverable
- Click the bluetooth icon on the taskbar
- Turn on Bluetooth (if its off)
- Click Make Discoverable
- Click Add Device
- Your phone will appear in the list, select it and click Pair
- Enter a PIN code
- Enter the same PIN code when prompted
- Click Ok
The simplest way to use the Blue Dot is as a button:
- Open Python 3 (Menu > Programming > Python 3)
- Create a new file (File > New File)
- The following code, will start up the Blue Dot, and wait for it to be pressed:
- Save your program (File > Save) as mydot.py
- Run your program (Run > Run Module)
- Open the Blue Dot app
- Connect to your Raspberry Pi
- Press the Blue Dot
from bluedot import BlueDot bd = BlueDot() bd.wait_for_press() print("You pressed the blue dot!")
from bluedot import BlueDot from signal import pause def say_hello(): print("Hello World") def say_goodbye(): print("goodbye") bd = BlueDot() bd.when_pressed = say_hello bd.when_released = say_goodbye pause()By using the position of where the button is pressed you can use the Blue Dot like a joystick:
from bluedot import BlueDot from signal import pause def dpad(pos): if pos.top: print("up") elif pos.bottom: print("down") elif pos.left: print("left") elif pos.right: print("right") elif pos.middle: print("fire") bd = BlueDot() bd.when_pressed = dpad pause()Add to this gpiozero's Robot functions, you can create a Bluetooth controlled robot with very little code.
from bluedot import BlueDot from gpiozero import Robot from signal import pause bd = BlueDot() robot = Robot(left=(lfpin, lbpin), right=(rfpin, rbpin)) def move(pos): if pos.top: robot.forward() elif pos.bottom: robot.backward() elif pos.left: robot.left() elif pos.right: robot.right() def stop(): robot.stop() bd.when_pressed = move bd.when_moved = move bd.when_released = stop pause()Check out the Blue Dot documentation for more information and ideas - you really can do a lot with a simple circle :)