Announcement

Collapse
No announcement yet.

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

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

    Originally posted by RVillani View Post
    In Blueprints, I'd write that formula in a Math Expression node and convert it to a macro. That way it's easy to use it elsewhere and the Math Expression node makes it very performant.

    EDIT: Actually, in C++ you can make that formula even faster: A + ((B << 8) + C) * 0.001f
    Thank you for your suggestions!

    I was not aware of the Math Expression node in Blueprint. That seems very usefull.
    But I really liked your C++ bitshift version, so I guess I'll make use of that!

    Comment


      Hello there.

      Thanks so much for the plugin, I think it's going to be perfect for what i want to do.

      I'm fairly new to Arduino and to Blueprints in Unreal. I was able to get your plugin up and running and i'm sending data from a potentiometer into Unreal and using it to drive a attribute on a camera. That's all working great. Now i'm looking at adding some buttons in Ardunio to change what attributes in Unreal i'm controlling. So i have the issue of needing to send multiple items of data. In this case just two items, the "mode" that the Arduino is in, and the values from the potentimeter. But my hope is to add some more items in the future.

      So after reading through all the posts on this thread it sounds like i'm dealing with the classic "protocol" issue that you describe back in post #42. My issue is that your solution is a bit beyond my abilities at the moment. While I've done a fair bit of scripting in other languages I've never had to deal with bytes before so it's a whole new scary world.

      However i came up with a different way if handling multiple bits of data all as a string. I know in your original post you say that this can freeze your game, but in my, albeit limited testing, i am not seeing any freezing. everything seems to run fine at 60fps.

      In my Arduino code i'm sending it out like this:

      Serial.print("m:");
      Serial.print(mode);
      Serial.print("v:");
      Serial.print(outputValue);
      Serial.println("eol");

      Then in blueprints i'm using a serials of string splits to separate out the data. I've attached a screenshot. This seems to be working just fine. But i'm guessing there is some very good reason why doing it this way is not such a great idea, but i don't know what that reason is.

      thanks
      eric
      Click image for larger version

