Yesterday, I created a thread but it was in Spanish. This is the topic in English.
I'm not new to programming but I am new to electronics and communication protocols. I'm going to raise a need to see if I can get guidance.
I want to design an escape room that will have multiple games. For simplicity, we will say that each game will have an Arduino associated with it.
In addition to all these Arduinos, I want to develop an application that manages the interaction with all these Arduinos, that is, that communicates with them. It would act as a master and the rest of the Arduinos would be "slaves", being the PC application the one that would have control of what is happening with the Arduinos and the one that, additionally, could make decisions by sending data to the Arduinos to, for For example, configure the path by adding or eliminating games to solve depending on whether the weather is good or bad.
How can I set up this communication between the PC and the arduinos? Investigating I have seen how they communicate through the Serial protocol and I have made a program through which I can, from the PC, turn on an arduino led (port 13) or receive data from the arduino. But of course, if I want to build a scheme with many arduinos, I understand that I can't use the Serial protocol because I understand that a PC does not have as many serial ports as Arduinos would connect.
I don't know if there is a way to generate "virtual COMs" so that each Arduino has its assigned port, even though they all go to the same COM port on the PC.
On the other hand, I have read that there is the I2C protocol that can be a good option for all this, but I am very green and I don't know where to start.
Hi,
Some questions and suggestions about your project.
You say you'll be using multiple arduinos. Right?
Yes, one per game
How far from the PC will these arduino be?
As it will be a small room, probably distance between PC and Arduinos will not be longer than 10 metras
Need to stay physically connected to the PC?
What I want is to control the whole game from a C# application where I can see the progress of the games. This application will also make some calculations in order to detect if the order of the games should be changed (in C# it will be easy). Answering to your question, probably one solution that would avoid the needing of physical connection could be Wifi, but I'm not sure if it's a good solution because I imagine that in case the net is down, I will have a great problem
You can use serial with several devices, but using the RS485 protocol (RS232/RS485 modules), which allows a master to connect to several slaves.
It sounds good, I will investigate about it
The Hardwarw of this protocol allows up to 100m of cables in total.
Do you mean 100 m distance from the PC to the Arduino or you are referring to a 100 m TOTAL cable (for example, 10 cables 10 metres long each)?
You can also make the PC a server and use ESP8266 or ESP32 instead of arduinos and communicating via WiFI.
I was trying to avoid WIFI understanding that a net down could occur and I don't know how should I solve it
RS485 only works well in a multidrop bus configuration.
What that means is that the wiring needs to go from one arduino to the next in a string.
If you want a configuration where there is one Central Arduino and several satellite arduinos connected to the central by separate cables (a star configuration) then you will need something different.
This means there is a central C# application which sends messages to the Arduinos and also receive data from them. If I had only one Arduino, I could do it using Serial Port. When there is more than one, I guess this type of communication is not possible, is it?
Then, the second idea is having a central bus (but I don't know how to make it real:
If my laptop had (an extreme example) 32 COM ports, I guess I could use 32 Arduinos using one COM port for each one of them, and then communication via serial port would be easy.
As this is not the case (I only have 2 COM ports in my laptop), It can not be done, unless there is a solution to get more "virtual" COM ports or something similar
PS: Sorry, I will check, but I thing the total is 1000m.
Pag 2
Key RS-485 Requirements
The key features are:
• Differential (Balanced) Interface
• Multipoint Operation
• Operation from a single +5V Supply
• −7V to +12V Bus Common Mode Range
• Up to 32 Unit Loads (Transceivers)
• 10 Mbps Maximum Data Rate (@40 feet) 4000 Foot Maximum Cable Length (@100 kbps)
the first image is the hub and spoke/star topology approach, you need one interface per device.
If you want a UART based interface You could use an USB hub and attach as many arduino as you want, each would be seen by your c# app on the PC on a dedicated COM port. As the port is not guaranteed to be always the same you'll probably need to come up with a way for each arduino to identify itself and there is no arduino to arduino communication, everything goes through the PC