Arduino + Bluetooth module + Android - android

I'm trying to think of a way to do a simple home automation project that involves an Arduino, a Bluetooth module and an Android phone. The idea is that I have two Arduino boards in different parts of my home. And if I walk into a room then a LED lights up on the board that has discovered my phone. If I walk out of the Bluetooth range, the LED should turn off.
I have tried the DomoticHome project with a router, but it's only for manual on/off and it's based on the Ethernet module.
I don't want to make an Android application from scratch, but I would like to take some existing open-source application that I could extend to use Bluetooth and/or turn on the LED automatically.

Actually, you might skip that Android application requirement. Just make the Arduino board l2ping your phone by Bluetooth periodically and switch your LED based on success or fail.
As a side effect, you could automate with just any phone, that supports Bluetooth. But the devil is in the detail. It might be necessary to pair boards and phone initially.
Additionally, most Android phones switch off visibility after a minute or two. So you will have to check, whether a ping will work then. (I don't know whether l2ping is available on Arduino out of the box, but it should be portable easily.) Trying to open a Bluetooth port on your mobile device may be an alternative to l2ping. So a no-application-solution should be possible.

Best way to do this would be using a handshake signal every 1 second or 2 seconds.. the bluetooth module should send HI if mobile receives that i should reply with HI.. Once the mobile does not reply it should turn the lights off.. If it receives the HI it should turn the light back on..I have a code that can connect to these bluetooth modules using serial communication..its very simple to use..i will check and send you the code.. All the best..

Related

Bluetooth proximity scan while paired

I have been doing a ton of research on this project I want to do, probably read every SO post (bluejacking, RFCOMM, beacons, etc...) and my head is spinning.
I want to create a system at home, using Arduino (with bluetooth le) that will scan bluetooth and detect when my phone or any of my family members phones are in proximity. Whether this is a MAC scanner or simply getting the friendly name. I would also like to get the RSSI. I dont need to do accurate distance measurement but I would like to know approximately how close they are. Does anybody have any suggestions for this approach? I know I can create an app on the phone and have it become a beacon and this may be an option but I am concerned with Android, it would have to be Marshmallow 5.0 at a minimum. I would like support to be a little lower than that, like JB or KK. So, it seems like there should be a simple scan, just looking for the MAC or name. That is all I really need.
That said, the main question I have is, can you scan for and see bluetooth devices in range if they are already paired to something? Like a Bluetooth headset? I understand bluetooth is point to point but does it allow multiple connections or at least broadcast the mac or name when paired?
This question, along with any general suggestions will help me out tremendously!
Thanks!
Bluetooth Discovery from the Listener involves Listening for Bluetooth Inquiry packets(RX) and inquiry response (TX).if done continuously this will deplete the battery. Hence most devices (including Mobile Phones and Headsets) has a policy of when to be discover-able and connectable. Headsets in particular are discoverable only when they are instructed and connectable until one device is connected to it ( There are probably exceptions where the headset has the capability to be connected to multiple phones at the same time). Most Mobile Phones are discoverable only when they are in settings screen ( Android,IOS and Windows Phones), but unlike the headset case they are connectable.
so one option with the MobilePhone is to see if it is possible to connect to them after pairing once ( for example by trying a service search on the remote device and see if it returns the service attributes, this internally makes a connection and indirectly ensures the presence of the device).
if you are specific about a mobile phone which is already paired then you might need to establish a higherlayer connection ( such as SPP) with Authentication and encryption. This would force a two way check between devices to see whether they are already paired. other less secure option is to rely on the Phone (Android and IOS phones doesn't generally Allow a higher layer connection without encryption/pairing) and try to establish an SPP connection to the phone.
Another option is to use Bluetooth-LowEnergy. But Note that security in BT was superior to BLE till BTv4.1 and same on BTv4.2.

How to Auto-Connect to Arduino with Android App?

I am currently working on an android application that blocks texting while driving. It connects through Bluetooth to an Arduino Bluno that is connected to a car via the OBD-II port and scans for data received from a car (either 0 for a non-drive state or 1 if the car is going above 0 mph i.e. driving) and blocks texting if the car is in a drive state.
What I would like to do is have the app/phone automatically connect to the Arduino once I enter the car with the phone and start driving. I am not familiar with how to do so, if I need to use the native Android Bluetooth connection data to scan for the hardware or if there is some other approach. Can I get some guidance as to how I can auto-connect?
Once the device is paired you can initialize the communication with your app or Arduino at any point.
So in your case I believe the best way would be to let the arduino initialize the communication with the app once you detect the car starts driving. The phone would have no idea when that happens according to the setup you described above.
To get an idea of how to use Bluetooth in your app (as always) you should have a look at the Android developer website.
Here are some links to get you started:
BluetoothAdapter: Can help you create a socket that listens to other devices ( BluetoothServerSocket)
Basic bluetooth

Android: bluetooth listen thread for incomming data only

i am working on an android app in which I need to only listen for incoming devices an log the data they are sending using Bluetooth, device sending data is basically a digital Bluetooth enabled thermometer which just sends the data. Problem is i don't know where to start as i m new to android programming. Just a step by step Procedure would be enough to guide me on the right track . i tried Bluetooth chat example but i didn't took me any where also i wasn't able to understand it.
Regards,
Rafiq Ahmed
First thing you need is to know how to make the connection with the thermometer. I suppose that, since the device is paired to the smartphone, you only must to manage the connection as a server (On the android-phone). Here you got a summarize:
Change Bluetooth permissions:
http://developer.android.com/guide/topics/connectivity/bluetooth.html#Permissions
Enable and set up the bluetooth: http://developer.android.com/guide/topics/connectivity/bluetooth.html#SettingUp
Find the device: http://developer.android.com/guide/topics/connectivity/bluetooth.html#FindingDevices
Connect with it: http://developer.android.com/guide/topics/connectivity/bluetooth.html#ConnectingAsAServer
And manage the connection:
http://developer.android.com/guide/topics/connectivity/bluetooth.html#ManagingAConnection
And last thing, I recommend you to pair the device before running the application, at the adjust menu of your mobilephone. Since that, follow the previous steps and all will be fine. If you have some doubt ask me, I had the same troubles about bluetooth connections with arduino and HC-06 bluetooth device
Hope it helps

Appliance Remote Control

I like to do a project based on android.I like to create an application for controlling lights in a room.My doubt is whether I can control those lights from anywhere using the androiod phone or it can only be controlled through USB cable or via bluetooth.If it can be controlled from anywhere how does the ADK board works,specifically how it transmits he data to the phone?
If the controller has a bluetooth radio SPP module (like a connectblue bluetooth to serial adapter) on it, then you can connect your phone's bluetooth to it, open a communication socket and send serial data between the phone and the controller board. No internet and no web server needed. Of course, this only works if your phone is in range of the controller (say, less than 10 to 30m)
To control the light from far away, then you need to connect each device (controller and phone) to the internet. You do not need to do it with a web server (though you could if you wanted) You can communicate data across the internet however you want, using whatever transport protocol best suits your purpose.
You could make it with a Arduino Board. Its Developt with C/C++. It's perfect for Android you will found many Tutorials
Everything communicates through a web server, somewhere. You'll have to have your hardware connected to the internet somehow, and your custom device can communicate with a phone through C2DM, or maybe a REST API or something. Bottom line is, you'll need a web component.

How to pair and connect to a headset

How can I connect and disconnect to/from a headset bluetooth device programmatically?
The application should work for Android 2.1+
In other words: I have a headeset. I can pair, connect, disconnect to it using Settings/Wireless and Networks/Blutooth Settings.
But how can I do all those things (pair, connect, disconnect) from my program?
Please chech this link.
The android bluetooth example (already listed) has a bunch of issues (not the least of which is you need 2 android devices to get it to function).
Take a look at the example at http://luugiathuy.com/2011/02/android-java-bluetooth/ where he is using bt on the android device to hit a server (to do some robotics work).
Be aware of UUID issues (the way that BT decides what connection it can make is defined in the UUID), and check out http://www.avetana-gmbh.de/avetana-gmbh/produkte/doc/javax/bluetooth/UUID.html
Keep in mind that the 16 bits represented in the UUID (ie, 0x1101 for Serial Port) is misleading in that its really the least significant part and needs to be coded 0x00001101.

Categories

Resources