Uduino is a Unity plugin which allows to communicate easily between Arduino and Unity.
Uduino aims to be a comprehensive and easy to setup solution for your Arduino/Unity projects, allowing you to communicate in both side (Arduino->Unity and Unity->Arduino).
It works efficiently across all operating systems, with a reliable serial connection and features exemples and a simple API.
Control your Arduino board directly with editor(even in pause mode !), with an advanced inspector panel. This Asset is made both for Designers, Hobbyist who wants to have things done quickly or professional who wants to have an advanced, stable and reliable connection.
An easy and fast way to read and write data from Unity ↔ Arduino
Advanced Inspector panel, allowing you to debug even in pause mode !
More than 10 Examples with the package
Arduino Library for an optimized and advanced use
Convert your existing Arduino code to be compatible with Uduino infew lines
Compatible with different Arduino board
Optimized serial connection to not drop the frame rate (Threads)
Purpose & Target
This project was created after too much frustration on how to properly connected Unity & Arduino. During past past experiences I was facing some problems: frame rate drop when communicating with serial ports, freeze and crash, difficulties to detect a specific Arduino board when several are connected, and many more.
All existing projects mixing Arduino and Unity where either not cross-platform, too complex and complicated (using Firmata to control a LED !? Hell no! ), not compatible with other libraries libraries or simply not stable enough. What we really need is a simple Arduino file and simple c# functions to read analog pin or write instructions.
How simple ?
Upload the Arduino Code
Press Discover Ports
That’s it ! you can now control your Arduino from the panel
As I told in the first message, I need some testers and feedback.
I could test this program only on 4 computers, which is not enough to be sure it’s stable. I also tried with few arduino boards, but not all of them.
after importing “uduino.unitypackage” I got an error:
“Assets/Uduino/Scripts/UduinoManager.cs(19,17): error CS0234: The type or namespace name Ports' does not exist in the namespace System.IO’. Are you missing an assembly reference”
But Uduino-master project from GitHub works just great!
So far I have tested 2 different workstations (both Windows10 64bit) and 2 arduinos together (2 x simple read: UNO + MEGA). It was very easy to get 2 inputs from 2 different arduino boards, uduino found the correct ports automatically without any issue !!
Also I wanted to test Arduino DUE but it seems uduino library has a errors and cannot uploaded on the Due:
“In file included from C:\Users\Martin\Desktop\sketch_dec01da\sketch_dec01da.ino:1:0:
E:\Programme\Arduino\libraries\Uduino/Uduino.h:51:30: fatal error: SoftwareSerial.h: No such file or directory #include <SoftwareSerial.h>
^
compilation terminated.
exit status 1
Fehler beim Kompilieren für das Board Arduino Due (Programming Port).”
For the error The type or namespace name Ports' does not exist in the namespace System.IO’, it’s a known issue which can be solved easily: You need to change your project API compatibility (Located under *Edit\Project Settings\Player )*from .NET 2.0 Subset to .NET 2.0. I added this on the github page.
I tried on arduino DUE and it seems to work here. Does you Arduino IDE is updated ? There was a issue with SoftwareSerial on previous Arduino version.
Hi @marcteys ,
I have a problem with reading and writing from/to one arduino at the same time. It seems writing disables the read function?! If only read or only write function (C# script inside unity) is active everything works just fine (read: sensor A0, write: pin13 onboard LED). If both functions are active, reading does not work anymore.
ReadWriteSensor.ino:
#include<Uduino.h>
Uduino uduino(“myArduinoName”); // Declare and name your object
void setup()
{
Serial.begin(9600);
pinMode (13, OUTPUT);
uduino.addCommand(“mySensor”, GetVariable); // Link your sensor reading (called “mySensor”) to a function
uduino.addCommand(“SetLight”, SetLightValue); // The function to be executed when we receive the value from Unity
}
void GetVariable() {
Serial.println(analogRead(A0));
}
void SetLightValue() {
char *arg;
arg = uduino.next(); // The arg char buffer is read and stored
uduino.readSerial(); // …then process Uduino. /!\ This part is mandatory
}
void loop()
{
// if (Serial.available() > 0) // verify if the serial is available…
uduino.readSerial(); // …then process Uduino. /!\ This part is mandatory
}
Probably I’m doing something wrong, could you please give me some hints to get it to work?! Any ideas how to read and write at the same time or after each other?
Maybe you already have a simple example to show how to use read and write to the serial port?!
I am doing quite a big refactor of the project those days, so be sure you updated your code to the last version, available on Github. I think your problem have been resolved, if not PM me.
For the final release on the play store I am also writing a full documentation with clear examples, new features and maybe video tutorial ! Everything will come in the next few days/weeks
During all this months without updates, I built a website , with tutorialsand a complete documentation!
More information can be found in the first message.
And also, get started easily with this quick-start video :
I have an Android build that runs through an Android TV box that gets inputs from a table hockey game. I want to connect the Android box to an Arduino and send all the outputs and inputs to and from Unity with the Arduino. Will Uduino work in an Android build?
I didn’t tested with Android support , but it might work. Let me try it first, before getting Uduino.
In the next version I planned to have Android support and wireless (esp8266) support.
Edit: It is not working currently and requires more work, but it will be working at some point soon.
I refactor most of the code and it took me a lot of time. Now Uduino can support “extensions”. You’ll be able to develop seamlessly on your desktop and android. These extensions include:
Arduino to Android communication via Serial
Arduino to Android communication via Bluetooth LE
Playmaker support
I’m still finishing some Interface elements and completing the documentation before releasing it publicly, however I might consider doing a beta-test soon.
Ah great, that’s good to hear. I’m not personally bothered about PlayMaker, but reliable read/writing between Android and Arduino is giving me way more headaches than I anticipated! Doing it using PC was trivial, but enumerating the available serial ports on Android seems to require a rooted device from what I’ve researched so far - have you managed to write a plugin in such a way to avoid this?
Do please keep me informed when you’re closer to release or if you need any testers for the beta!
Uduino for Android will automatically find the board connected to your phone.
I am currently beta-testing Uduino for Android (both Bluetooth and OTG), let me know if you want to be part of it !