I’m try to get data from rs485 is not work please advise to me.
1. Try to connect PC usb485 to DY-MD02 is work.
Send command “AUTO” or “READ”
2. Try to Arduino rs485 shield to DY-MD02 is not work.
Send command “AUTO”
my code
''''
char command[4] = {'A', 'U', 'T', 'O'};
int n = sizeof(command)/sizeof(command[0]); // Number of elements in an array
String incoming = ""; // for incoming serial string data
void setup()
{
// initialize serial ports
Serial.begin(9600);
pinMode(EN,OUTPUT);
digitalWrite(EN,HIGH); //Enable high, RS485 shield waiting to transmit data
Serial.write(command,n); //Test send command Auto,Read to RS485
delay(500);
}
void loop()
{
String temp;
digitalWrite(EN,LOW); //Enable low, RS485 shield waiting to receive data
while(Serial.available() > 0 )
{
temp=Serial.read();
Serial.println(temp);
delay(1000); //Delay for some time, waiting for data transmitted
}
}
''''
if change code to = Serial.readString() not show anything.
please help me Thank
to Juraj
Maker tell me can connect with Arduino uno and send manual to me.
see in attach file.
end of line
characters (\r\n) at the end.readString
function fetch the character value step by step and store them in buffer tillEOL
character are received. After receivingEOL
character it returns the string. – Vaibhav Jun 10 '19 at 8:00