I don't know anymore on to connect an RS485 to MAX485

Please help me. I did everything. So, I have an RS485 (pH sensor) and MAX485. The RS485 (pH sensor) needs to receive data to the MAX485. My first try is not working when I diagnostic tested it and said is failed. By the second try is I fix the wirings, but failed. By the third try is I fix thr wirings of MAX 485 and still failed. By the fourth try where I fix the RS485's wirings, but still failed. By the sixth try where I fix the connection between the RS485 and MAX 485, but failed. Then, I tested RS485 and MAX485 with no breaboard and just Arduino UNO R4 WiFi, but still failed. I don't know what to do now. I try with the AI's help (which is Claude AI) and it doesn't know what to do. I bought another MAX485 and still in this situation. What's the problem here because I tested and diagnostic test it and still failed. I give up and need help on this forum please?

Please read - How to get the best out of this forum

and provide all information you have, code, schematic, sensor specification etc.

Welcome to forum.
You wrote seven times it failed but not What failed.
How is your wiring exactly done, what code you use and what's the output with that code?

what host microcontroller are you using?
are you using a RS485 module, e.g.

or have you built a PCB with an onboard MAX485

Hi @dannyflarence !

"I did it right and it worked immediately."

Would you consider this answer helpful? I guess not.

But it is mirroring your failure description...:slight_smile:

If you want sound help please supply all relevant information:

Software:

  • Development environment (Arduino IDE? Version?)
  • Sketch used for testing

Hardware: (brand and type, at least a link to an internet source)

  • Controller board
  • RS485 interface
  • Sensor
  • Drawing of the wiring (can be manually drawn)
  • Power supply

Please post your sketch inside code tags:

image

It will speed up things!
ec2021

*Welcome!
Apparently, you did not properly "fix the wiring." The number of different ways you have tried connecting it indicates that it is probably still wired incorrectly, or you may have damaged something in the process.

Post an annotated schematic showing exactly how you wired your project. Be sure to include links to each hardware device that provide the technical details.

At this point, I am assuming you are using an UNO.

RS485 needs to SEND data TO the MAX485.

Be sure you are connecting the 485 devices for SIMPLEX communication (link HERE).

(NOT half-duplex or full duplex, unless data is to be sent and received)

Simplex SENDER (from here):

// Sender Code
#include <SoftwareSerial.h>
 
// Define the pins for the MAX485
#define DE 3
#define RE 2
 
// Create a SoftwareSerial object to communicate with the MAX485
SoftwareSerial RS485Serial(10, 11); // RX, TX
 
void setup() {
  // Initialize the serial communication
  Serial.begin(9600);
  RS485Serial.begin(9600);
 
  // Set the DE and RE pins as outputs
  pinMode(DE, OUTPUT);
  pinMode(RE, OUTPUT);
 
  // Set DE and RE high to enable transmission mode
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
}
 
void loop() {
  // Generate random data
  int data = random(0, 100);
 
  // Send data over RS485
  RS485Serial.write(data);
 
  // Print the sent data to the serial monitor
  Serial.print("Data sent: ");
  Serial.println(data);
 
  // Wait for a while before sending the next data
  delay(2000);
}

Simplex RECEIVER (from here):

// Receiver Code
#include <SoftwareSerial.h>
 
// Define the pins for the MAX485
#define DE 3
#define RE 2
 
// Create a SoftwareSerial object to communicate with the MAX485
SoftwareSerial RS485Serial(10, 11); // RX, TX
 
void setup() {
  // Initialize the serial communication
  Serial.begin(9600);
  RS485Serial.begin(9600);
 
  // Set the DE and RE pins as outputs
  pinMode(DE, OUTPUT);
  pinMode(RE, OUTPUT);
 
  // Set DE and RE low to enable receiving mode
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);
}
 
void loop() {
  if (RS485Serial.available()) {
    // Read the received data
    int receivedData = RS485Serial.read();
 
    // Print the received data to the serial monitor
    Serial.print("Data received: ");
    Serial.println(receivedData);
 
    // Print a successful message
    Serial.println("Data successfully received.");
  }
}

rereading post 1 the dev board is a UNO R4 WiFi

program connecting UNO R4 WiFi to a RS485 module then via RS485 to a FDTI RS485 cable


// UNO R4 Serial1 to RS485 bus

// uNO R4 Serial uses USB  Serial1 uses D1/TX and D0/RX

// connections
// UNO R4 5V to RS485 VCC
// UNO R4 GND to RS485 GND
// UNO R4 Serial1 Receive D0/RX to RS485 RO  (Receiver Output) /RXD
// UNO R4 Serial1 Transmit D1/TX to RS485 DI  (Driver Input) /TXD
// UNO R4 D2 to RS485 DE
// UNO R4 D3 to RS485 RE

// see https://microcontrollerslab.com/rs485-serial-communication-arduino-tutorial/

#define RS485Serial Serial1  // hardware serial port on ESP32

// some RS485 modules automatically switch between transmit and receive DE/RE not defined
// RS485 DE (Driver Enable set HIGH to enable)  and RE (Receiver Enable set LOW to enable)
#define DE 2  //RS485 Direction control pin
#define RE 3  //RS485 Direction control pin

#define RS485Transmit HIGH
#define RS485Receive LOW

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("\n\nUNO R4 connect to RS485 bus - enter/receive text");
  Serial.println("UNO R4 Serial1 Receive D0/RX to RS485 RO  (Receiver Output) /RXD");
  Serial.println("UNO R4 Serial1 Transmit D1/TX to RS485 DI  (Driver Input) /TXD");

#ifdef DE  // if DE and RE are defined
  pinMode(DE, OUTPUT);
  pinMode(RE, OUTPUT);
  digitalWrite(DE, RS485Receive);  // Disable RS485 Transmit
  digitalWrite(RE, RS485Receive);  // Disable RS485 Transmit
#endif
  RS485Serial.begin(115200, SERIAL_8N1);  //, RXD2, TXD2);  // set the RS485 data rate
}

// loop sending data to RS485 and receiving data
void loop() {
  if (Serial.available()) {           // Arduino Serial data avaliable?
#ifdef DE                             // if DE and RE are defined
    digitalWrite(DE, RS485Transmit);  // Enable RS485 Transmit
    digitalWrite(RE, RS485Transmit);  // Enable RS485 Transmit
#endif
    RS485Serial.write(Serial.read());  // Send byte to Remote RS485
    RS485Serial.flush();               // wait for byte to be transmitted
#ifdef DE                              // if DE and RE are defined
    digitalWrite(DE, RS485Receive);    // Disable RS485 Transmit
    digitalWrite(RE, RS485Receive);    // Disable RS485 Transmit
#endif
  }

  if (RS485Serial.available())         // RS485 serial data available?
    Serial.write(RS485Serial.read());  // read character and display it
}

UNO R4 WiFi serial monitor output as text is enter on Teraterm and UNO R4

UNO R4 connect to RS485 bus - enter/receive text
UNO R4 Serial1 Receive D0/RX to RS485 RO  (Receiver Output) /RXD
UNO R4 Serial1 Transmit D1/TX to RS485 DI  (Driver Input) /TXD
hello from teraterm
test2 from teraterm
test3 from teraterm 0987654321

Teraterm output (baudrate set to 115200)

photo

a USB-RS485 module such as the FTDI RS485 module used above is very useful for testing the RS485 bus and monitoring traffic

can you show us a photo of your MAX485 and wiring?