# \[FREE\] ArduinoKit - Cross Platform Arduino Plugin for UE4

**URL:** <https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362>\
**Category:** Plugins\
**Tags:** unreal-engine\
**Created:** [August 1, 2016, 1:32am UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362 "2016-08-01T01:32:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![valentegamedev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/valentegamedev/32/1068844_2.png) [@valentegamedev](https://forums.unrealengine.com/u/valentegamedev)\
**Post date:** [August 1, 2016, 1:32am UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/1 "2016-08-01T01:32:24Z")

</div>

**New version available!**

Hello all,

I’m working in some 4D projects that we need to interact with arduino to control external hardware… So, I made this plugin to help in my projects based on the serial library by Teunis van Beelen ([RS-232 for Linux and Windows](http://www.teuniz.net/RS-232/))

Its serial communication works in **Windows, OSX and Linux**.

The code is available at: [Bitbucket](https://bitbucket.org/danielvmacedo/arduinokitue4)

Just clone the repo and copy the “ArduinoKit” folder inside “Plugins” to your own “Plugins” folder.

I hope that it can be useful for some people.

Here are the nodes available:

 ![ArduinoKit.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/0/0098dbbd517e9691146e02d86669c4b5bd63125b.png)

For the port name, you need to write the full path, for example:

Windows: “COM3”  
OSX: “/dev/cu.usbmodem1421”  
Linux: “/dev/ttyS0”

**Windows users only:  
ports higher than “COM9” need to be on this format: “\.\COM10”, “\.\COM11”, “\.\COM12” and so on…**

**Info:**

- The **Read Text Node** pops the last string that was read from arduino. **If nothing is found, it will return a blank string**.

- The **Get All Available Texts Node** will return the whole stack of strings that was read from arduino. The last one is the most recent. After you call this node, the stack is cleared.

- All strings sent from arduino \*\*must \*\*have the ending character “/n” or use Serial.println () instead of Serial.print().

- The **Open Node** now tries to close any previously opened connection.

- The **Open Node** have a new input parameter that is the size of the stack that will hold all strings read from arduino. If it is filled, it will discard the oldest one and push the new one on the top of the stack.

Cheers

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d7cbf4ea](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d7cbf4ea](https://forums.unrealengine.com/u/anonymous_user_d7cbf4ea)\
**Post date:** [August 2, 2016, 9:38am UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/2 "2016-08-02T09:38:09Z")

</div>

Hi!  
I tested it and it basically works! Thanks. But I found a strange behaviour. If I print the String from the “Read Text” Node it looks alright, but as soon, as I try to convert this string to a float or int, the Values start to strangly jump around. Maybe the string is not correctly formated as it should be in unreal. I tried some conversions, but nothing fixed it.  
Can you tell me how I can get a simple float send with the an arduino code like

float variable;  
Serial.println(variable);

to be correctly stored into a float variable inside the unreal engine?

Thank you very much!

P.S: In the UE4Duino Plugin this woked without any problems. I am using win10 Unreal and Engine 4.12.5

---

<div class="post-metadata">

**Author:** ![valentegamedev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/valentegamedev/32/1068844_2.png) [@valentegamedev](https://forums.unrealengine.com/u/valentegamedev)\
**Post date:** [August 2, 2016, 10:38am UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/3 "2016-08-02T10:38:47Z")

</div>

> [@Appsite GmbH;574484](#):
>
> Hi!  
> I tested it and it basically works! Thanks. But I found a strange behaviour. If I print the String from the “Read Text” Node it looks alright, but as soon, as I try to convert this string to a float or int, the Values start to strangly jump around. Maybe the string is not correctly formated as it should be in unreal. I tried some conversions, but nothing fixed it.  
> Can you tell me how I can get a simple float send with the an arduino code like
> 
> float variable;  
> Serial.println(variable);
> 
> to be correctly stored into a float variable inside the unreal engine?
> 
> Thank you very much!
> 
> P.S: In the UE4Duino Plugin this woked without any problems. I am using win10 Unreal and Engine 4.12.5

Hello [MENTION=64722]Appsite GmbH[/MENTION],

the way my plugin works is a bit different. You will need to create a buffer holding the bytes until you have the whole string built. I just pushed a new code to the git repo actually removing the function ReadText() and adding the StringFromByteArray() to prevent others to try the samething you tried. The correct way using my plugin should be like this blueprint:

 ![Buffer.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/d/d/9dd6bedb31ba89989535441b1527370449896b08.png)

You create a array of bytes variable and use it as the buffer. Whenever you find a endingline character (byte = 10) you build the string and clear the buffer.

On the arduino side you can use this:

```html
float variable = 123.45;
Serial.println(variable);

```

or

```html
float variable = 123.45;
Serial.print(variable);
Serial.print("
");

```

The buffer example node is in the level blueprint on git repo.

I hope it helps!

PS: I’ll try to automate this step to read text whenever I get some free time 😉

Cheers!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d7cbf4ea](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d7cbf4ea](https://forums.unrealengine.com/u/anonymous_user_d7cbf4ea)\
**Post date:** [August 2, 2016, 11:40am UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/4 "2016-08-02T11:40:57Z")

</div>

Fantastic! That works like a charm now. 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1e5f0599](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1e5f0599](https://forums.unrealengine.com/u/anonymous_user_1e5f0599)\
**Post date:** [August 2, 2016, 4:20pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/5 "2016-08-02T16:20:55Z")

</div>

> [@danielvmacedo;573803](#):
>
> Hello all,
> 
> I’m working in some 4D projects that we need to interact with arduino to control external hardware… So, I made this plugin to help in my projects based on the serial library by Teunis van Beelen ([RS-232 for Linux and Windows](http://www.teuniz.net/RS-232/))
> 
> Its serial communication works in **Windows, OSX and Linux**.
> 
> The code is available at: [Bitbucket](https://bitbucket.org/danielvmacedo/arduinokitue4)
> 
> Just clone the repo and copy the “ArduinoKit” folder inside “Plugins” to your own “Plugins” folder.
> 
> I hope that it can be useful for some people.
> 
> Here are the nodes available:
> 
> For the port name, you need to write the full path, for example:
> 
> Windows: “COM3”  
> OSX: “/dev/cu.usbmodem1421”  
> Linux: “/dev/ttyS0”
> 
> **If you want to read strings ending with  
> from arduino, you need to create a byte buffer array like this:**
> 
> **Whenever you find a endingline character (byte = 10) you build the string and clear the buffer. 🙂**
> 
> Cheers

Really Great job !!  
I need help, i have a problem with read Bytes !! i used your example to print the readBytes but no msg !!  
(Im using 4.12.5 and win10 )

---

<div class="post-metadata">

**Author:** ![valentegamedev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/valentegamedev/32/1068844_2.png) [@valentegamedev](https://forums.unrealengine.com/u/valentegamedev)\
**Post date:** [August 2, 2016, 4:27pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/6 "2016-08-02T16:27:49Z")

</div>

@brownoo, can you post your code?

---

<div class="post-metadata">

**Author:** ![darthviper107](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/darthviper107/32/710746_2.png) [@darthviper107](https://forums.unrealengine.com/u/darthviper107)\
**Post date:** [August 2, 2016, 5:15pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/7 "2016-08-02T17:15:57Z")

</div>

If you could get this to support Android as well that would be amazing

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1e5f0599](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1e5f0599](https://forums.unrealengine.com/u/anonymous_user_1e5f0599)\
**Post date:** [August 2, 2016, 6:13pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/8 "2016-08-02T18:13:39Z")

</div>

> [@danielvmacedo;574652](#):
>
> @anonymous_user_1e5f0599, can you post your code?

this is my Code!! even my arduino not connected the wire from readbytes still red ☹ nothing print on my screen !

 ![Code.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/7/1/271e67ab24419491cd00cccd11ded625c00b0a4e.png)

---

<div class="post-metadata">

**Author:** ![valentegamedev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/valentegamedev/32/1068844_2.png) [@valentegamedev](https://forums.unrealengine.com/u/valentegamedev)\
**Post date:** [August 2, 2016, 6:41pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/9 "2016-08-02T18:41:34Z")

</div>

> [@brownoo;574699](#):
>
> this is my Code!! even my arduino not connected the wire from readbytes still red ☹ nothing print on my screen !
> 
> ![Code.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/7/1/271e67ab24419491cd00cccd11ded625c00b0a4e.png)

Very strange. That should work… can you send me how are you printing into the serial from arduino?

---

<div class="post-metadata">

**Author:** ![valentegamedev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/valentegamedev/32/1068844_2.png) [@valentegamedev](https://forums.unrealengine.com/u/valentegamedev)\
**Post date:** [August 2, 2016, 6:42pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/10 "2016-08-02T18:42:42Z")

</div>

@darthviper107 I’ll take a look on that! =)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1e5f0599](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1e5f0599](https://forums.unrealengine.com/u/anonymous_user_1e5f0599)\
**Post date:** [August 2, 2016, 6:47pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/11 "2016-08-02T18:47:17Z")

</div>

> [@danielvmacedo;574724](#):
>
> @darthviper107 I’ll take a look on that! =)

Thanks alot ^^ !!

---

<div class="post-metadata">

**Author:** ![valentegamedev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/valentegamedev/32/1068844_2.png) [@valentegamedev](https://forums.unrealengine.com/u/valentegamedev)\
**Post date:** [August 2, 2016, 6:55pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/12 "2016-08-02T18:55:20Z")

</div>

> [@danielvmacedo;574723](#):
>
> Very strange. That should work… can you send me how are you printing into the serial from arduino?

Try your blueprint with this code on arduino:

```auto

void setup() {
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  Serial.begin(115200);
  blink();
}
void loop() {
  delay(100);
  blink();
}

void blink() {
  digitalWrite(13, HIGH);
  delay(200);
  digitalWrite(13, LOW);
  delay(200);

  float variable = 123.45;
  Serial.println(variable);
}

```

Let me know if it works!

Cheers

---

<div class="post-metadata">

**Author:** ![valentegamedev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/valentegamedev/32/1068844_2.png) [@valentegamedev](https://forums.unrealengine.com/u/valentegamedev)\
**Post date:** [August 2, 2016, 7:08pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/13 "2016-08-02T19:08:37Z")

</div>

@brownoo

I tried a few things here… the Editor keeps the connection opened after you stop the game execution. If you disconnect the arduino and connect again without closing the Editor or manually calling Close node, you will not be able to Open a new connection (the plugin is not detecting that you disconnected the arduino). Try to force a Close before you Open on BeginPlay.

Will check that bug later!

Cheers

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1e5f0599](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1e5f0599](https://forums.unrealengine.com/u/anonymous_user_1e5f0599)\
**Post date:** [August 2, 2016, 7:20pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/14 "2016-08-02T19:20:44Z")

</div>

> [@danielvmacedo;574740](#):
>
> @anonymous_user_1e5f0599
> 
> I tried a few things here… the Editor keeps the connection opened after you stop the game execution. If you disconnect the arduino and connect again without closing the Editor or manually calling Close node, you will not be able to Open a new connection (the plugin is not detecting that you disconnected the arduino). Try to force a Close before you Open on BeginPlay.
> 
> Will check that bug later!
> 
> Cheers

I tried to force the close but same problem still reading with or without arduino any other solution ?

---

<div class="post-metadata">

**Author:** ![valentegamedev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/valentegamedev/32/1068844_2.png) [@valentegamedev](https://forums.unrealengine.com/u/valentegamedev)\
**Post date:** [August 2, 2016, 7:31pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/15 "2016-08-02T19:31:12Z")

</div>

> [@anonymous\_user\_d85168f1wnoo;574749](#):
>
> I tried to force the close but same problem still reading with or without arduino any other solution ?

@brownoo I see that you port number is COM10+… try using this string: “\.\COM12”

Should look like this:

![Open.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/9/289c6e1e74455f5ef67c6cabb68bb88d06a29766.png)

Let me know if it works!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1e5f0599](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1e5f0599](https://forums.unrealengine.com/u/anonymous_user_1e5f0599)\
**Post date:** [August 2, 2016, 7:36pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/16 "2016-08-02T19:36:14Z")

</div>

> [@danielvmacedo;574753](#):
>
> @anonymous_user_1e5f0599 I see that you port number is COM10+… try using this string: “\.\COM12”
> 
> Should look like this:
> 
> ![Open.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/9/289c6e1e74455f5ef67c6cabb68bb88d06a29766.png)
> 
> Let me know if it works!

Unfortunatly, same problem ☹ still reading !!

---

<div class="post-metadata">

**Author:** ![valentegamedev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/valentegamedev/32/1068844_2.png) [@valentegamedev](https://forums.unrealengine.com/u/valentegamedev)\
**Post date:** [August 2, 2016, 7:42pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/17 "2016-08-02T19:42:32Z")

</div>

> [@brownoo;574755](#):
>
> Unfortunatly, same problem ☹ still reading !!

The read is called but it is returning a TArray\<uint8\> with size 0. It returns with size 0 when it’s not finding anything on the buffer or is not opened.

Can you show the arduino side?

Because using this code on arduino:

```auto

void setup() {
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  Serial.begin(115200);
  blink();
}
void loop() {
  delay(100);
  blink();
}

void blink() {
  digitalWrite(13, HIGH);
  delay(200);
  digitalWrite(13, LOW);
  delay(200);

  float variable = 123.45;
  Serial.println(variable);
}

```

And using the same node setup (and port “\.\COM12”) that you are using… everything works fine on my machine (win 10 + Unreal 4.12.5).

Can you also show your console log to see if you get:

```auto

LogTemp:Warning: UArduinoKitBP::Open -> Success

```

or

```auto

LogTemp:Warning: UArduinoKitBP::Open -> Failed

```

during the Open attempt

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1e5f0599](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1e5f0599](https://forums.unrealengine.com/u/anonymous_user_1e5f0599)\
**Post date:** [August 2, 2016, 8:04pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/18 "2016-08-02T20:04:44Z")

</div>

> [@danielvmacedo;574759](#):
>
> The read is called but it is returning a TArray\<uint8\> with size 0. It returns with size 0 when it’s not finding anything on the buffer or is not opened.
> 
> Can you show the arduino side?
> 
> Because using this code on arduino:
> 
> ```auto
> 
> void setup() {
> pinMode(13, OUTPUT);
> digitalWrite(13, LOW);
> Serial.begin(115200);
> blink();
> }
> void loop() {
> delay(100);
> blink();
> }
> 
> void blink() {
> digitalWrite(13, HIGH);
> delay(200);
> digitalWrite(13, LOW);
> delay(200);
> 
> float variable = 123.45;
> Serial.println(variable);
> }
> 
> ```
> 
> And using the same node setup (and port “\.\COM12”) that you are using… everything works fine on my machine (win 10 + Unreal 4.12.5).
> 
> Can you also show your console log to see if you get:
> 
> ```auto
> 
> LogTemp:Warning: UArduinoKitBP::Open -> Success
> 
> ```
> 
> or
> 
> ```auto
> 
> LogTemp:Warning: UArduinoKitBP::Open -> Failed
> 
> ```
> 
> during the Open attempt

I tried your arduino code still same problem, i tested the serial communication with realtern it works !! even with the UE 4.9.2 ☹

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1e5f0599](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1e5f0599](https://forums.unrealengine.com/u/anonymous_user_1e5f0599)\
**Post date:** [August 2, 2016, 8:13pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/19 "2016-08-02T20:13:09Z")

</div>

LogTemp:Warning: UArduinoKitBP::Open -\> Failed  
PIE: Info Play in editor start time for /Game/UEDPIE\_0\_ExampleMap 1.09  
LogBlueprintUserMessages: Late PlayInEditor Detection: Level ‘/Game/ExampleMap.ExampleMap:PersistentLevel’ has LevelScriptBlueprint ‘/Game/ExampleMap.ExampleMap:PersistentLevel.ExampleMap’ with GeneratedClass ‘/Game/ExampleMap.ExampleMap\_C’ with ClassGeneratedBy ‘/Game/ExampleMap.ExampleMap:PersistentLevel.ExampleMap’

---

<div class="post-metadata">

**Author:** ![valentegamedev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/valentegamedev/32/1068844_2.png) [@valentegamedev](https://forums.unrealengine.com/u/valentegamedev)\
**Post date:** [August 2, 2016, 8:22pm UTC](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362/21 "2016-08-02T20:22:58Z")

</div>

> [@brownoo;574780](#):
>
> LogTemp:Warning: UArduinoKitBP::Open -\> Failed  
> PIE: Info Play in editor start time for /Game/UEDPIE\_0\_ExampleMap 1.09  
> LogBlueprintUserMessages: Late PlayInEditor Detection: Level ‘/Game/ExampleMap.ExampleMap:PersistentLevel’ has LevelScriptBlueprint ‘/Game/ExampleMap.ExampleMap:PersistentLevel.ExampleMap’ with GeneratedClass ‘/Game/ExampleMap.ExampleMap\_C’ with ClassGeneratedBy ‘/Game/ExampleMap.ExampleMap:PersistentLevel.ExampleMap’

Yeah… its not opening the port with the arduino.

My last attempt is to change the associated port with your arduino in device manager…

Select your arduino and go to properties

 ![1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/5/0/e50350ce61f17f84d395bd7f27b59c0035e76f6d.png)

Port settings

![2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/9/3/c9398b8f9d4aefbd93c8d9ddcf199d220dfcc0fd.png)

Advanced Button and change the port to a number lower than COM10 and use the regular string like “COM3” in unreal Open node

![3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/2/c/52c163acc224c9749068c936bdd7707cab6c2cc7.png)

than disconnect and connect your arduino, check if it’s found and assigned to the right port and try the code inside Unreal.

If this doesnt work… I’m sorry… I have no clue why it’s not connecting =(

[Next page](https://forums.unrealengine.com/t/free-arduinokit-cross-platform-arduino-plugin-for-ue4/70362.md?page=2)
