Home e-Manual

Data transfer (RX-TX) Arduino UNO to OpenCM9.04

Hello everyone, I am trying to transfer some data from Arduino UNO to OpenCM board using the below example sketch (Arduino IDE software). It seems the OpenCM9.04 is not receiving any data, however the same code is fine while using with two arduino boards (UNO, and Mega). The hardware connection of Arduino UNO and OpenCM9.04 is shown in figure.

Hardware connection

Example Code

> //Serial_communication_sender code
>      char mystr[5] = "Hello"; //String data
>      char k[3]="345";
 
void setup() {
  // Begin the Serial at 115200 Baud
  Serial.begin(115200);
}

void loop() {
  Serial.write(mystr,5); //Write the serial data
  Serial.write(k,3);
  delay(1); 
}

.

//Serial communication receiver code 
    char mystr[10]; //Initialized variable to store received data
        char k[3];

    void setup() {
      // Begin the Serial at 115200 Baud
      Serial.begin(115200);
    }

    void loop() {
      Serial.readBytes(mystr,5); //Read the serial data and store in var
      Serial.readBytes(k,3);
      
      Serial.println(mystr); //Print data on Serial Monitor
      Serial.println(k); 
      delay(100);
    }

It would be grateful if anyone can suggest or help me that where I am doing wrong and how the data can be transferred between these two boards. Thanks in advance

I am pretty sure Serial1 (UART0) on the OpenCM9.04 is connected to the dynamixel servos.

If you want to send serial coms to the OpenCM9.04 you will need to recive them on serial2 see the manual for the pin out OpenCM 9.04

2 Likes

I have also tested the serial2 (A4, A5 pins) but still the data is not transfering to the OpenCM9.04. In addition, I just knew that the digital I/O pins of OpenCM9.04 supports 3.3V, may be this can be reason as the UNO is sending a signal of around 5V. If really, this voltage difference is the cause of the data transfer then what could be the possible solution to resolve this problem. Or should I have a try with the I2C option…Thank you again.

I would trying using this UART port listed as serial2. Alos you will need to connect via a level shifter or you will damage the OpenCM9.04 with the 5v.

You will need to change the code to open Serial2.begin(115200); and read fro Serial2.readBytes(mystr,5); on the OpenCM9.04 board

You will normally also only read if (Serail2.available()>0) {

2 Likes

I am buying the voltage level shifter module for the OpenCM9.04. and will soon update here about the progress.

I really hadn’t any idea to change the code to serial2, without knowing this may be I wouldn’t be able to see the received data.

yes, I do update the example sketch code accordingly.

Again many many thanks for guiding me.