Send a command to multiple boards through serial ports

Hi, im a little bit lost here. I have 5 stm32 boards that i use to messure flow. I want to send a command to reset them at the same time ( it can be 5ms between each command).
I read that is possible to send commands for multiple boards, but dont know wich arduino model use, and how to connect.

Sure - you can connect multiple receivers to one transmitter.
But what you can't do is just connect multiple transmitters to one receiver - because that would short all the transmitters together.

So, although you can easily send a command to multiple devices - you can't so easily receive all their responses to that command.

If you're happy to just blindly "send and hope", then just connect the TX out from the sending Arduino to all the RX ins of all the receiving Arduinos.

which family type and the device?

STM32s usually have several hardware serial ports, may be 5 serial ports...

1 Like

So how do you currently communicate with them?

Currently i communicate one by one via serial port with a terminal series in my pc. Using only 3 cables ( green, white and black).

Hello sisfer

Connect all GND lines together and all reset lines together and now you can reset all MCUs at the same time.

Have a nice day and enjoy coding in C++.

1 Like

I understand that you have five serial ports open at your PC in parallel to communicate with the boards. Is that correct?

If yes you could write a Python script that opens the five COMs and transmits a Reset command via Serial to the five boards.

But it would require that you close the terminal communication before you start the script to free the COMs.

1 Like

Sorry, i think i my explanation was confusing. I have 1 serial port open at my pc.

They have 5 serial port, but i only need to use 3.

Ok.

Then "goto @paulpaulson" ... :wink:

Post a blockdiagram simply.

A picture is worth a thousand words.

2 Likes

So you're plugging & unplugging the sensors in turn?

What do you mean by that?

Another example where I diagram would be so much clearer!

The requirement sounds simple

1 PC with 1 serial port is required to send a command to 5 separate boards either simultaneously or within 5ms of each other and that command should cause each of the boards to reset

As to why this is required is open to question

I connected the tx of the arduino to the rx of the boards. It is possible for me to send commands trough the serial monitor? Or do i have to make a code that sends the command preseted?

The Serial monitor has an input box. Type the command in there then press Enter to send it

1 Like

The serial monitor Command you type will arrive on the Rx of the arduino connected to the PC. You would have to copy over (to Tx) what you received so that it’s forwarded to the other boards.

int r ;
while ((r = Serial.read()) != -1) Serial.write(r); // pass data from Rx to Tx

Just to clarify if possible.

You are using a PC to send commands to 5 stm32 boards, presumably this is done by addressing each board and issuing a command.

However what you are wanting to do, is to use an Arduino to control all 5 at the same time, so there is no lag between devices?

If so, my next question would be, do you have a set sequence of commands used all the time, or are you sending commands based on variable inputs?

A post was split to a new topic: What is the best way to make a RS-485 network?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.