Announcement

Collapse
No announcement yet.

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

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    Just to add one more info on my last post:
    The RX light on the arduino board does lit up every time press the "F" key, so something is happening... just not seeing the result on the board.
    Last edited by knotff; 10-21-2017, 03:29 PM.
    ________________
    Fabiano Friedrich

    LinkedIn | fabianofriedrich
    RevEngLab | www.revenglab.com
    TZERO Architecture | www.tzero.org

    Comment


      #32
      Is a chance to get binaries for 4.18 unreal version?

      Comment


        #33
        Originally posted by DanielDurys View Post
        Is a chance to get binaries for 4.18 unreal version?
        Added it to the latest release

        Originally posted by knotFF View Post
        Getting the exact same thing.
        Using the provided script "ArduinoTypesExample".
        It works on the Serial Monitor on the IDE if I type in "lines", but getting nothing on the UE editor. Lines comes out as blank, Float as 0.0 and Integer as 0.
        That's weird. This is my setup:
        Click image for larger version

Name:	Arduino.png
Views:	1
Size:	116.7 KB
ID:	1378358
        And it works. Baud Rate is set to 9600 to match the script's.
        Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
        Unreal products: Dynamic Picture Frames, Neo Kinect

        Comment


          #34
          Originally posted by RVillani View Post
          Added it to the latest release


          That's weird. This is my setup:
          Click image for larger version  Name:	Arduino.png Views:	1 Size:	116.7 KB ID:	1378358
          And it works. Baud Rate is set to 9600 to match the script's.
          __________________________________________________________

          Thanks for the 4.18 update!

          Thing remain the same on my end. Everything works on the SERIAL MONITOR, but nothing happens on the Editor.
          Furthermore, when I package the project to WIN64 (which was not working for either versions on 4.17) , I cannot open any port. I did a loop to go through 1-50 port, but they all turn FALSE.

          Click image for larger version

