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)
Its serial communication works in Windows, OSX and Linux.
Windows users only:
ports higher than “COM9” need to be on this format: “\.\COM10”, “\.\COM11”, “\.\COM12” and so on…
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 max 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.
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
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
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:
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.
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’