#Making Unity send data over a serial port

1 messages · Page 1 of 1 (latest)

thick hemlock
#

Hi! I want to ask if it’s possible to control 4 PWM pins on an ESP32-C3 mini from a Unity application over USB. For context, Unity wouldn’t talk to the pins directly — it would just open the ESP’s USB serial port and send simple text commands like “SET PIN=18 DUTY=2000\n”, and the ESP firmware would interpret those commands and update its PWM outputs. So the only thing Unity needs to do is: detect the serial port, open it, send formatted command strings, read the ESP’s “OK/ERR” responses, and keep the connection alive without blocking the main thread. Is this kind of serial-port communication reliable/possible with Unity on desktop builds, and does anyone here have experience with using System.IO.Ports or another approach for this type of hardware control?

dense iron
#

You should probably start by making a standalone C# program that does what you want and then move it over to Unity. There shouldn't be anything in Unity that would somehow prevent that kind of thing.

#

It's very unlikely to find someone here who has done that very specific hardware communication thing, but if you get stuck with Unity-specific issues it's worth it to ask again because they usually can be solved with general Unity knowledge

astral dock
#

what is your goal? there is a serial port communication asset on the asset store that creative coders regularly use for stuff

thick hemlock
#

tbh i have never touched unity, but i need a simple shooting game for demonstration of my mechanical project

#

And I wanted to make sure it was possible in unity before i start to learn it

thick hemlock
astral dock