steph2000
Posts: 17
Joined: Sun Dec 14, 2014 8:03 pm

Send pictures from Raspberry to smartphone over bluetooth

Wed Jan 21, 2015 1:59 pm

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!

User avatar
DougieLawson
Posts: 35364
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Send pictures from Raspberry to smartphone over bluetoot

Wed Jan 21, 2015 2:11 pm

Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

steph2000
Posts: 17
Joined: Sun Dec 14, 2014 8:03 pm

Re: Send pictures from Raspberry to smartphone over bluetoot

Wed Jan 21, 2015 10:38 pm

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...

User avatar
DougieLawson
Posts: 35364
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Send pictures from Raspberry to smartphone over bluetoot

Wed Jan 21, 2015 11:41 pm

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.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Douglas6
Posts: 4671
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Send pictures from Raspberry to smartphone over bluetoot

Thu Jan 22, 2015 12:34 am

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.

User avatar
Douglas6
Posts: 4671
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Send pictures from Raspberry to smartphone over bluetoot

Thu Jan 22, 2015 5:12 am

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.

hamza
Posts: 76
Joined: Fri Apr 03, 2015 7:16 pm

Re: Send pictures from Raspberry to smartphone over bluetoot

Fri May 22, 2015 2:49 pm

thank you, its working perfectly,
how can detect if the image received correctly??(i mean by code??) is there notification or flage??

User avatar
Douglas6
Posts: 4671
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Send pictures from Raspberry to smartphone over bluetoot

Fri May 22, 2015 3:21 pm

Check the return code of the ussp-push command. Google for how to do that in the language of your choice.

vikvik
Posts: 1
Joined: Fri Jan 01, 2016 10:34 pm

Re: Send pictures from Raspberry to smartphone over bluetoot

Fri Jan 01, 2016 10:38 pm

Hi, is it possible to send a message from the Raspberry PI over Bluetooth to the Smartphone ?

drgeoff
Posts: 9360
Joined: Wed Jan 25, 2012 6:39 pm

Re: Send pictures from Raspberry to smartphone over bluetoot

Fri Jan 01, 2016 11:30 pm

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.

PalaniKasi
Posts: 52
Joined: Mon Dec 14, 2015 1:51 pm

Re: Send pictures from Raspberry to smartphone over bluetoot

Fri Jan 08, 2016 9:43 am

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

User avatar
Douglas6
Posts: 4671
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Send pictures from Raspberry to smartphone over bluetoot

Fri Jan 08, 2016 2:24 pm

Just as you would over any other serial device. Read the bytes of the image data, write them to the serial device.

PalaniKasi
Posts: 52
Joined: Mon Dec 14, 2015 1:51 pm

Re: Send pictures from Raspberry to smartphone over bluetoot

Sat Jan 09, 2016 5:15 am

You are correct ..But in my smartphone i need any specific application to get the images bit by bit and reconstruct it..

Audacity
Posts: 1
Joined: Sun Jun 05, 2016 3:28 pm

Re: Send pictures from Raspberry to smartphone over bluetoot

Sun Jun 05, 2016 3:31 pm

thank you Douglas6, it worked perfectly. Can we automate this process with a python script?

User avatar
Douglas6
Posts: 4671
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Send pictures from Raspberry to smartphone over bluetoot

Sun Jun 05, 2016 3:51 pm

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>"])

Irvaan Sid
Posts: 10
Joined: Tue Jun 06, 2017 11:43 am

Re: Send pictures from Raspberry to smartphone over bluetoot

Wed Jun 07, 2017 8:37 am

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??

User avatar
Douglas6
Posts: 4671
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Send pictures from Raspberry to smartphone over bluetoot

Wed Jun 07, 2017 9:14 am

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.

Skaf
Posts: 4
Joined: Wed Aug 23, 2017 3:25 pm

Re: Send pictures from Raspberry to smartphone over bluetooth

Wed Aug 23, 2017 3:31 pm

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

User avatar
Douglas6
Posts: 4671
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Send pictures from Raspberry to smartphone over bluetooth

Wed Aug 23, 2017 11:12 pm

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.

Skaf
Posts: 4
Joined: Wed Aug 23, 2017 3:25 pm

Re: Send pictures from Raspberry to smartphone over bluetooth

Mon Sep 04, 2017 8:09 am

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!

User avatar
Douglas6
Posts: 4671
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Send pictures from Raspberry to smartphone over bluetooth

Mon Sep 04, 2017 1:53 pm

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.

anshumantech
Posts: 51
Joined: Fri Aug 05, 2016 5:20 am

Re: Send pictures from Raspberry to smartphone over bluetooth

Thu Sep 14, 2017 6:28 am

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?

va7dgp_Don
Posts: 2
Joined: Mon Jan 26, 2015 10:47 pm

Re: Send pictures from Raspberry to smartphone over bluetooth

Fri Feb 08, 2019 4:43 pm

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

Return to “Beginners”