Download

[Free][Windows only] UE4Duino 2 - Arduino (COM port) communication

Use this plugin to communicate with Arduino or other COM port devices on Windows.

The GitHub page contains the source code and binaries. I try to keep it always updated with latest Engine Launcher version.

UE 4.16 binaries download
UE 4.17 binaries download
UE 4.18 binaries download
UE 4.19.2 binaries download
UE 4.20.3 binaries download
UE 4.21.1 binaries download
UE 4.22.0 binaries download
UE 4.23.1 binaries download
UE 4.24.1 binaries download
All releases here.

How to use it
Create a Plugins folder in your project directory. Place the folder UE4Duino (the one that contains Source, Resources etc) in the Plugins folder.

You can use the Open Serial Port function and store the result in a variable

Or create the Serial object yourself and open the port afterwards

Either way, never forget to call ClosePort on the Serial instance before quitting the game. EndPlayEvent is a good place for that. If you forget to do it, you’ll have to unplug the Arduino (or other COM device) from the PC and plug it back.

You can set the type of line endings used with the WriteLine function.

There’s an example Arduino script in UE4Duino/ArduinoTypesExample. It demonstrates how to send floats, ints and strings to Unreal.

Credits
Original version of the plugin was created by @gryzly32
Thread for first version here.

This is absolutely neat stuff. I love microcontroller, psd’s, and fpga’s. Well done.

Thanks! Me too! :smiley:
It’s awesome when you make your game control real life electronics, lights etc.

Hey, really cool project! I’m having trouble using it though. I’ve installed it by putting it in the Plugins folder, but when I go to add a node in a blueprint, I only have the function “Open Serial Port.” I don’t seem to have Close Port, Read, or Write. New to Arduino and UE4. Could someone please help me out? Thanks!

Hey, really cool project! I’m having trouble using it though. I’ve installed it by placing it in a Plugins folder and everything. My problem is, when I go to add nodes in a blueprint, it seems that I only have “Open Serial Port.” I can’t find a Close Port, Read, or Write. New to Arduino and UE4, so I would be grateful if someone could walk me through this. Thanks!

Promote it to variable and drag from that.

Look at the first example image. Promote the return value from OpenSerialPort to a variable. Than call the other functions from that variable.
If you don’t know how to do that, or what are instances and variables, you should study a bit more the Blueprint system and maybe some Object Oriented Programing too.

Important question: Everything works perfectly fine in the editor. When I build the “windows no editor version” the port doesnt open… tryed with a delay or keypress but the port doesnt open and on the download page there there are 2 download versions 2.2.1 4.16 and 2.2 4.16.1 which makes it a bit confusing what is the newest.

Anyway don’t get me wrong, the thing is perfectly documented and I had a 3 step Fan working in half a day so thanks a lot!

Hope you can help with how to open the port on a windows no editor build.

And this is the warning: LogPluginManager:Warning: Engine version string in D:/Gebruikers/Gebruiker/Nieuwe map - kopie (3)/Unreal Projects/arduino_1/Plugins/UE4Duino/UE4Duino.uplugin could not be parsed (“4.16”)

Did some research myself, I guess this link is part of the solution, at least I hope.

BTW: I use arduino to 4x relay and UE4 version 4.16.2

I’ve used it a lot in packaged games, so I know it works. Are you sure you’re opening the correct port number on the packaged version? Or that the game or the Arduino IDE is not still using the port when you try it? Do you close the port when closing the game?

2.2.1 is the latest. I removed the engine hotfix version because C++ APIs don’t change between major versions, so the hotfix version doesn’t matter.

Just add " .1" at the end of the version string. (4.16.1)

I am confused; I want to konow does this plugin suit for UE4 4.16.2 . I have tested this plugin on UE4.16.2 ,and I used the Arduino code of example , But On UE4, The BP did receice somthing ,but diaplay nothing. I am in trouble for a few days, can you give me some suggestions? Thank you !

Yes, it suits. I am using it myself in 4.16.2.
Show me the code you’re using in Arduino and the Blueprint part.

I created the Arduino code as follows:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.setTimeout(5);

}

void loop() {
// put your main code here, to run repeatedly:

  Serial.println("this is the new line ");
  delay(1000);

}

