开发者

How can I create a Bluetooth serial connection between an iPhone and an Arduino+Bluetooth Mate?

I have a project where I need my iPhone to communicate with an Arduino. Bluetooth seems like the best 开发者_如何学Gooption for the communication. How should I program my iPhone (what framework?) to communicate with the Bluetooth Mate or do Apple's restrictions prevent this? Is it possible with a jailbroken iPhone? Is there a better way other than Bluetooth? Sample code would be helpful.

Thanks in advance


Actually you can make it happen now without Jailbreaking or MFi enrollment.

Take a look ate Bluetooth 4.0 in newer iOS devices and Arduino BT 4.0 shield.

This might help: http://blog.makezine.com/2012/03/19/bluetooth-4-0-from-arduino-to-iphone-no-jailbreaking-no-mfi/


Meanwhile there is an Arduino shield available from Seeedstudio: Bluetooth Low Energy Shield

Devices following the Bluetooth 4.0 specification can be accessed by all iPhone/iPad models with a Bluetooth 4.0 chip inside (currently iPhone 4S, 5 and iPad 3) running with iOS 6. You no longer need to be part of the MFI program or jailbreak the device for most purposes. Use the Core Bluetooth Framework that's also discussed in the WWDC 2012 videos Core Bluetooth 101 (Core OS) and Advanced Core Bluetooth (Core OS).


It's been a while since I was in contact with embedded bluetooth-to-iphone devices, but as far as I remember you have to buy authentication chips from apple.
Apple MFi

But as jailbreak is an option this might work. But I never tried this, because I once was in possession of some authentication chips.

I found btstack with a quick googling, maybe it's helpful.


Try instaling bluetoth iBlueNova, and it will comunicate with each device.


Yes, the best way to do this would be to use Blynk. Make an account, copy the example code, and get started with the Blynk app!


Apple's OS app sandbox prevents generic (Classic non-BLE) Bluetooth serial data comm on stock OS devices, except for a few companies registered in their MFi program.


The most reliable and possibly the easiest solution is to the use the Arduino Ethernet shield with a physical network connection to your WiFi router. The Arduino would host web pages or respond directly to http that did your work for you.

No jailbreaking, no BT programming, no serial com port stuff. Just regular old web pages. Sweet stuff.

The simplest solution would be to navigate with any browser on your network, including your iPhone, to your Arduino and issues commands.

Example:

http://192.168.1.101/?1

192.168.1.101 = the IP of your Arduino

?1 would mean PIN13 pulled high (i.e. turn on the LED)

Your code would be something like:

EthernetClient client = server.available();
while (client.connected())
{
    if (client.available()) 
    {
        char cVar = client.read();
        if (cVar != '?') return;
        Serial.Print(cVar)
        if (cVar == '1') digitalWrite(13, HIGH); //turn on the led
    }
}

That code is quick and dirty so don't hold it against me!

Let me know what you decide and how it works out. I need to go read up on http://blog.makezine.com/2012/03/19/bluetooth-4-0-from-arduino-to-iphone-no-jailbreaking-no-mfi/

Thanks for that link ygbr!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