Hello guys i ma trying to built a connection MAX485 TTL To RS485 Converter Module Board between the nanos (master and slave) that send data over 150m with a CAT 6 A and B pins on the rs485 (there are two of then, my pins connect are rx0 to RO and tx1 to DI and the last one the control in D4 to RE.
and then my slave (receiver) dont response to the master(transmiter) data sending
can someone tell me or fix my code
here you go:
Transmitter/Master code:
int enablePin = 4;
int potval =0 ;
void setup()
{
Serial.begin(9600); // initialize serial at baudrate 9600:
pinMode(enablePin, OUTPUT);
Serial.print("Transmitter Nano");
delay(3000);
digitalWrite(enablePin, HIGH); // (always high as Master Writes data to Slave)
}
void loop()
{
Serial.print("Sent Value= ");
Serial.println(potval); //Serial Write POTval to RS-485 Bus
Serial.print("Sent Value");
Serial.print(potval);
delay(1000);
potval+=1;
}
Slave/receiver code:
int enablePin = 4;
void setup()
{
Serial.begin(9600);
pinMode(enablePin, OUTPUT);
Serial.print("Circuito ativo");
Serial.print("slave Nano");
delay(3000);
digitalWrite(enablePin, LOW);
}
void loop()
{
while (Serial.available())
{
int pwmval = Serial.parseInt();
Serial.print("tenho o valor definido");
Serial.println(pwmval);
Serial.print("valor recebido");
delay(1000);
}
}
Hello there, thanks for replaying. I updated the post with photos, the schematic and the real photo. So you can see more clearing i also puted the pins the the post clear for you can see what are the pins i am using!
Hello there and sorry for late response i was working, i need to both of modules comunicate together, i only gonna use nanos or megas so the code should be generic for both .. and also later i will connect then to a relay 8 channel
Looking at your picture in relation to your fritzing diagram i think you seem to think that the hole on one side of the valley in your breadboard are connected to the holes on the other side. With most breadboards this is not the case. This results in the DE & !RE to be connected to each other through a resistor, but to nothing else.
Also if you do a 2 way communication you should not use a 120R terminator, but on you picture this is on the other side of the valley and therefore more than likely not connected.
That could be true, no markings on the protoboard to show.
@as7rx
Can you check the continuity of the protoboard and the way the rows and columns are connected.
First just measure the voltage at Vcc and gnd points on the 485 modules, make sure you can measure a voltage there.