Name:	image_121594.png
Views:	2
Size:	3.5 KB
ID:	1378764
          Editor Output Log

          Click image for larger version  Name:	752634ebddf051b30f3ab7a102a89e9f.png Views:	1 Size:	201.5 KB ID:	1378766
          Setup

          Click image for larger version  Name:	14c5a4c261ee400ce458485bbec3dd12.png Views:	1 Size:	478.1 KB ID:	1378767
          Unable to open port when running EXE

          Click image for larger version  Name:	d4edf1c58fcb4beae9041370ddf03275.png Views:	1 Size:	8.2 KB ID:	1378765
          Running error on WIN32 (4.18) and Wind32/64 on 4.17.
          ________________
          Fabiano Friedrich

          LinkedIn | fabianofriedrich
          RevEngLab | www.revenglab.com
          TZERO Architecture | www.tzero.org

          Comment


            #35
            knotFF, you can't use the same port in UE and in Serial Monitor at the same time I had this problem, just close Serial Monitor and UE4 will now can use the port.
            RVillani, thank you for the 4.18 binaries
            Last edited by DanielDurys; 11-02-2017, 04:33 AM.

            Comment


              #36
              Originally posted by DanielDurys View Post
              knotFF, you can't use the same port in UE and in Serial Monitor at the same time I had this problem, just close Serial Monitor and UE4 will now can use the port.
              RVillani, thank you for the 4.18 binaries
              Sure thing. But what I meant was, I can see it working in the Serial Monitor, where I type in "lines" or "float" or "int", I get the desired feedback. On the other hand, when I run it on the UE Editor, with the Serial Monitor closed (otherwise the COM port won't open), I get no reading from Arduino.

              This is what I should be getting (image from @RVillani post #12):

              Click image for larger version

Name:	image_113017.jpg
Views:	1
Size:	23.6 KB
ID:	1379276

              But this is what I get:
              Click image for larger version

Name:	image_121594.png
Views:	2
Size:	3.5 KB
ID:	1379277

              You can see I get nothing after the brackets and the FALSE printed there is because the comparison to the text, which is turning negative.
              Nonetheless, when I make a build of a level and run the EXE, I cannot open any PORT, even looping the OPEN PORT from 1-50. This is the happening on 2 different machines.
              I wonder if I am missing some Library or something like that.
              ________________
              Fabiano Friedrich

              LinkedIn | fabianofriedrich
              RevEngLab | www.revenglab.com
              TZERO Architecture | www.tzero.org

              Comment


                #37
                DanielDurys You are welcome, mate!

                knotFF You are also welcome and, as for your problems, solutions follow below. Hope these help!

                I've had the port not opening problem in a project, without errors or anything, and the problem was that Unreal simply was not compiling the plugin. It also happened with another plugin in another project. Seems kinda random.

                After some fiddling (days of it) the solution was to make the plugin not load by default and re-enable it in the plugins window. Here's how you do it without corrupting any Blueprints already using the plugin:
                • Close the editor
                • Open the [Project]\Plugins\UE4Duino\UE4Duino.uplugin file in a text editor (like Notepad)
                • Change "EnabledByDefault": true to false
                • Open the [Project]\[Project].uproject file in a text editor
                • Before the final closing curly bracket (}) add a comma and:
                  Code:
                  "Plugins": [
                  	   {
                  	       "Name": "UE4Duino",
                  	       "Enabled": true
                  	   }
                  	]
                • Save both files, launch the project and build it to test. Avoid Win32 as it never worked for me without VS 2015. And the error message window you posted has to do with DirectX, not the plugin (WindowsD3D11Device.cpp).
                As for the "Arduino not responding back in Unreal" problem, found the issue:
                You are sending the float command, not lines. So the script answers with 4 bytes that make a float. That doesn't end with a line break, thus ReadLine won't work (even for reading the bytes).
                Last edited by RVillani; 11-07-2017, 08:10 PM.
                Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
                Unreal products: Dynamic Picture Frames, Neo Kinect

                Comment


                  #38
                  Originally posted by RVillani View Post
                  DanielDurys You are welcome, mate!

                  knotFF You are also welcome and, as for your problems, solutions follow below. Hope these help!

                  I've had the port not opening problem in a project, without errors or anything, and the problem was that Unreal simply was not compiling the plugin. It also happened with another plugin in another project. Seems kinda random.

                  After some fiddling (days of it) the solution was to make the plugin not load by default and re-enable it in the plugins window. Here's how you do it without corrupting any Blueprints already using the plugin:
                  • Close the editor
                  • Open the [Project]\Plugins\UE4Duino\UE4Duino.uplugin file in a text editor (like Notepad)
                  • Change "EnabledByDefault": true to false
                  • Open the [Project]\[Project].uproject file in a text editor
                  • Before the final closing curly bracket (}) add a comma and:
                    Code:
                    "Plugins": [
                    {
                    "Name": "UE4Duino",
                    "Enabled": true
                    }
                    ]
                  • Save both files, launch the project and build it to test. Avoid Win32 as it never worked for me without VS 2015. And the error message window you posted has to do with DirectX, not the plugin (WindowsD3D11Device.cpp).

                  As for the "Arduino not responding back in Unreal" problem, found the issue:
                  You are sending the float command, not lines. So the script answers with 4 bytes that make a float. That doesn't end with a line break, thus ReadLine won't work (even for reading the bytes).
                  RVillani
                  Thanks so much for the plug-in solutions not loading on build. That was spot on:

                  No in regards to the "UE4Duino/ArduinoTypesExample", I continue to get no data from Arduino<>Unreal. When I use "lines" I get nothing back (Read Line), when I use float (ReadBytes+BytesToFloat or ReadAFloat) I get "0.0". Same with ''int", where I get a "0".

                  Click image for larger version

Name:	e31047cebb665342f08ef6c88dc06d10.png
Views:	1
Size:	191.8 KB
ID:	1382928
                  Click image for larger version

