Arduino and Unity: Talking!

In the last update, I used a free app called Bluefruit LE Connect to facilitate the wireless communication between an iPhone and an Arduino over BLE. It’s a great little app for testing and you could conceivably use it in your project if you don’t require a custom interface, but if you need more control over the software side of things, you’re going to want to write your own app. For me, I’m ultimately curious about having a game talk to custom hardware so I made my next goal to develop an app in Unity that talks to Arduino through BLE.

Unity doesn’t have any native, built-in methods to handle BLE connections – but fortunately, that’s where the Unity Asset Store comes in. I found a great package called Bluetooth LE for iOS and Android. It’s lightweight, has clear examples and well written documentation, but it’s the developer support alone that makes the $10 a complete steal. Here’s why: testing BLE is cumbersome. It’s not something you can simulate in the Unity IDE so you end up having to create a build each time you want to try something out on the mobile device. Each time Unity compiles to Xcode, it recompiles everything, so you end up having to sit through ~5 minute builds each time you’re fumbling around trying to find that one line of code that might be wrong. I was banging my head against the wall several times but Tony patiently looked at my C# scripts + Xcode logs and helped clue me in on more than one occassion. Do check it out!



13 thoughts on “Arduino and Unity: Talking!

  1. Hi,

    Great setup you have there! I am trying to do something similar with my Samsung gear VR. I am pretty new to programming and I just started learning Unity. I am trying to make my Unity android program talk to the Arduino/PC via Bluetooth. I would appreciate it if you could help me out with the setup.

    Thank you.

      1. cant connect to the BLE….
        im using HC-06
        and with what you have provided unable to understand a thing

  2. Hi i purchased the assets. I using a bluno nano at the moment. I am able to pair it with my android phone. however i have still yet to send data from my bluno to the unity app. May i ask how do you do it?

  3. Hi, I just bought this plugin and got it to connect my app to a bluefruit m0, but I don’t know what to do from here (how to make the two talk) so I wanted to ask how to send and receive data in your unity app or if you can share your script in unity. I have no idea what serviceUUID or charactersticUUID are or where to get them, if I use writeCharacteristic it says ‘Service not found for Write’ so I’m really lost here.

  4. Hi there, I’m doing the same thing but need some of your help.
    I’m using adafruit feather M0 and a piezo to send signal in serial port. Then I download the asset for bluetooth, I ran the example, I can easily connect to my device. But my problem is that I don’t know how to read the signal in serial port like you did, what did you do?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s