diff --git a/ToDo.txt b/ToDo.txt new file mode 100644 index 0000000000000000000000000000000000000000..f82650f80693ea158c367df8780a977f689b74d7 --- /dev/null +++ b/ToDo.txt @@ -0,0 +1,29 @@ +Problem: + +pyaudio isnt working +1. sound always coming out of HDMI + donno how it was fixed but after changing from HDMI to analog and not touching the computer for few minutes, changed on its own + -> also fixed the problem with no device, now has ((0, u'dmix', 0L), 48000.0) +2. invalid sample rate + because dmix has sample rate of 48000, need to change other sample rates to 48000 + +https://www.linuxquestions.org/questions/linux-newbie-8/how-to-play-realtime-insted-of-using-arecord-and-aplay-858500/ + +mkfifo realtime.wav +arecord realtime.wav && aplay realtime.wav + +change this so create .wav with the program that i made and play it with aplay +need to be 16bits + +espeak doesnt work +current thing doesnt work either + +https://tutorials-raspberrypi.com/raspberry-pi-bluetooth-data-transfer-to-the-smartphone/ +get distance via raspberry pi +send distance data or converted sound data to phone via bluetooth +play sound via phone + +android receiving data via bluetooth +https://www.egr.msu.edu/classes/ece480/capstone/spring14/group01/docs/appnote/Wirsing-SendingAndReceivingDataViaBluetoothWithAnAndroidDevice.pdf + +https://www.youtube.com/watch?v=sY06F_sPef4 diff --git a/bluetoothControlApp.py b/bluetoothControlApp.py new file mode 100644 index 0000000000000000000000000000000000000000..033df73a86c37794906687c968a2f60aacb9c43e --- /dev/null +++ b/bluetoothControlApp.py @@ -0,0 +1,16 @@ +from distanceMeasure import TFmini, Button +from piAndroidBluetooth import serialBluetooth + +tf = TFmini() +button = Button(15) +blue = serialBluetooth() +tf.open() + +while True: + if button.isPressed(): + try: + distance = tf.getDistance() + blue.write(str(distance)+'\n') + + except KeyboardInterrupt: # Ctrl+C + tf.close() diff --git a/piAndroidBluetooth/__init__.py b/piAndroidBluetooth/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..228019fd5cdd1ee4d481a530bdbce495e7cc13b1 --- /dev/null +++ b/piAndroidBluetooth/__init__.py @@ -0,0 +1 @@ +from .serialBluetooth import serialBluetooth diff --git a/piAndroidBluetooth/piAndroidBluetooth.txt b/piAndroidBluetooth/piAndroidBluetooth.txt new file mode 100644 index 0000000000000000000000000000000000000000..419e1617fd920b4825f1b175945f9ea044ff3d0c --- /dev/null +++ b/piAndroidBluetooth/piAndroidBluetooth.txt @@ -0,0 +1,22 @@ +https://www.youtube.com/watch?v=sY06F_sPef4 + +Set Up: +sudo nano /etc/systemd/system/dbus-org.bluez.service + ExecStart=/usr/lib/bluetooth/bluetoothd -C //add -C + ExecStartPost=/usr/bin/sdptool add SP //add this line below the line above +Save and Reboot + +Set Connection: +1. Connect Android and Pi with Bluetooth(search it up) + +To Test Set Up: +Android: +1. Download "Serial Bluetooth Terminal" +2. Connect to Pi by doing the following + 1. Menu(three horizontal lines) > Devices > raspberry pi +Pi: +1. sudo rfcomm watch hci0 +=> by doing Android.2, Pi.1, serial bluetooth connection is made +2. python -m serial.tools.list_ports +=> make sure /dev/rfcomm0 exist +3. Run the serialBluetooth.py file to send data(need to figure out how to receive it) \ No newline at end of file diff --git a/piAndroidBluetooth/serialBluetooth.py b/piAndroidBluetooth/serialBluetooth.py new file mode 100644 index 0000000000000000000000000000000000000000..d1f9b4f258860d77c8d04437b36fe731450f9b70 --- /dev/null +++ b/piAndroidBluetooth/serialBluetooth.py @@ -0,0 +1,23 @@ +import serial + +class serialBluetooth: + def __init__(self): + #see if i can do rfcomm watch hci0 here + #see if /dev/rfcomm0 exist + self.ser = serial.Serial('/dev/rfcomm0') + + def isOpen(self): + return self.ser.isOpen() + + def write(self, message): + self.ser.write(message) + + def read(self): + return self.ser.readline() + + +if __name__ == "__main__": + bluetooth = serialBluetooth() + bluetooth.write("Testing Write") + print(bluetooth.read()) +