G
G
gmg2017-02-23 12:45:10
Arduino
gmg, 2017-02-23 12:45:10

MAX485 not working on arduino mega2560?

Good afternoon.
I made a network using 3 arduino. Master (mega) and two slaves (nano). So from the slave I send data to the master, but nothing comes.
I change mega to uno and exactly the same sketch works.
Master sketch

#include <SoftwareSerial.h>
#include <ArduinoJson.h>

byte DERE = 8; // DE RE

SoftwareSerial RS485 = SoftwareSerial(7, 6); // pin 7 - RO, pin 6 - DI

void setup() {
      Serial.begin(9600);
      RS485.begin(4800);
      pinMode(DERE, OUTPUT);
}

void loop() {
      if (RS485.available()) {
         Serial.println(RS485.read());
      }
}

In general, no information comes. Although I'm sure it was sent.
What can be a jamb?
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
hotfatboiiii, 2021-10-14
@hotfatboiiii

this question is several years old, but please if you found a solution, post it, exactly the same problem that I can not solve for several weeks

A
asuv, 2021-11-10
@asuv

There is not enough information in the question, but as a possible variant of the problem, the following is: as far as I understand, the RS485 network on the MAX485 for 3 Arduins Mega does not work ... it is quite possible that these Arduinos are powered from the same power source ... try using an individual power source (I'm talking about 220V to 5V converter) for each Arduino ... this caused me to not work ...

M
MrJet123, 2022-04-13
@MrJet123

Known limitations of the SoftwareSerial library include the following:
When using multiple serial ports, only one of them can receive data at a time
on the Arduino Mega and Mega2560 boards, some pins do not support level-change interrupts. Because of this, on these boards, only the following pins can be used as an RX pin: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64 ), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).
I used the same pins as you, it doesn’t work with them) I connected 10, 11 and everything started up.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question