Search Unity

How to send a string from Arduino to a Hololens game via Bluetooth?

Discussion in 'VR' started by VGFan95, Feb 20, 2017.

  1. VGFan95

    VGFan95

    Joined:
    Feb 18, 2017
    Posts:
    7
    Hello,

    I have been working on a game that involves sending a string of text over Bluetooth from an Arduino Uno Rev 3 to the game.

    Up till now, I had been doing all the testing in the editor, and retrieving the string of text by using Uniduino.

    Unfortunately, Uniduino uses the System.IO.Ports namespace, which isn't available on the Windows Store App platform. Thus, when I try to Build my game for deployment to the Hololens device, rather then testing in the editor, i get the error "The type or namespace name 'SerialPort' could not be found".

    Has anybody been able to read data from Bluetooth in their Hololens / Windows Store App game?

    Any help is appreciated,

    Thanks
     
    Last edited: Mar 16, 2017
  2. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    VGFan95 likes this.
  3. VGFan95

    VGFan95

    Joined:
    Feb 18, 2017
    Posts:
    7
    Thanks, I'll look that article over. Might be too advanced for me to understand what's going on but i'll give it a shot.
     
  4. Hodgson_SDAS

    Hodgson_SDAS

    Joined:
    Apr 30, 2015
    Posts:
    123
    @Unity_Wesley I'd have probably pointed to that article myself haha.
     
  5. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    You did in the forum post linked above, making sure to give credit were credit is due. :)
     
  6. VGFan95

    VGFan95

    Joined:
    Feb 18, 2017
    Posts:
    7
    Ok, I think that post got me on the right track. I managed to get a non-Unity app on the Hololens read the BLE data.

    The tutorial I followed is found here: www.simplicity.be (blog), and the code for it found on GitHub here. I'm using an Arduino Mega 2560 and a RedBearLab BLE Shield.

    The problem I am having now is that I don't know how to translate that tutorial into Unity.

    Mainly, I think the issue is that the example uses the UniversalBeaconLibrary and I don't know how to allow my Unity WSA to use that library.

    Any ideas?

    Thanks.
     
  7. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    Here is the documentation on plugins
    https://docs.unity3d.com/Manual/Plugins.html

    You need to add the dll to your project, and have a separate folders for each platform you want to have. Example is a plugins folder then inside that folder have editor, x86, etc... then have a copy of the dll with the proper settings for each platform inside those folders.

    Here is an example pic
    upload_2017-3-13_14-45-42.png
     
    VGFan95 likes this.
  8. VGFan95

    VGFan95

    Joined:
    Feb 18, 2017
    Posts:
    7
    That did the trick!

    Thanks for your help!
     
  9. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    Your Welcome! :)