Initial notes on using MAX485 based TTL-to-RS485 adapter boards with Arduino or Raspberry Pi

; Date: Sun Jul 02 2017

Tags: MODBUS »»»» Raspberry Pi »»»» Arduino

I've been looking for an inexpensive but robust way to connect an inexpensive embedded computer to an RS485 network. The MAX485 based interface boards look enticingly inexpensive, and claim to be easy to connect. They should be more reliable than a USB RS485 adapter, because the MAX485 boards are hardwired to GPIO pins. It took much searching to find any advice about connecting these adapters to a computer. The board I received was marked DI/DE/RE/RO on one end, and Vcc/A/B/GND on the other. The latter is clear, that's power and the RS485 pins, but what could the other end mean.

For this project I do not have working code. Instead this post is about noting a useful resource explaining how to use the MAX485 based TTL-RS485 adapters.

Earlier I'd posted how to use an USB RS485 adapter to read data from a simple MODBUS device: Read a MODBUS temperature sensor through USB-RS485 adapter on Ubuntu and Raspberry Pi And how to read that same MODBUS device from an Arduino using an RS485 shield: Using an Arduino to read a simple MODBUS/RTU RS-485 temperature sensor

Both of those were simple to implement and read from that simple device. One thing that stood out using the two USB RS-485 adapters I have is how unreliable they are. After awhile the host computer would stop recognizing the adapter, and I'd have to reboot the computer. This is unacceptable for the typical MODBUS use case, which is industrial control devices. As a result I've been looking for a more reliable RS485 interface board.

Amazon search for ( MAX485 based TTL-to-RS485 interfaces

The MAX485 chip is made by Maxim Integrated, a large integrated circuit maker.

The manufacturer home page for the interface board I have says nothing about how to use the interface board. Literally nothing. I was able to find the Maxim Integrated datasheets and other information.

Block diagram of using several MAX485 chips to form an RS485 network

This diagram shows four MAX485 chips wired to form an RS485 network. That's great, and it even shows the DI/DE/RE/RO signal pins. That explains what the pins on that end of the board are, but it doesn't explain how to use this to interface with a computer.

The MAX485 signal pins

And this explains what the MAX485 signal pins are, on the MAX485 chip itself. The two ends of the board I have contain 8 signal pins total, and it seems likely those simply correspond to the MAX485 pins. This explains that the DE/RE lines enable input/output functions, while the DI and RO lines are where input/output occurs.

That's close. But it's not everything.

This page has the key: ( rs485-communication-between-arduino-mega-and-arduino-pro-mini.html

It shows a GPIO pin (pin 8) being used as input to both the DE/RE lines to disable/enable both by setting the one pin high or low. The UART's TX/RX lines are connected to the DI/RO pins on the interface board. There's a bit of Arduino code to send regular text over the RS485 network. That's nice, but of course I want to run MODBUS over the interface and it's not clear where to go from here.

Well, there's enough clues to begin to do something, but I'll have to leave that for another day. The outline of the idea is:

#include <ModbusMaster.h>

void setup() {
    // use Serial (port 0); initialize Modbus communication baud rate

    // communicate with Modbus slave ID 255 over Serial (port 0)
    node.begin(1, Serial);

    pinMode(8, OUTPUT);

void loop() {
    digitalWrite(8, HIGH);
    result = node.readInputRegisters(1, 1);
    if (result == node.ku8MBSuccess) {
        tp_modbus = node.getResponseBuffer(0);
    tp_status = result;
    digitalWrite(8, LOW);

That's what I plan to start with ...

About the Author(s)

( David Herron : David Herron is a writer and software engineer focusing on the wise use of technology. He is especially interested in clean energy technologies like solar power, wind power, and electric cars. David worked for nearly 30 years in Silicon Valley on software ranging from electronic mail systems, to video streaming, to the Java programming language, and has published several books on Node.js programming and electric vehicles.