And In UE4(4.16.2) I created a bp_cube (is this style ok?);
1.png0f684ca71eca9ef72d6714b90b9cfd58d4a99ed1.pngc6dac25f5e139a1478b1922b6f8a707aa9ca94a5.png
This is my bp , When the program is runing , I pressed button L , from the ue4 ,I can see 663fe31cb310d490446700b02968c816be2cadc7.png , it indates it indeed receive some data ,but there is nothing display on the screen. and c7e109929241302db3fda2dcadb7b95bfa27adc1.png

can u tell me , how to solve it ? thank you

@gaofei7439 That’s weird. I did the same setup as you and this is what I got:
e5da7ad445ba14c54a50c003392704316a2f31fb.jpeg

Are you sure the Arduino code was uploaded to the Arduino board?
Or maybe there’s something else in your Blueprint consumig the characters by accident and ReadLine just works because it finds anything there, like the "
".

Is it worth adding whitelisted platforms to the plugin? For example “WhitelistPlatforms” : “Win64”, “Win32” ]

I have a Windows client acting as a server with the Arduino connection, but an Android app client that does not use but also can’t compile the plugin (can’t find AllowWindowsPlatformTypes.h )

Does this make sense or is there another way to compile an Android build when UE4Duino is included?

From what I found so far, WhiteList and BlackList doesn’t make a difference on compilation. The only way to make it not try to compile the plugin for Android is to remove the .uplugin file and re-generate visual studio project files, so it ignores the plugin completely. But then, if you are using it in other parts of the project, it’ll break your project. I guess you’ll have to do a project for PC and another separate one for the Android.

Hi all UE4Duino users and really thanks for your great work @RVillani .
I am testing some arduino + blueprint codes without success so far and I kindly ask for help.
1a0da90fd0d4730359c2d7d2f2dc9a3dc3dbc38d.png1ccf0a8b6faa0f7588dcc989390a2318f56884cd.png
Those images are my Arduino code and my blueprint code, I do not know what I am doing wrong my main goal is sending from UE4 string ON to Arduino and Arduino must read it and activate 2 digital pins.
EDIT: LogTemp:Error: Failed to open port COM3. Error: 00000006 this is what I have achieved, COM port is not opening neither working. Have tried so far, 3 differents usb ports + hub (2 ad 3.0).
Any help? Really thanks and best regards!

Hi UE4Duino users and tahnks for your great work @RVillani .
I am trying to achieve some Arduino code + Blueprint to be able to send a String ( ON ) from Unreal to Arduino activating and 2 digital pins. My codes are:

I have tested Event Tick, Any Key, and many different actions to see if any of them work without success so far. By the way output log do not show messages about port open or closed…
Any help would be appreciated. Regards!

I have my outputs printing to the serial on my Arduino, and I have a basic Blueprint set up, how do I get that data into the blueprint? There is a gap in the documentation that leaps over that entire step.

I have been trying to get this to work for some time, not having any success. I have my Arduino outputting a stream of 1’s and 0’s depending on a button state. Using the serial monitor I can see that everything is working properly and that the output is clean and as expected. The issue I am having is getting that data into the blueprint. I want to use the input ‘1’ to change the flicker speed of a light to .2 and I want ‘0’ to reset it to the flicker speed of 1.0. I am not sure exactly how to do this within the Blueprint editor however.

Icon128.png

This was an educated guess on how it might work, but I really don’t know. If “Selection” on the ‘Switch on Int’ node is set to 0 or to 1 the result is as expected however apparently I am either not getting the data into the blueprint, I am not handling it properly, or both. One thing to note is this is a constant stream of data, should I base it off of the Event Tick instead? Any thoughts?

Edit: One other note, is that the serial port IS indeed opening, and the flow goes all the way to the end through the ‘0’ option. This is regardless of value however, and only happens once. I need the value to be read properly and for it to repeatedly check the value and update it.

@jwsargent.me Why are you using LineEndToString?!?! It’s description says “Converts a LineEnd enum value to String.” It has nothing to do with reading data from Arduino. You want to use ReadByte, to read the next 0 or 1 from the Arduino. Right after it use FlushPort. Because if you don’t and Arduino is sending data faster than Unreal is reading it (once at each frame), Unreal will start to get late in relation to Arduino.

Also, how are you sending the data from Arduino? If it’s using printl, forget it. That sends the numbers as characters, with line ends and ReadBytes will read each char of that message as a byte (not 0 and 1). So try using Serial.write(1) (or 0).