Sending commands via bluetooth serial port

Post your questions and help other users.

Moderator: Martin

Post Reply
nanobot
Posts: 13
Joined: 10 Aug 2014 11:00

Sending commands via bluetooth serial port

Post by nanobot » 10 Aug 2014 11:09

Hi,

I was switching from Tasker to Automagic Premium because of the nice flows, which are a great optical programming help.

Now I have a little problem and hope to get some help here.

I'm using a relay with a bluetooth interface, so I can easily connect to it with my Samsung Tab. But now I wonder how to send commands via bluetooth in order to switch the relay. The commands are already known from the relays user manual. But how to send them? Do I need a plugin or can I do that within Automagic Premium?

Best regards,
nanobot
Last edited by nanobot on 11 Aug 2014 10:52, edited 1 time in total.

nanobot
Posts: 13
Joined: 10 Aug 2014 11:00

Re: Sending commands via bluetooth

Post by nanobot » 10 Aug 2014 18:03

Maybe I have to go more into detail. :D

The relay is called TOSR02 from TinySine. There is a separate App which works great - one just have to connect to the bluetooth relay and then can easily toggle the two relays between on and off. I want to use it in my car together with my Samsung Tab 4. Everytime the tabs battery is getting low I want to toggle the relay by Automagic which is installed on the tab. The tab is plugged to the relay at all times and is being charged if the relay is in the state "on". Now I'm in search of a Automagic feature or a compatible plugin to send commands to the relay via bluetooth whenever the battery of the tab is low or even fully charged.

ZSasha
Posts: 103
Joined: 11 Oct 2013 03:48

Re: Sending commands via bluetooth

Post by ZSasha » 10 Aug 2014 22:00

Hi nanobot, were you able to do that with Tasker? If yes - was it some plugin involved or it was a natively supported in Tasker?

nanobot
Posts: 13
Joined: 10 Aug 2014 11:00

Re: Sending commands via bluetooth

Post by nanobot » 11 Aug 2014 06:50

Hi ZSasha,

I didn't try that in Tasker up to now because it's a new project and I don't want to use both apps. If it is not possible with Automagic than I have to try it with Tasker, but I love Automagic! :P

If there is no Automagic action which can handle bluetooth serial connections than I have to do it by a plugin or by command line. But that's very new for me. :|

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Sending commands via bluetooth serial port

Post by Martin » 12 Aug 2014 16:20

Hi,

There's no built-in way to communicate with a BT device directly so you would have to use a plugin for now. Maybe SL4A also allows to communicate over BT.
BT serial communication is something that is on my list of features under consideration but I did not yet have the time to look at it so I can't promise anything yet.

Regards,
Martin

nanobot
Posts: 13
Joined: 10 Aug 2014 11:00

Re: Sending commands via bluetooth serial port

Post by nanobot » 03 Sep 2014 06:44

Hi,

now everythings works great with Automagic Premium and my BT serial connection. I installed SL4A and PY4A and now I can start my script.py by the action "Plugin" very easy.
Here is my script if anyone will be interested in it:

Code: Select all

import android
import time

droid = android.Android()

mac = '01:02:03:04:05:06' #here you have to change the mac address by the one of your paired BT device
uuid = '00001101-0000-1000-8000-00805F9B34FB'
command = 'd'

droid.toggleBluetoothState(True) #if your BT is off you can switch it on
droid.bluetoothConnect(uuid,mac)
droid.bluetoothWrite(command)
time.sleep(2) #the script will pause for 2 seconds

droid.exit()
Bye,
nanobot

angelatwork
Posts: 186
Joined: 12 Feb 2014 01:45

Re: Sending commands via bluetooth serial port

Post by angelatwork » 03 Sep 2014 17:39

interesting, thank you for sharing
Best regards,
AngelAtwOrk

Post Reply