Search code examples
serial-portarduinorxtxmodbus

Prevent Serial.Print to convert data to ASCII


I would like to create a ModBus-like communication between Arduinos (WITHOUT any RS232/RS485 module). But the Serial.print(data); convert data to ASCII Human Readable data. I would like to keep the "Byte" format between arduinos.

Does someone know how to remove this conversion? Is it a simple parameter to change or do I have to create a library?

NOTE: I would like to use a modbus because I have 3 or more arduinos to control.

NOTE: I do not use I2C because I have to control I2C servos on a third Arduino.

Thanks.


Solution

  • The print function is used to send data in an ASCII encoding; if you want to send the bytes use the write function:

    http://arduino.cc/en/Serial/write

    e.g.

    char mybuffer[] = {2, 4, 8, 3, 6};
    Serial.write(mybuffer, 5);