Page 1 of 1

Send pictures from Raspberry to smartphone over bluetooth

Posted: Wed Jan 21, 2015 1:59 pm
by steph2000
Hi there!

I wonder if it is possible for a Raspberry Pi to send files to an iPhone or Android Smartphone over Bluetooth. I would like to send pictures I took with the PiCamera to my phone, but am unsure where to start... Will this require interaction from the user, or would it in practice be feasible to create an app that will collect the incoming pictures?

Thanks a lot for the advise!

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Wed Jan 21, 2015 2:11 pm
by DougieLawson

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Wed Jan 21, 2015 10:38 pm
by steph2000
Thanks for the suggestion! Sadly I only have an iPhone... Furthermore, I was looking if there was any information available to create an app that would be able to communicate with a Raspberry Pi module through bluetooth.

I did manage to pair my Raspberry Pi to my iPhone. It was easier than I anticipated :-) But for now, I'm not doing much with it as I do not have any means to communicate between the two devices...

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Wed Jan 21, 2015 11:41 pm
by DougieLawson
If you have the PAN stuff you can do TCP/IP over BlueTooth.
http://www.raspberrypi.org/forums/viewt ... 91&t=36889

https://github.com/Douglas6/pinaple has instructions and code for getting it running with a Nexus.

Can't help with an iPhone.

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Thu Jan 22, 2015 12:34 am
by Douglas6
You probably want to look into OBEX, which should let you push files from the Pi with no intervention on the phone. I've never tried it but it looks easy from a few examples on the web. Google 'raspberry pi obexftp'. The iPhone may be a problem; I too cannot help you there.

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Thu Jan 22, 2015 5:12 am
by Douglas6
Ok, I just gave this a go, and it was surprisingly easy. From a clean install of Raspian Wheezy, first install the BlueZ software:

Code: Select all

sudo apt-get install -y --no-install-recommends bluetooth python-gobject
Make sure things went well with

Code: Select all

hciconfig
which should return with something like

Code: Select all

hci0:   Type: BR/EDR  Bus: USB
        BD Address: AA:BB:CC:DD:EE:FF  ACL MTU: 310:10  SCO MTU: 64:8
        UP RUNNING PSCAN
        RX bytes:57163 acl:808 sco:0 events:1922 errors:0
        TX bytes:679643 acl:3353 sco:0 commands:166 errors:0
Now pair your phone and your Pi. On the Pi, first make the adapter discoverable:

Code: Select all

sudo hciconfig 0 piscan
then start the pairing agent on the Pi:

Code: Select all

sudo bluez-simple-agent
On your phone, search for Bluetooth devices and start pairing. Follow the prompts on both the phone and the Pi. On the Pi, you should end up with something like

Code: Select all

Agent registered
RequestConfirmation (/org/bluez/2683/hci0/dev_11_22_33_44_55_66, 989777)
Confirm passkey (yes/no): yes
exit the agent with Ctrl-C.

Right, we're paired now. Get the Bluetooth address of the phone with:

Code: Select all

hcitool scan
which should produce something like:

Code: Select all

Scanning ...
        11:22:33:44:55:66       Nexus 4
Now discover what services your phone provides. We're looking for 'OBEX FTP' and/or 'OBEX Object Push'. In my case, only OBEX Object Push is available. Here's the command (use the Bluetooth address that the scan returned):

Code: Select all

sdptool browse 11:22:33:44:55:66
In my case (Nexus 4) the results included

Code: Select all

Service Name: OBEX Object Push
Service RecHandle: 0x1000e
Service Class ID List:
  "OBEX Object Push" (0x1105)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 12
  "OBEX" (0x0008)
Profile Descriptor List:
  "OBEX Object Push" (0x1105)
    Version: 0x0100
You'll need to take note of the channel number. If your phone provides a 'OBEX FTP' service, you can use obexftp, but in my case, I only have 'OBEX Object Push', so I need ussp-push, so let's install that:

Code: Select all

sudo apt-get install -y ussp-push
Now, it's a simple command:

Code: Select all

 ussp-push <bdaddr>@<channel> </path/name/to/your.jpg> <your.jpg>
substituting your phone's Bluetooth address and channel, and the path to your file to upload, and the name you want it to have on the phone. In my case, it looks like

Code: Select all

ussp-push 11:22:33:44:55:[email protected] /home/pi/my_niece.jpg my_niece.jpg
I then received a notification on my phone that a file was being uploaded. I clicked 'accept', and the transfer started, and I got another notification when it was done. The file ended up in a 'bluetooth' directory (next to the Android and Download directories; the full path was something like /storage/emulated/0/bluetooth/)

