Microduino-Module RS485
From Microduino Wiki
(Redirected from Microduino-RS485)
Language: | English • 中文 |
---|
Microduino- RS485 is a low-power serial communication module based on MAX485 chip, which can achieve bidirectional serial port data transmission.
ContentsFeatures
Specification
Document
DevelopmentThe 485 communication interface is a hardware description for the communication interface. It needs only two communication lines, which can transmit data among two or more devices. And the connection for this data transmission is the half-duplex communication mode, that means in a certain moment, one device can only send or receive data. In hardware, you can select the serial communication by the toggle switch. Meantime, you need program to achieve data transmission among different serial ports through the 485 protocol. Application
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(9, 10); //RX,TX
String comdata_rec = ""; //Character string displayed.
String onedata_rec = ""; //Judge "clean" cache character string.
String comdata_send = ""; // Character string displayed.
String onedata_send = ""; // Judge "clean" cache character string.
String serialdata_rec="";
String serialdata_send="";
void setup()
{
Serial.begin(9600);
Serial1.begin(115200);
}
void loop() // run over and over again
{
while (Serial.available() > 0)
{
comdata_rec = ""; //Clear the character.
serialdata_rec = "";
onedata_rec += char(Serial.read()); //Read the character
comdata_rec += onedata_rec; // Read the character
delay(30);
}
if( serialdata_rec!=comdata_rec)
{
onedata_rec = ""; //Clear the cache character string
serialdata_rec=comdata_rec;
Serial1.print(comdata_rec);
}
while (Serial1.available() > 0)
{
comdata_send = ""; ///Clear the character
serialdata_send = "";
onedata_send += char(Serial1.read()); // Read the character
comdata_send += onedata_send; /// Read the character
delay(30);
}
if( serialdata_send!=comdata_send)
{
onedata_send = ""; // Clear the cache character string
serialdata_send=comdata_send;
Serial.println(comdata_send);
}
}
PurchaseHistoryPicture
Video |