RS485 to PC/Hyperterminal


I want to control an Arduino down a long cable in a noisy RF enviroment, so I figured RS485 is best (balanced and long cables).

So I’ll used an RS232 to 485 converter on the PC, then as far as I can tell, I connect my cable to a 120? terminating resistor and MAX485 chip, then connect the TTL side of this to my arduino serial pins. I’ll then use MS hyperterminal (until I write some better software) to send it a multi-character string. The arduino then acknowledges the command, works out the command and performs it, then replies to say it’s complete.

Will that work? Do the hyperterminal serial messages via RS232, then converted to RS485 signal make sense to the Arduino or does it have other characters/handshaking stuff that’ll confuse my Arduino sketch, or does it “just work!”?

If I do need data interpretation are there any C/Arduino libraries etc I can use (been randomly looking at modbus libraries and anything that mentions 485 in the description, without it making much sense)? Still a bit confused about the interfacing from a data point of view! In at the deep end with this project at the mo’! :disappointed_relieved:



P.S. Read this, but didn't follow all the code.

Would I really need all that bit to do handshaking?

I'll then use MS hyperterminal (until I write some better software)

There are much better terminal programs than hyperT. e.g putty -

Putty will do! Will it work by just typing a command into putty? Obviously I can turn flow control, XON/XOFF, etc off if required.

I just know hyperterminal better! :~


You can use a terminal soft to test your comms. It´s not a problem. The RS485 only defines a physical layer (voltages), because of that, you need to create a protocol (rules, messages, etc). The code which you can follow in my blog is an example based on a professional product. It´s just an example, but you can create your own. I mean, if you send an "a", you are going to receive an "a" in your Arduino. You don´t need to do anything special... But for sure, create a protocol is the best thing to do. Another example of protocol is modbus over rs485.(

If you use CAN bus in stead of RS485, the controller is going to do all the "dirty" job (messages, rules, CRC, ...) for you. You can follow some examples here ( I´m afraid, at the moment it´s only in spanish.

Regards, ;)


The hardware you’ve drawn should work. As Igor says you really should design a protocol to make the comms reliable. The complexity of said protocol depends on the nature of the application and mostly boils down to how critical the Arduino’s job is.

The example usually put forward here is something like

where the <> are delimiters that allow the Arduino to sync on the data. That’s about all you need if the Arduino is just doing a LED display for fun. If it’s controlling a heart lung machine I’d add a checksum :slight_smile:


As Graynomad says, you can start something as easy as:

  • “S”= START
  • “1” or “0” => command 1=ON, 0=OFF
  • “E” => END (in my chart is F, because end in spanish is FIN…he,he,he)

It´s an easy example that I did to switch ON and OFF a led (Tinkering with Electronics...: LINKDUINO: Linksys + Arduino + Excel-Telnet)

//Mini protocolo serie
//Igor Real

int luz1= 13;
int el1;
int estado=0;
byte dato_recibido;

void setup() {
   pinMode(luz1, OUTPUT);
   pinMode(12, OUTPUT);

void loop()
  //trama a recibir --> S1F o S0F
  //S inicio
  //F fin
  while (Serial.available() > 0)
    //Significa que has recibido algo y lees el primer byte;
    if (dato_recibido=='S' && estado==0){
    if (((dato_recibido=='1')||(dato_recibido=='0')) && estado==1){
      if (dato_recibido=='1')  el1=1;
      if (dato_recibido=='0')  el1=0;
    if (dato_recibido=='F' && estado==2){
      if (el1==0)  Serial.println("APAGADO");
      if (el1==1)  Serial.println("ENCENDIDO");

You can continue adding more features to your messages, for example, the slave address, timeouts if you don´t receive the next char of the message, checksum,…

As I said before, if you use CAN bus, you are going to have a very sophisticated messages and rules that it´s “transparent” for the user (the CAN controller do everything for you).



Ah, great news! I'm putting plenty of error checking into my code already. If it goes wrong then it'll probably lose 2.5kW of RF into the wrong place and set fire to things! I'll make sure it's damn good before then though, and it's more likely that the thing I'm controlling I haven't build yet will catch fire through no fault of the arduino!

Just didn't know if there was other stuff going on in the data, so it would work perfectly fine using the on-board USB and its associated chip, but once trying RS485 via the pins on the chip and a MAX485 if it would seem to be gobbledegook! If that was the case suicide might be one of my better options at this point! XD

Thanks for the help!