UE4Duino - Arduino to UE4 plugin Release!

UPDATE!

UE4Duino 2.0

First of all, thanks a lot to @ for saving me time on understanding how to use serial ports on C++ in Windows!
I’ve rewritten the plugin from ground up, but wanted to keep 's credits for the name and his initiative.

The zip below contains binaries for UE 4.14.0, but it should compile successfully since 4.11. Maybe even lower.
Download:

Attention: if updating it on an existing project, beware! You’ll need to change some stuff as it now works on instanced variables instead of a static connection.

USAGE

  • You can use the Construct Object From Class node to create an instance of the Serial class and use the Open COM function to start the connection.
  • Or you can use the static function Open COM Port, which will create the instance and open the port for you. Just remember to store that instance in some variable to use later!
  • ALWAYS call Close COM before quitting the game (like on Event End Play). If you fail to do so, you won’t be able to reopen it unless you reconnect the device to the PC.
  • For now, you have to check for input on Tick. Whatever kind of input you read for, it’ll return Success=true if there was input. But I intend to create a thread just for checking and notifying input changes with events.

CHANGE LOG

  • Code is more Unrealish: hide windows platform types; switch from TCHAR] to FString; use *FMemory *methods; *int32 *instead of int; *bool *instead of *BOOL *etc.
  • Works with COM10 and above. (If you change your COM to test it, you need to reconnect the device).
  • Condensed everything into a single class: Serial.
  • Not threaded. Reading when there’s no data to read will return instantly. When reading serial inside Arduino code, remember to use Serial.setTimeout(10) on the setup function, so the Serial.readStringUntil (and other functions that interpret a group of bytes) return faster.
  • Added functions to read and write numeric data types (float, int, *byte *and byte array). On the Arduino side you must know how to convert byte arrays from/to these types.
  • Added ability to read Strings by line or whole string found in serial.
  • Added ability to work with more than one Arduino (COM) simultaneously. The class works with instanced objects instead of static variables.
  • It packages successfully (tested on Development and Shipping modes).
  • Changed logo and “Creator” on plugin description as I mostly rewrote it. But kept the name as it’s very nice and @ deserves its credits for starting the thing. Hoping he won’t mind much.

[/QUOTE]

Hi, RVillani, thank you so much for your work! I’ve been successfully using your previous plugin on 4.10 version. It works great and it is really helpful!

Now I have new challenge - I have to filter input signal (I have C++ code for the filter) however I don’t understand how I can implement it in this plugin. I started learning how to program C++ in UE4 but I still don’t see a link between your amazing plugin in blueprints and C++ class. Do you have any ideas how this can be done?

UPDATE!

UE4Duino 2.0

First of all, thanks a lot to @ for saving me time on understanding how to use serial ports on C++ in Windows!
I’ve rewritten the plugin from ground up, but wanted to keep 's credits for the name and his initiative.

The zip below contains binaries for UE 4.14.0, but it should compile successfully since 4.11. Maybe even lower.
Download:

Attention: if updating it on an existing project, beware! You’ll need to change some stuff as it now works on instanced variables instead of a static connection.

USAGE

  • You can use the Construct Object From Class node to create an instance of the Serial class and use the Open COM function to start the connection.
  • Or you can use the static function Open COM Port, which will create the instance and open the port for you. Just remember to store that instance in some variable to use later!
  • ALWAYS call Close COM before quitting the game (like on Event End Play). If you fail to do so, you won’t be able to reopen it unless you reconnect the device to the PC.
  • For now, you have to check for input on Tick. Whatever kind of input you read for, it’ll return Success=true if there was input. But I intend to create a thread just for checking and notifying input changes with events.

CHANGE LOG

  • Code is more Unrealish: hide windows platform types; switch from TCHAR] to FString; use *FMemory *methods; *int32 *instead of int; *bool *instead of *BOOL *etc.
  • Works with COM10 and above. (If you change your COM to test it, you need to reconnect the device).
  • Condensed everything into a single class: Serial.
  • Not threaded. Reading when there’s no data to read will return instantly. When reading serial inside Arduino code, remember to use Serial.setTimeout(10) on the setup function, so the Serial.readStringUntil (and other functions that interpret a group of bytes) return faster.
  • Added functions to read and write numeric data types (float, int, *byte *and byte array). On the Arduino side you must know how to convert byte arrays from/to these types.
  • Added ability to read Strings by line or whole string found in serial.
  • Added ability to work with more than one Arduino (COM) simultaneously. The class works with instanced objects instead of static variables.
  • It packages successfully (tested on Development and Shipping modes).
  • Changed logo and “Creator” on plugin description as I mostly rewrote it. But kept the name as it’s very nice and @ deserves its credits for starting the thing. Hoping he won’t mind much.

[/QUOTE]

Hi and @,

Thanks for all the good work. I’m using this plugin to build a controller to interface with tablets using a serial port from an embedded microcontroller. I initially build it with the initial version of the plugin but was having issues when COM ports were being selected above 10 and with crashing so I decided to give 's build a go. When trying to utilize the *Read Line *command, the Terminator byte in the C++ code is a single ’
’ character. However, the Serial.println() command uses the
characters to indicate a new line. This is a vestige of the old mechanical typewriter days when they’d have to return to the left-hand side of a page before skipping to a new line. So when we pass a string to the UE4 side of things we terminate the string at ’
’ and leave the ‘\r’ at the end of the string being passed. This is a bit of a nuisance in Unreal as we cannot directly insert a line break string literal a string in UE4. Thus, we can’t compare the data read directly over the serial port with a string literal as what we read has a \r at the end and a string compare won’t.

