Author Topic: Serial communication for ROV.  (Read 369 times)

0 Members and 1 Guest are viewing this topic.

Offline Edvin gjerdeTopic starter

  • Newbie
  • Posts: 1
  • Country: se
Serial communication for ROV.
« on: May 11, 2022, 06:56:31 pm »
I am working on a ROV (remote operated vehicle) and I need to make two arduino cards communicate with Rx and Tx pins. I have test many different codes but nowon have worked. The problem is not the connection between the cards I knows that Rx-> Tx & Tx-> Rx & gind<->gind. You knows any code I can try next?
It is one arduino uno and one arduino mega thats is going to communicate. The konektsons between the board were whid jumperlinks.


sender
char str[4];

void setup() {
  Serial.begin(9600);
}

void loop() {
  int value=1234;
 
  itoa(value, str, 10);
  Serial.write(str, 4);
}

resiver
char str[4];

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() {
  int i=0;

  if (Serial1.available()) {
    delay(100);
    while(Serial1.available() && i<4) {
      str[i++] = Serial1.read();
    }
    str[i++]='\0';
  }

  if(i>0) {
    Serial.println(str,4);
  }
}
excuse my english :)
« Last Edit: May 12, 2022, 06:13:36 pm by Edvin gjerde »
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Serial communication for ROV.
« Reply #1 on: May 11, 2022, 07:34:42 pm »
What is the length of the cable between arduino boards? Do you know that on UNO boards UART pins are also used for virtual serial port while connected on USB, so it will not work while on USB (as far as I remember, I'm not an arduino specialist)?

It would be useful if you could post code which you tried and it was not working. It is hard to say what you should try next, when we don't know what you have tried already. Keep in mind, that while there are tons of badly witten arduino code online, the fact that you have tried many and none worked probably means that the problem is either not the code or there is a need to configure the code in some way for your particular case.
 

Offline SmallCog

  • Frequent Contributor
  • **
  • Posts: 290
  • Country: au
Re: Serial communication for ROV.
« Reply #2 on: May 11, 2022, 11:18:31 pm »
Consider using RS485 if there'll be any length to the cable - I imagine this is likely with an ROV
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf