Serial communication detecting

I am workin on a project. I have two channel for Serial RS232 communication. Main and Stand-By channel. If Main channel has some problem and, cannot communicate for 15 seconds then I want to start Stand-By channel communication. How can I do that? I want to listen to channel's RX with Arduino. I think I can use MAX 232 for Serial to TTL convert. Can I listen to channel's RX with Arduino then Can I decide which channel should work?

Thank you,guys..

Can you show a schematic or a diagram of what equipment is connected and how? For instance, it's crucial to know if the Arduino will be on one end of both Serial channels or if it's a "third party" 'eavesdropping' on communications between two other devices.

In general, what you say could be done by e.g. sending a heartbeat signal over the Serial channel every second or so and if that's no longer picked up by the Arduino, make it do whatever is necessary to switch channels. But how that will work out exactly really depends on what you're connecting together and how.

the diagram would be basicly this. I haveto decide which channel would work. Because of this I think to take the data to Arduino and then I can listen which channel is working. Is it possible? What I need to do?

what is the fact to decide "working" or "not working" ?

Hi, if data is coming from the channel that means it is working. If there is a problem on the channel and the data is not coming for 15 seconds I need to use the other channel for communication.

Well, I think the easiest way to do this is to use an Arduino Mega. The Arduino Mega offers three serial interfaces.

Arduino doesn't has ttl-rs232 converter. I need to convert rs232 data to ttl and then I need to look which channel is active then I need to send active channel's data by using rs232 converter again.

I'm not sure if using the Arduino as a passthrough device as you've drawn it will work well. It might, but there's a risk of timing issues and/or data corruption. You'd have to try.

In your place I would probably choose not to put the Arduino in-between the other 2 devices, let it listen in on what happens on the direct connection between both ends and use a couple of cmos switches to change the channel whenever necessary.

@aalptekin, your topic has been moved to a more suitable location on the forum. InstallationandTroubleshooting is not for problems with your project nor for advice on it :wink:

Hi,guys. I am trying to do a project. The project schematic is on the picture.

I have a device and this devices has two ports. One of them is Main. Another is Standby ports. This devices send data to another devices on rs232 level. Standby port is for, when main channel has a problem, standby channel should work. I need to control this channel. When the data cannot come from main channel for 15 seconds, I need to active the standby channel. How can I control this?

I thought I can take the data to Arduino by using rs232 integrated circuit. And then I can check it which channel is working. Can I do that with Arduino, If not how can I do that?

You would need to know the format of the data coming out of the serial port and check that the data coming out is valid.

What is the actual application ?


If Serial data is not available() (HINT) on the main serial link then start reading on the standby serial link. Use millis() timing throughout the code to avoid blocking its operation

Ideally use an Arduino with more than one hardware UART such as a Mega board

Thanks for posting it according to the my PM response.
You will get a lot of better answers than just ask me. :blush:

So, what does the "main channel problem" you defined?
Is the port completely silence?
Receive corrupted data?
How to confirm that the data is corrupted?

Main channel problem is the data doesn't come. I don't need to control the data is valid or not. I just need to know the data is exist or not.

Important details revealed.

So if the serial port is outputing random data or pin state changes, that is not a 'problem' ?

It is totally not problem for me :slight_smile: If the corrupted data is receiving, the first devices send corrupted data. The problem is it's. Not mine.

Every time you read a byte from the main channel save the value of millis(). Later in loop(), if the current value of millis() minus the last data read saved time ever exceeds 15 seconds then switch to reading from the standby serial link. Once data becomes available from the main link then switch back to reading frim it

@UKHeliBob is heading in a good direction…
I’d take that a step farther, requiring three good packets before deciding that a source is valid.

There’s no harm validating the data from both sources - even when they’re ‘offline’, then you can warn the user if either of the data sources is not working as expected…
GREEN = both data sources are verified…
FLASHING = active source is good, but the other isn’t working…
RED or off = neither data source is available.
A second LED could indicate which source is ‘actively being used’.
( With RG LEDs, you can think of other combinations using YEL. )

Before going too much further, my advice would be to avoid SoftwareSerial.
It’s fun and useful for some things, but not the basis of a failover system.

This suggests a MEGA2560 or other platform that provides multiple hardware UARTs.

1 Like

The definition of three good packets should make for an interesting discussion :grinning:

1 Like

It getting funny. :wink:

Are the two ports always sending exactly the same data when good conditions?
Furthermore, how much is the timing difference?
And what is the permissible lag between Arduino receiving data and transferring it to your PC?