Name:	b47cc60c2117364d82dde221733be4d3.png
Views:	1
Size:	3.9 KB
ID:	1382929



                  ________________
                  Fabiano Friedrich

                  LinkedIn | fabianofriedrich
                  RevEngLab | www.revenglab.com
                  TZERO Architecture | www.tzero.org

                  Comment


                    #39
                    Hi - thanks for the plugin RVillani - a great creation!
                    I am having a small problem with my sensor readings.I am bringing in a float from Arduino which has two decimal places (1.05, 3.09, 0.01 etc).

                    The sensor readings appear fine on the serial window in Arduino.....but when I bring the float readings into unreal the data is not so clean.
                    I think the data readings when brought into unreal sometimes get jumbled up....for example it seems as though sometimes the float value is put on two lines instead of one line.
                    I have tried using read float and read line but no improvement with either.

                    I have not included "? is valid" or put in a "0.1 delay" - could this cause a problem ?
                    Is it better not to bring in decimal points - should I multiply all data by 100 in arduino and bring it in as an int and then divide inside my blueprint ?
                    Any advice would be great.

                    Comment


                      #40
                      Hi - as per my last message this is what is causing issues with my readings (in the screenshot one of the lines appears as it should and the other appears on two lines)...any ideas?

                      Comment


                        #41
                        knotFF Don't use PrintLine. Just Print. On the example code I made, it checks if the received string is exactly equal to "lines" or "float" etc. So, if you PrintLine, you are sending "\r\n" or alikes with it, causing it to fail, as "lines\r\n" is not "lines".

                        It's kinda funny because before you used Print with "float" trying to get lines. Now, you are using the correct words but sending them wrong xD
                        Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
                        Unreal products: Dynamic Picture Frames, Neo Kinect

                        Comment


                          #42
                          Hi, joeycampbell
                          Without seeing code or Blueprints, I can only assume what's going on. But it's a very common problem with new Arduino/Unreal users: synchronization. Arduino speaks in a speed, Unreal reads in another. You could send "123456" and Unreal could read it correctly or read one part in a frame and the rest in another, because it's reading before Arduino finishes sending all the characters.

                          You have two ways of sending a float to Unreal. Either as characters (text), as you seem to be doing, or as the 4 bytes that make a float. The first way has the synchronization problem described above. The second way could also suffer from this problem if Unreal read the 4 bytes separately. So, how to solve it? There are several ways:
                          • If you know how many characters you are going to send, you could always wait until Unreal reads all of them. But this can freeze your game, even if very briefly.
                          • You can send something to Arduino and make it answer to that with your data. This way, Unreal knows when to expect data. Then you can use a small delay to make sure there's time for Arduino to send all the characters. Arduino is lightning fast, but the COM port is not. This is how in did in the plugin's examples.
                          • Harder, but the most precise way: create a protocol. Send a sequence of characters (2 or 3) before each message and another sequence at the end. Then, in Unreal, you keep checking for this sequence (even between separate frames). If found, store all coming bytes/chars/strings/whatnot in an array, until it recognizes the END sequence. After the end sequence, you know for sure the message is complete.
                          I always use the last method. I'll describe an example of how I do it in Unreal to read floats or other kind of data that I can store in byte arrays.
                          • First, I define the size of my "package" in Unreal and Arduino. For instance, let's say I'll be sending 2 floats (4 bytes each) and 2 bytes for the start and 2 more for the end of the protocol. 4 + 4 + 2 + 2 = 12 bytes
                          • I define in Unreal and Arduino these start/end bytes, so both know what to expect.
                          • In Unreal, I keep reading the bytes in the Serial port. If I find the first one, I register that I've found it and start looking for the second one.
                          • If the next one is the second one, I know the next 8 bytes are my two floats and then comes my protocol end. If the next one is not the second one in the protocol, I know I'm reading some random piece of data and I start looking for the first protocol byte again.
                          Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
                          Unreal products: Dynamic Picture Frames, Neo Kinect

                          Comment


                            #43
                            Originally posted by RVillani View Post
                            knotFF Don't use PrintLine. Just Print. On the example code I made, it checks if the received string is exactly equal to "lines" or "float" etc. So, if you PrintLine, you are sending "\r\n" or alikes with it, causing it to fail, as "lines\r\n" is not "lines".

                            It's kinda funny because before you used Print with "float" trying to get lines. Now, you are using the correct words but sending them wrong xD
                            RVillani
                            Sorry for the mismatched screenshots, but I have tried them all. Print/PrintLine, ReadByte/ReadBytes, etc., all I/O methods. Nothing works for me.
                            In fact I wrote all available methods in a blueprint, to test all Input/Outputs from Arduino<>Unreal, like so:

                            Click image for larger version  Name:	55016a66cd4c2ed65f479bf689674738.png Views:	1 Size:	107.9 KB ID:	1386304

                            I do believe I have found the possible issue, but I need to confirme it.
                            I've exported this build with Baud 9600 for testing on (it will pick the correct COM via loop from 1-50) :
                            https://www.dropbox.com/s/tkd23mfx9a...duino.zip?dl=0

                            This EXE works in 2 ways:
                            1. for "ArduinoTypeExample":
                              1. This is a copy of the exemples presented in page one of this forum
                              2. Pressing keyboard F = lines
                              3. Pressing keyboard G = float
                              4. Pressing keyboard H = int
                            2. Reading Only, you need to create a scritp in Arduino IDE to print something to serial. (or just remove the IF statements from the exemple above):
                              1. Pressing keyboard T = this will go through all available READs available in UE4Arduino's plugin.

                            Could anyone try this please?
                            I does not work on my machine (macbook under bootcamp), but it works on my friends machine (native Windows machine). So I think the problem I am having is because of an Apple<>Driver<>Windows for the USB ports...
                            Last edited by knotff; 11-15-2017, 03:02 PM.
                            ________________
                            Fabiano Friedrich

                            LinkedIn | fabianofriedrich
                            RevEngLab | www.revenglab.com
                            TZERO Architecture | www.tzero.org

                            Comment


                              #44
                              Thanks RVillani

                              Comment


                                #45
                                Has anyone tried to read two sensor readings simultaneously from arduino ?
                                I have tried separating the sensor readings by a comma (in arduino) and then using the split string function to decipher the two readings.
                                I can print both readings on screen but the outputs from the split node are not working.
                                I have used the attached blueprint as a reference - any ideas what I'm doing wrong?



                                Comment

                                Working...
                                X