Hope this helps.

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Fri May 22, 2015 2:49 pm
by hamza
thank you, its working perfectly,
how can detect if the image received correctly??(i mean by code??) is there notification or flage??

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Fri May 22, 2015 3:21 pm
by Douglas6
Check the return code of the ussp-push command. Google for how to do that in the language of your choice.

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Fri Jan 01, 2016 10:38 pm
by vikvik
Hi, is it possible to send a message from the Raspberry PI over Bluetooth to the Smartphone ?

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Fri Jan 01, 2016 11:30 pm
by drgeoff
vikvik wrote:Hi, is it possible to send a message from the Raspberry PI over Bluetooth to the Smartphone ?
"Send a message" is not precise enough. You need to be more clear about what you want to do.

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Fri Jan 08, 2016 9:43 am
by PalaniKasi
However your using Bluetooth dongle for sending images..I need to send images through HC-05 bluetooth module in serial manner..if anyone knows about that please let me know ....
Thanks in advance..
Regards,
Palani K

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Fri Jan 08, 2016 2:24 pm
by Douglas6
Just as you would over any other serial device. Read the bytes of the image data, write them to the serial device.

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Sat Jan 09, 2016 5:15 am
by PalaniKasi
You are correct ..But in my smartphone i need any specific application to get the images bit by bit and reconstruct it..

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Sun Jun 05, 2016 3:31 pm
by Audacity
thank you Douglas6, it worked perfectly. Can we automate this process with a python script?

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Sun Jun 05, 2016 3:51 pm
by Douglas6
Sure. You can use Python's subprocess library. Something like this (untested) :

Code: Select all

import subprocess 
subprocess.call(["ussp-push", "<bdaddr>@<channel>", "</path/name/to/your.jpg>", "<your.jpg>"])

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Wed Jun 07, 2017 8:37 am
by Irvaan Sid
Is it possible to transfer file using ussp-push without mentioning the channel number? Because I found that for each device connected the channel number changes. Is there any way to transfer files only by mentioning the mac-address??

Re: Send pictures from Raspberry to smartphone over bluetoot

Posted: Wed Jun 07, 2017 9:14 am
by Douglas6
Good question. Theoretically, yes. You can determine the channel for example with sdptool or equivalent. I don't know what kind of smarts are built into ussp-push, or if extra coding is required.

Re: Send pictures from Raspberry to smartphone over bluetooth

Posted: Wed Aug 23, 2017 3:31 pm
by Skaf
Hi Douglas and all the others,

thanks for this nice and smooth tutorial.
Everythings is fine except i have a litle question:

Is it possible to send fileS or a Directories with the ussp-push? or at least deasable the "would you like to accept this download" on the phone?

i hope i'm clear enough!
have a nice day

Skaf

Re: Send pictures from Raspberry to smartphone over bluetooth

Posted: Wed Aug 23, 2017 11:12 pm
by Douglas6
As I understand it, ussp-push is suitable for sending a single object. You could use it in a program to iterate through a glob and send each file. I don't know how to disable the acceptance on the phone. If you find something, let us know.

Re: Send pictures from Raspberry to smartphone over bluetooth

Posted: Mon Sep 04, 2017 8:09 am
by Skaf
hi, thanks for your answer.

I finaly just zip the folders i wanted to send and send the .zip file... and it works fine! ( no idea if it's worth or not :D )

Didn't find any thing to disable the acceptance on the phone, but i don't need it anymore with the zip file.

Now maybe you will have an idea... when i do your procdure to install ussp-push with my RPi-zero, it works quite well, but when i do the same with my RPi3 i can start the data-transfer but nothing happend...
the both with the "2017-06-21-raspbian-jessie-lite.img"

and in you procedure you said that : "You'll need to take note of the channel number."

but the ussp-push can find the channel automatically if you don't put the channel after the @<>
ussp-push <bdaddr>@<channel> </path/name/to/your.jpg> <your.jpg>

see you!

Re: Send pictures from Raspberry to smartphone over bluetooth

Posted: Mon Sep 04, 2017 1:53 pm
by Douglas6
On the Pi3 you can try the usual troubleshooting steps. Try 'hciconfig -a' to make sure it's finding the adapter. Use 'systemctl status bluetooth' to see if the service is running. In bluetoothctl, try 'info <bdaddr>' to ensure the devices are paired and trusted.

Thanks for the tip on ussp-push. I wasn't sure which version is currently being shipped with Raspbian.

Re: Send pictures from Raspberry to smartphone over bluetooth

Posted: Thu Sep 14, 2017 6:28 am
by anshumantech
1.How can i check the file transfer from my android mobile to raspberry pi 3?
2. when i pair my mobile to raspberry pi's bluetooth then the pairing is done but when i connect then it was showing mi error that "connection failed: GDBus.Error:org.bluez.Error.Failed:no such file or directory. Try to connect mannually."
3. when i tried to send file from raspberry pi 3 to mobile i get error like "obex-data-server not installed "for that i used command sudo apt-get install obex-data-server but it was showing mi that it is already installed. i used obexpushd -B -n but that also failed.so how can i connect raspberry pi 3 and my mobile via bluetooth?and send file from pi to mobile?

Re: Send pictures from Raspberry to smartphone over bluetooth

Posted: Fri Feb 08, 2019 4:43 pm
by va7dgp_Don
As a ham radio operator. A fellow ham and I were wondering if using SSTV which is sending a picture by sound card to be received over a transceiver. VHF 145.5000 here in North America. We like to run SSTV and use my Iphone (His Android) to send and receive pictures using a sound card to send and receive but use the Bluetooth to see and use the Bluetooth transmit and send over the radio. I hope I'm making sense.

Don va7dgp