My workaround has been to the kind solutionof with ‘\r’ inserted, in my case, instead of ’
'.

In the above image, the Make Literal String node actually delimits the string using the ‘\r’ character which allows me to succesfully compare the string to what’s being passed over serial.

Perhaps this change can permanently make it’s way into the next set of changes by using ’
’ as a multi byte terminator or just using the ‘\r’ as the terminator for when reading from Serial.println().

Thanks again

Would this plugin work to save data of temperature and humidity on MySQL with Arduino?

hi, so im having a bit of a problem figuring out how to read the values of two potentiometers in unreal. I have one to control yaw and the other to control pitch. I am sending the values one after another but i dont know how to read them one by one in unreal to control both yaw/pitch independently.

The picture of my blueprint just shows how i am reading the output from the arduino when i am ONLY sending the yaw value. I have my pitch value commented out as of now until i figure out how to properly read it. My blueprint works just fine for reading one value but any help with how implement the other would be greatly appreciated.

did you solved the problem? Now I met the same trouble.

figured it out ! In my code for arduino i sent a string value to represent yaw right before sending the yaw value and sent a string value to represent pitch followed by the pitch value. so my serial data would send like :

y90
p45
y66
p22

(the numbers are arbitrary values to represent the pot value)
inside unreal engine i would split the string after each letter and send the corresponding data to the right event. If a “y” was found in the first position it would send the pot value to the controller yaw input and vice versa if “p” was found for pitch input.

have you solved the problem? I Met the same trouble; On the arduino side, I sent the string . On the Ue4 side , I am sure UE4 has received something ,but thiere is nothing to display

hello there

I know its too late but wanted to ask , does this plugins works with 4.14 ?

Hi! Where are you getting the arduino node from?

Hello,

Great work on this plugin, and keeping up the fantastic work
Will this be updated to 4.15 anytime soon, or is it possible you could release the project ?

Thanks in advance

UE4Duino Update

Hello,

Thanks for all the great work keeping this Plugin updated, I hope you don’t mind, but i have had a go at updating to 4.15, i have it working but would like it if someone else from the community could test to confirm this works
Its a first time in C++ for me, normally C# but wanted to have a go

://goo.gl/dCBBaI

Thanks

so this is basically programming an arduino without coding. or otherwise said programming an arduino via blueprint???

Hi!
I decided to get back to my project with UE4 and Arduino, and found some updates here =)

Firstly thanks a lot to for the real great job!

My first question is to :
Is it possible to implement in your plugin ability to remove “\r” and "
" commands and split the whole string to several according to this received commands? Like it is in Arduino IDE Monitor. In version by @ there were no commands like this, only data.

Also I already wrote about recompiling this plugin to different versions of UE4, so just to repeat:

  1. Create new project in UE4.1x
  2. Add new C++ class (None->next)
  3. Save project
  4. Close it
  5. Create folder “Plugins” in the project folder and put here UE4Duino plugin
  6. Open again your project and UE4 will ask you to recompile UE4Duino plugin - you should press YES.
  7. When recompilation will be done, you can close UE and copy UE4Duino from that project to other project. It will work.

Please Note the you have VS2015Community (://www.visualstudio.com/downloads/) and Windows SDK for your version of Windows(://developer.microsoft.com/en-us/windows/downloads/sdk-archive) to be installed.

This plugin allows you to link up an Arduino via Serial to a UE4 project, and send data both ways,
with a BP set up and Arduino sketch you could press a make a pin go High on Arduino and operate something in BP ? also if you had a button in BP you could control something on your Arduino

Hi @yuliia.sergeeva,
Found your question without the answer.
Of course you can, check for Node “Parse Into Array”, use any symbol as delimiter and you will get an array of any number of values you want

Hi @Stupzow

Hope you can help,

I can write a string from UE4 and have it recognised in the Arduino without problem, but im having difficulty in getting the Arduino to send a string up to UE4 and compare in order to do something

For example, i have a pin2 go high on the Arduino i want a string “P2HIGH” sent up to UE4 and print a message on screen ?
i can get the string up to UE4 but how can i determine if the string is correct ?

I have tried to use “String == String” BP node but cant seem to get it working ?

Any help would be greatfull

Thanks in advance

Found a solution :slight_smile:

Hey! So, I’m having trouble figuring out where exactly to start. I’ve been trying to figure out how to use 6 flex sensors and an absolute orientation sensor for control in a game a friend and I am creating. I am extremely new to arduino. Like I only aquired one recently. Do any of you have any advice on where to start or some good tutorials to watch/read?

Thank you so much!Great work :smiley:

Hello guys,

I’m currently working on connecting two Arduino simultaneously. So I installed new version of ue4duino and i have problem with output of Arduino inside Unreal Engine. The serial monitor of arduino shows that everything is ok and my potentiometer works fluently. Inside UE4, values are freezing or working with huge delay, or working for some time and freezing.

My script is below
My blueprint is classic - as posted above.

Thank you in advance

int val2,val3,val4 = 0;

void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
{
val2 = analogRead(A2);
val3 = analogRead(A3);
val4 = analogRead(A4);
Serial.print(val2); Serial.print(‘,’);
Serial.print(val3); Serial.print(‘,’);
Serial.println(val4);
delay(1);
}