Name:	BPexample.PNG
Views:	1
Size:	110.2 KB
ID:	1592396




      Comment



        Originally posted by sporksalot View Post
        Then in blueprints i'm using a serials of string splits to separate out the data. I've attached a screenshot. This seems to be working just fine. But i'm guessing there is some very good reason why doing it this way is not such a great idea, but i don't know what that reason is.
        Defining what you are sending and is expecting to receive is the more correct way of doing it, it will look cleaner and error checking is simpler. You will also save resources on both ends doing the more correct way.

        Comment


          Originally posted by sporksalot View Post
          But i'm guessing there is some very good reason why doing it this way is not such a great idea, but i don't know what that reason is.
          Like Lambdarevolution said, you'd save resources by using bytes. Each character in a string is a byte by itself (plus the null one at the end to signal the end of the string). Besides the processing to process the strings, convert from/to numbers etc.

          But, if you still want to use strings, replace ReadString with ReadLine. If you just ReadString, it'll read whatever is in the serial buffer, and you'll likely get half strings many times. Because Unreal and the Arduino are not in sync. So you might get things like "modevutp" in one frame and "utValueeol" on the next frame, because Unreal read while Arduino was still sending. Whereas if you use ReadLine, the reading will only end once it gets a line end, which you're sending with Serial.println. It will freeze if Arduino takes too long to send another line end, so keep doing that in the loop as fast as possible.

          Another thing you will want to do is use Flush after every ReadLine, to clear the serial buffer before the next frame's ReadLine. Otherwise, if Arduino is sending data faster than Unreal is reading, as each ReadLine stops in the next line end, it will potentially leave many other strings in the serial buffer, and on each ReadLine you'd be reading only one group of commands, which would not be the latest one.
          Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
          Unreal products: Dynamic Picture Frames, Neo Kinect

          Comment


            Thanks for the advice and tips
            It's not that I WANT to use strings, it's just the only thing currently within my current technical skills and knowledge. I just need to go off and learn how to use bytes as it does sounds like the better solution. Maybe after i've done a lot of the other components for this project i'll come back to that.

            thanks again for the great plugin.

            thx-e

            Comment


              Can I use this plugin in my c++ project? I tried to include in the dependency in Build.cs and it does not work.

              Comment


                Hi,
                is it posible to run with 4.22?
                Thank you for this great tool

                Comment


                  Olá Rvilani, o plugin é fantastico, qual a possibilidade de uma compilação para a UE 4.22?

                  Comment


                    4.22 release is here

                    Originally posted by SargodB View Post
                    Can I use this plugin in my c++ project? I tried to include in the dependency in Build.cs and it does not work.
                    It was missing the UE4DUINO_API macro in the class declaration. Sorry about that! I only learned about it recently. I guess all the times I needed to use my plugins in C++, I got lucky by having that macro already unaware of what it's for. hahaha You can download the fixed source or the released version for 4.22 in the link above.


                    Originally posted by syll View Post
                    Hi, is it posible to run with 4.22? Thank you for this great tool
                    You're very welcome! It always was But if you don't want to build it, the release is in the link above.


                    Originally posted by Trevelin View Post
                    Olá Rvilani, o plugin é fantastico, qual a possibilidade de uma compilação para a UE 4.22?
                    Obrigado! Bem possível, eu diria. XD
                    Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
                    Unreal products: Dynamic Picture Frames, Neo Kinect

                    Comment


                      Obrigado! RVillani!!!! top

                      Comment


                        Hello, I used the plugin in 4.20.3.It is normal to use it without the wrapper project, but the plug-in cannot read the port after the wrapper project

                        Comment


                          Originally posted by RVillani View Post
                          4.22 release is here


                          It was missing the UE4DUINO_API macro in the class declaration. Sorry about that! I only learned about it recently. I guess all the times I needed to use my plugins in C++, I got lucky by having that macro already unaware of what it's for. hahaha You can download the fixed source or the released version for 4.22 in the link above.



                          You're very welcome! It always was But if you don't want to build it, the release is in the link above.



                          Obrigado! Bem possível, eu diria. XD
                          Thank you!!!

                          Comment


                            Originally posted by anlan909 View Post
                            Hello, I used the plugin in 4.20.3.It is normal to use it without the wrapper project, but the plug-in cannot read the port after the wrapper project
                            Which wrapper project?
                            Anyways, maybe it was the version with a bug fixed on later ones, that indeed would prevent the port from opening. Try downloading the latest source from GitHub and compiling it.
                            Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
                            Unreal products: Dynamic Picture Frames, Neo Kinect

                            Comment


                              Hello!

                              I'm very new with Unreal Engine and i saw this plugin and thought... "Hey! i could make a cool GUI scoring for my home pinball" but i don't know where to go from there haha. I have the game all coded in Arduino but for scoring (Arduino is doing the math for all 4 players) i want it to be displayed on Unreal Engine and maybe add pictures, how would i do this?

                              Example, if target/switch is hit -> Add score on Arduino -> printing/displaying scoring in Unreal Engine.

                              And for sharing data, how can i get Unreal Engine to talk to Arduino? Like In Unreal i want it to tell the Arduino to test lighting, coils and switches to see if they're working.

                              Example, custom GUI menu/settings, click "Test Lighting" in Unreal Engine -> Arduino will turn on all lights.


                              Thanks,

                              Comment


                                Hello Guys i'm a 17 year old noob trying to learn how to combine ue4 and arduino i managed to download the UE4duino plugin succesfullly but i can't get it to work.
                                i tried to control the light intensity of a point light with a potentiometer and i kind of get it to work but i get a lot off random values because some values are split in two frames for example if i have the value 255 unreal reads it as 25 and 5. i simply can't solve it i have read the whole forum for a simple and clear answer but i can't find one i hoope you guys can help me
                                ps: i'm using an arduino uno and UE4.21.2
                                greetings Kenneth

                                (Sorry for the bad english)

                                Comment

                                Working...
                                X