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
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.
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!
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 !
@gaofei7439 Thatâs weird. I did the same setup as you and this is what I got:
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 @ .
I am testing some arduino + blueprint codes without success so far and I kindly ask for help.
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!
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.
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).
This is the code for my basic arduino 4xrelay board. I use a baut rate (arduino and Ue4) of 1200, seems enough to me. What ever I write to the serial it gets parsed as a integer (ParseInt). So⌠when I write 10 to the serial relay 1 gets switched off. When I write 11, relay 1 gets switched on. same for 20 21 30 31 40 41. There is no trickery just write according to the docs to the serial port. Works absolutely perfect for me and a big thanks to the creators of this plugin and Ue4. Hope it helps someone.
The Code:
// Basic 4 Realy board connection
// Each relay is turned on and off when sending 10 11 20 21 30 31 40 41
// You can here them click as there state changes from off to on and on to
// off.
// You will also see the corresponding Red LED on the 4 Relay board
// light up when the relay is on.
// define names for the 4 Digital pins On the Arduino
// These data pins link to 4 Relay board pins IN1, IN2, IN3,IN4
#define RELAY1 6
#define RELAY2 7
#define RELAY3 8
#define RELAY4 9
long mydata = 0;
void setup()
{
// Initialise the Arduino data pins for OUTPUT
Serial.begin(1200);
Serial.setTimeout(10);
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(RELAY4, OUTPUT);
}
void loop(){
while (Serial.available() == 0) {}
mydata = Serial.parseInt();
if (mydata == 10){digitalWrite(RELAY1,LOW);}
if (mydata == 11){digitalWrite(RELAY1,HIGH);}
if (mydata == 20){digitalWrite(RELAY2,LOW);}
if (mydata == 21){digitalWrite(RELAY2,HIGH);}
if (mydata == 30){digitalWrite(RELAY3,LOW);}
if (mydata == 31){digitalWrite(RELAY3,HIGH);}
if (mydata == 40){digitalWrite(RELAY4,LOW);}
if (mydata == 41){digitalWrite(RELAY4,HIGH);}
}