Hello All, I had some days trying to read the COM port number by Arduino code to show it on a small OLED display, the problem is I can't find any Serial function to achieve read the own serial port number connected and show it on the OLED, because I don't have the option to see the serial port number with the computer screen. For example, each time I reconnect the Arduino board in any USB port of the computer I will achieve to see the COM port number changes with the OLED screen.
Thanks for the fast response, I need that, because I have maybe 10 Arduino datalogger connected to one computer(then I have a lot of COM ports in Windows PC), and for me is better to know the COM port number, right now I need put an external LCD screen to the computer and check the correct COM port reconnecting the USB to achieve make the configuration of the data logger windows software.
I agree with @anon57585045. This is only known on the PC side. This thread on stackoverflow gives some good insight into how it is done with Python.
If you are going to have multiple of your Arduino based devices connected at once to your PC and you want each to display their COM port on their respective OLEDs then you could start with the information on the above linked stackoverflow and have the Python code send a special command to each of your devices that it finds to inform them of which COM port they have been connected.
PC problem, not Arduino, and I suspect a pretty silly one.. Surely it would be a hell of a lot simpler to have all those Arduinos in a local network with ONE connected to the PC.
Looking more widely, it is possible to read the name of a USB serial device if it is attached. For example, I here now see a com port on my machine, "COM4 (LOLIN S2 mini)". I believe it's possible to change those names so you could name your sensors. Beyond that, I don't know but it might help.
Is that a specific software? Which one? Is it configurable with some form of configuration file that you can modify on the fly or passing com ports on the command line?
Did you write it yourself?
Does it handle 10 devices at the same time? Or do you run 10 instances of it?
For a sensible answer towards a solution, I think that you will have to give a lot more detail.
Might it be possible to do the reverse? For instance each Arduino would sent a ID number to the PC.
Some script (I have no idea how to create) would read the Com ports and receive the ID's
Yes is custom software developed with C# and I run 10 instances of it on each computer, also I use maybe 7 computers, where each computer has around 10 Arduinos
I'm missing a little bit the point why you need to know on which COM port a datalogger is. If that is to be able to configure that custom software to add a datalogger, how do you configure the custom software on a headless system?
It should be reasonably easy to modify that custom software to monitor COM ports, pick up the dataloggers and automatically add them to it's configuration.
It should be equally easy for that software to send a message to the Arduino to tell it on which COM port it is after it picked up a new COM port (in case that is still a requirement after the (1)).
you chose the extensive path... it is not effective....
Instead of connecting dozens of arduinos to several computers, it would be right to organize the arduino to the network and first collect data on one controller and transfer it to the one PC using one comport