Announcement

Collapse
No announcement yet.

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

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

    #91
    Originally posted by PowerKJH View Post
    It works well. Thank you very much. ^^ Perhaps Is Bluetooth mode supported?
    If you mean one board talking to PC via Bluetooth, I've never tried that. But I don't think the plugin would do it, since Bluetooth is a different driver.
    What I did once was make an Arduino wired to the PC communicate with another one via Bluetooth module on both boards.
    Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
    Unreal products: Dynamic Picture Frames, Neo Kinect

    Comment


      #92
      Originally posted by RikuShadow97 View Post
      I don't understand how in 3 years there is no even 1 tutorial of how this plugin works
      I guess you're lacking some knowledge of Unreal and Arduino. The examples are usually enough XD

      Behind the courtains, the plugin works like this: it opens up a Serial Port and let you send and receive bytes through it. That's the only thing the Serial Port understands: bytes.
      So you can use this plugin to talk to anything that uses Serial Port, not just Arduino.
      Now, knowing that you can only send and receive bytes, anything you want to do you need to know how to convert that from and to bytes. That's the basic data unit in binary computers, so anything can be converted to/from bytes.
      The protocol thing I told you about is a way for you to know when you are reading the first bytes of a sequence of fixed length. And inside that sequence you'll have decided exactly which bytes are what.

      Imagine a JPEG file, for instance. It have varied sizes, so in order for a JPEG reader software to know when to stop, there must be some bytes in a specific place in the JPEG format (protocol) that tells its size. That's called the file header.

      What you need to do is to define a format for the data you want to exchange with Unreal and, in Unreal, keep searching for the bytes that define the start of the data. When you find it, you'll know exactly what comes after and how to read it. These first bytes are usually a sequence that should be very unlike to repeat in your data. Like 0xFF 0xFE 0xFD. That specific byte sequence must be a bit hard to find in random data.

      The Read/Write Int, Floats and whatnot functions are just methods I left there to ease the conversion of those formats to and from bytes. But the only thing going through the serial port are bytes.
      Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
      Unreal products: Dynamic Picture Frames, Neo Kinect

      Comment


        #93
        Hello All :-/ Need some help here.

        I'm doing a beginner course in arduino and i thought combing it with UE4. after some digging on line i found this (ue4duino) great plugin.

        my simple project is when i click on the arduino button a light will turn on a spotlight in the Unreal Scene.

        I already set up my scene in UE4, and when i click the button on the arduino, it fires "0" or "1" to the arduino console.

        Click image for larger version

Name:	arduinoconsole.JPG
Views:	73
Size:	173.4 KB
ID:	1488887












































        when i PLAY the scene in the UE4, there is somtimes Flickering light. but it doesn't stay consist.

        I tried to followed the instructions but i guess im missing something.

        Click image for larger version

Name:	unreal-level-blueprint.JPG
Views:	77
Size:	339.1 KB
ID:	1488888

        Im Newbie both to UE4 and Arduino.

        im using WIN10, Arduino Uno R3, UE 4.18.2

        any help will be very appreciated.

        10X


        Comment


          #94
          Originally posted by RVillani View Post

          I guess you're lacking some knowledge of Unreal and Arduino. The examples are usually enough XD

          Behind the courtains, the plugin works like this: it opens up a Serial Port and let you send and receive bytes through it. That's the only thing the Serial Port understands: bytes.
          So you can use this plugin to talk to anything that uses Serial Port, not just Arduino.
          Now, knowing that you can only send and receive bytes, anything you want to do you need to know how to convert that from and to bytes. That's the basic data unit in binary computers, so anything can be converted to/from bytes.
          The protocol thing I told you about is a way for you to know when you are reading the first bytes of a sequence of fixed length. And inside that sequence you'll have decided exactly which bytes are what.

          Imagine a JPEG file, for instance. It have varied sizes, so in order for a JPEG reader software to know when to stop, there must be some bytes in a specific place in the JPEG format (protocol) that tells its size. That's called the file header.

          What you need to do is to define a format for the data you want to exchange with Unreal and, in Unreal, keep searching for the bytes that define the start of the data. When you find it, you'll know exactly what comes after and how to read it. These first bytes are usually a sequence that should be very unlike to repeat in your data. Like 0xFF 0xFE 0xFD. That specific byte sequence must be a bit hard to find in random data.

          The Read/Write Int, Floats and whatnot functions are just methods I left there to ease the conversion of those formats to and from bytes. But the only thing going through the serial port are bytes.

          I don't mean, the internal logic. I mean how to do things works with it xd. I've been using unreal 2 month, coming from unity. I can use it, but arduino... just 2 weeks. I did somes interactions like turn on and off a led from unreal, or make a rotation of the character. but not the correct way. Last day I could check the value of a int from arduino in unreal, but it change whenever it wants, not exaccly when i changed it, so...

          And again. u cannot select what variable are u using. If i have 2 inputs in arduino and i want to change X rotation and Z rotation, in unreal, with your plugin, there's no way to say "check variable called Xrotation" for example. xd

          Tell me where im wrong...

          Comment


            #95
            Originally posted by pixelman17 View Post
            when i PLAY the scene in the UE4, there is somtimes Flickering light. but it doesn't stay consist.
            You're reading String from Arduino and converting to int. But your string also contains "\n", which is most likely being converted to 0, thus turning your light off.
            If you really want to send line breaks from Arduino, use "\r\n" and, in Unreal, read it with ReadLine.
            Just to make sure, debug your Blueprint with a break point in the "SetIntensity to 0" node and see when it's getting called.
            Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
            Unreal products: Dynamic Picture Frames, Neo Kinect

            Comment


              #96
              Originally posted by RikuShadow97 View Post
              Tell me where im wrong...
              Sorry, but it looks like you didn't read anything I wrote. I already told you twice why you can't have separate variables and how to work like if you had them.
              If you want a Ctrl+C, Ctrl+V ready solution, someone else will have to help you. I already gave you directions of how I deal with several variables from Arduino.
              Or, if you're willing to pay, I can help you personally through Skype/TeamViewer.
              Last edited by RVillani; 06-14-2018, 06:56 AM.
              Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
              Unreal products: Dynamic Picture Frames, Neo Kinect

              Comment


                #97
                Originally posted by RVillani View Post
                Sorry, but it looks like you didn't read anything I wrote. I already told you twice why you can't have separate variables and how to work like if you had them.
                If you want a Ctrl+C, Ctrl+V ready solution, someone else will have to help you. I already gave you directions of how I deal with several variables from Arduino.
                Man, I can understand, more or less, why u cannot use 2 variables like this, i just confirm it. The problem is 1 I need somehow to do it. 2, with BP i sent u there return a value of 100000. aprox, when in arduino it start at 50. Then, i change the way. I used Get(0) and then transform it to int. It seems to work, but when I stop the input, I got return a random value, so... this rotation has problem xd.

                Sorry for be a dumb guy who is trying to understand something never seen.

                Comment


                  #98
                  Originally posted by RikuShadow97 View Post
                  The problem is 1 I need somehow to do it. 2
                  Read this post I wrote about the protocol scheme. And use a byte array to send to Unreal as many values as you want. In unreal, after finding your first bytes (read that post), you'll know where your other desired bytes are to retrieve your variables.

                  The BytesToInt function is your friend here, but don't use it directly on ReadBytes. You don't know how many bytes you are reading and you need only 4 to make an Int. Also, flush the serial port after opening it, otherwise you'll be reading all the data sent from Arduino before the BeginPlay event in the engine. And, last but really important, USE THE PROTOCOL scheme described on the aforementioned post. If you don't, you'll never know if the 4 bytes you are reading are from the same Int. You could be reading the last 2 of an Int and the first 2 of the next one. Arduino and Unreal won't work in sync, that's why we use a protocol. To find when the next package of data starts and make Unreal read your values from their actual beginning.
                  Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
                  Unreal products: Dynamic Picture Frames, Neo Kinect

                  Comment


                    #99
                    RikuShadow97 also, you could try printing lines from Arduino and using the read line function in Unreal. Then, your strings could be like: "variable1", "50". Then you can check if the string is the name of your variable and convert the next string to an Int. You can still very likely get just a piece of the data still, like "vari" and then "able1", by reading before Arduino finishes writing. That's why the protocol idea is still the best way.
                    Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
                    Unreal products: Dynamic Picture Frames, Neo Kinect

                    Comment


                      Originally posted by RVillani View Post
                      RikuShadow97 also, you could try printing lines from Arduino and using the read line function in Unreal. Then, your strings could be like: "variable1", "50". Then you can check if the string is the name of your variable and convert the next string to an Int. You can still very likely get just a piece of the data still, like "vari" and then "able1", by reading before Arduino finishes writing. That's why the protocol idea is still the best way.
                      My first try was like that. But it wasn't the value wich I wanted to use, it was like millions. I get a solution, but it was meh. I've already did the flush after open serial. I'm gonna check the post.

                      Thanks again.

                      Comment


                        Originally posted by RVillani View Post

                        If you mean one board talking to PC via Bluetooth, I've never tried that. But I don't think the plugin would do it, since Bluetooth is a different driver.
                        What I did once was make an Arduino wired to the PC communicate with another one via Bluetooth module on both boards.
                        Thank you for your comment. ^^.

                        My purpose is to control Unreal with external input.

                        Please make sure it is what I understand.

                        EX)

                        1 arduino connection PC.

                        1 arduino + 1 bluetooth module + 1 external input

                        -> External input value is communicated with arduino connected to PC by Bluetooth effect in unreal.

                        (px. I can not speak English, so I'm referring to the translator.)

                        Comment


                          Originally posted by PowerKJH View Post
                          1 arduino connection PC.

                          1 arduino + 1 bluetooth module + 1 external input

                          -> External input value is communicated with arduino connected to PC by Bluetooth effect in unreal.

                          (px. I can not speak English, so I'm referring to the translator.)
                          I don't know if it is because of the translation, but you were missing some things there.
                          You'll need:
                          • 1 Arduino connected to the PC. This Arduino must have a Bluetooth module configured as receiver.
                          • 1 Arduino not connected to the PC. This Arduino also has a Bluetooth module, but configured as sender. And it would be the one that gets the input to send it to the other Arduino (the receiver).
                          Input would be sent from the sender Aduino to the receiver one and the receiver one would send it to Unreal.
                          Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
                          Unreal products: Dynamic Picture Frames, Neo Kinect

                          Comment


                            Originally posted by RVillani View Post

                            I don't know if it is because of the translation, but you were missing some things there.
                            You'll need:
                            • 1 Arduino connected to the PC. This Arduino must have a Bluetooth module configured as receiver.
                            • 1 Arduino not connected to the PC. This Arduino also has a Bluetooth module, but configured as sender. And it would be the one that gets the input to send it to the other Arduino (the receiver).
                            Input would be sent from the sender Aduino to the receiver one and the receiver one would send it to Unreal.
                            It's perfect.
                            Thank you!!

                            Comment


                              Um dumb *** question. Ive got this plugin all set up and running with the Arduino. In the arduino code if i have a changing float called 'sensorValue' how do I convert that to the serial byte that Unreal expects? in the Arduino example the bit about the Float says:

                              float fVal = 12.34f;
                              byte* fBuffer = reinterpret_cast<byte*>(&fVal);
                              Serial.write(fBuffer, 4);

                              what is12.34f? some arbitary? float?

                              so could i do this????

                              float fVal = sensorValue;
                              byte* fBuffer = reinterpret_cast<byte*>(&fVal);
                              Serial.write(fBuffer, 4);

                              Comment


                                Originally posted by Gibson_Martelli View Post
                                so could i do this????

                                float fVal = sensorValue;
                                byte* fBuffer = reinterpret_cast<byte*>(&fVal);
                                Serial.write(fBuffer, 4);
                                Yes. You could. And if sensorValue is already of type float, you can just use it directly:
                                Code:
                                byte* fBuffer = reinterpret_cast<byte*>(&sensorValue);
                                12.34f was indeed an arbitrary value with an easy to remember sequence of numbers to make sure that the value was being translated correcly in Unreal, even its decimal part.
                                Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
                                Unreal products: Dynamic Picture Frames, Neo Kinect

                                Comment

                                Working...
                                X