Skip to content

Commit 5ca2b37

Browse files
committed
v1.0.6
* Added support for both hardware and software serial ports. * Updated examples.
1 parent c5ffea4 commit 5ca2b37

19 files changed

+1261
-465
lines changed

.vscode/arduino.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"board": "esp32:esp32:esp32doit-devkit-v1",
3+
"sketch": "examples\\RS485Passthrough\\RS485Passthrough.ino",
4+
"configuration": "FlashFreq=80,UploadSpeed=921600,DebugLevel=none,EraseFlash=none",
5+
"port": "COM24"
6+
}

.vscode/c_cpp_properties.json

Lines changed: 580 additions & 0 deletions
Large diffs are not rendered by default.

README.adoc

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
:repository-owner: arduino-libraries
2-
:repository-name: ArduinoRS485
1+
:repository-owner: CIRCUITSTATE
2+
:repository-name: CSE_ArduinoRS485
33

44
= {repository-name} Library for Arduino =
55

6-
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-arduino.yml/badge.svg["Check Arduino status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-arduino.yml"]
7-
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/compile-examples.yml/badge.svg["Compile Examples status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/compile-examples.yml"]
8-
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/spell-check.yml/badge.svg["Spell Check status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/spell-check.yml"]
6+
This Arduino library allows you to send and receive data using the **RS-485** interface standard. Supported by all Arduino-compatible boards such as ESP32, STM32, RP2040, AVR, SAMD, ESP8266, etc. You can use both hardware and software serial ports. This library supports the Maxim Integrated MAX485 and equivalent chipsets.
97

10-
Enables sending and receiving data using the RS-485 standard with RS-485 shields, like the MKR 485 Shield.
8+
Three examples are included with this library:
119

12-
This library supports the Maxim Integrated MAX3157 and equivalent chipsets.
10+
* **RS485_Sender** - Sends data to a receiver.
11+
* **RS485_Receiver** - Receives data from a sender.
12+
* **RS485_Passthrough** - Sends and receives data between the RS-485 port and the default serial port.
13+
14+
This library is a fork of the ArduinoRS485 library by Arduino, and is maintained by **CIRCUITSTATE**.
15+
16+
* https://github.com/arduino-libraries/ArduinoRS485[ArduinoRS485 Library by Arduino]
17+
* https://www.arduino.cc/reference/en/libraries/arduinors485/[ArduinoRS485 documentation by Arduino]
18+
* https://www.circuitstate.com/tutorials/what-is-rs-485-how-to-use-max485-with-arduino-for-reliable-long-distance-serial-communication/[RS-485 tutorial by CIRCUITSTATE]
19+
* https://www.circuitstate.com/pinouts/max485-cd4069-rs-485-module-with-auto-data-direction-control-pinout-diagram-and-pin-reference/[MAX485+CD4069 Module Pinout by CIRCUITSTATE]
1320

14-
For more information about this library please visit us at
15-
http://www.arduino.cc/en/Reference/{repository-name}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
RS-485 Passthrough.
3+
4+
This sketch relays data sent and received between the Serial port and the RS-485 interface.
5+
6+
Originally created by Sandeep Mistry, on 4 July 2018.
7+
Modified by @vishnumaiea for CIRCUITSTATE Electronics (@circuitstate).
8+
9+
Source: https://github.com/CIRCUITSTATE/CSE_ArduinoRS485
10+
*/
11+
12+
#include <CSE_ArduinoRS485.h>
13+
14+
// Declare the RS485 interface here with a hardware serial port.
15+
RS485Class RS485 (Serial1, 2, 3, 4); // DE, RE, TX
16+
17+
/* // If you want to use a software serial port, declare it here,
18+
// comment out the previous declaration, and uncomment this section.
19+
#include <SoftwareSerial.h>
20+
21+
SoftwareSerial mySerial (10, 11); // RX, TX
22+
RS485Class RS485 (mySerial, 2, 3, 4); // DE, RE, TX */
23+
24+
void setup() {
25+
Serial.begin (9600);
26+
RS485.begin (9600);
27+
28+
// Enable transmission. Can be disabled with: RS485.endTransmission();
29+
RS485.beginTransmission();
30+
31+
// Enable reception. Can be disabled with: RS485.noReceive();
32+
RS485.receive();
33+
}
34+
35+
void loop() {
36+
if (Serial.available()) {
37+
RS485.write (Serial.read());
38+
}
39+
40+
if (RS485.available()) {
41+
Serial.write (RS485.read());
42+
}
43+
}

examples/RS485Passthrough/RS485Passthrough.ino

Lines changed: 0 additions & 44 deletions
This file was deleted.

examples/RS485Receiver/RS485Receiver.ino

Lines changed: 0 additions & 37 deletions
This file was deleted.

examples/RS485Sender/RS485Sender.ino

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
RS-485 Receiver.
3+
4+
This sketch prints any data received from the RS-485 interface to the Serial port.
5+
6+
Originally created by Sandeep Mistry, on 4 July 2018.
7+
Modified by @vishnumaiea for CIRCUITSTATE Electronics (@circuitstate).
8+
9+
Source: https://github.com/CIRCUITSTATE/CSE_ArduinoRS485
10+
*/
11+
12+
#include <CSE_ArduinoRS485.h>
13+
14+
// Declare the RS485 interface here with a hardware serial port.
15+
RS485Class RS485 (Serial1, 2, 3, 4); // DE, RE, TX
16+
17+
/* // If you want to use a software serial port, declare it here,
18+
// comment out the previous declaration, and uncomment this section.
19+
#include <SoftwareSerial.h>
20+
21+
SoftwareSerial mySerial (10, 11); // RX, TX
22+
RS485Class RS485 (mySerial, 2, 3, 4); // DE, RE, TX */
23+
24+
void setup() {
25+
Serial.begin (9600);
26+
while (!Serial);
27+
28+
RS485.begin (9600);
29+
30+
// Enable reception. Can be disabled with: RS485.noReceive();
31+
RS485.receive();
32+
}
33+
34+
void loop() {
35+
if (RS485.available()) {
36+
Serial.write (RS485.read());
37+
}
38+
}
39+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
RS-485 Sender
3+
4+
This sketch periodically sends a string over the RS-485 interface
5+
6+
Originally created by Sandeep Mistry, on 4 July 2018.
7+
Modified by @vishnumaiea for CIRCUITSTATE Electronics (@circuitstate).
8+
9+
Source: https://github.com/CIRCUITSTATE/CSE_ArduinoRS485
10+
*/
11+
12+
#include <CSE_ArduinoRS485.h>
13+
14+
int counter = 0;
15+
16+
// Declare the RS485 interface here with a hardware serial port.
17+
RS485Class RS485 (Serial1, 2, 3, 4); // DE, RE, TX
18+
19+
/* // If you want to use a software serial port, declare it here,
20+
// comment out the previous declaration, and uncomment this section.
21+
#include <SoftwareSerial.h>
22+
23+
SoftwareSerial mySerial (10, 11); // RX, TX
24+
RS485Class RS485 (mySerial, 2, 3, 4); // DE, RE, TX */
25+
26+
void setup() {
27+
// Initialize the RS485 interface
28+
RS485.begin (9600);
29+
}
30+
31+
void loop() {
32+
RS485.beginTransmission();
33+
RS485.print ("Hello ");
34+
RS485.println (counter);
35+
RS485.endTransmission();
36+
37+
counter++;
38+
39+
delay (1000);
40+
}

keywords.txt

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
#######################################
2-
# Syntax Coloring Map For ArduinoRS485
2+
# Syntax Coloring Map For CSE_ArduinoRS485
33
#######################################
44

55
#######################################
66
# Datatypes (KEYWORD1)
77
#######################################
88

9-
ArduinoRS485 KEYWORD1
10-
RS485 KEYWORD1
9+
RS485Class KEYWORD1
1110

1211
#######################################
1312
# Methods and Functions (KEYWORD2)
1413
#######################################
1514

16-
begin KEYWORD2
17-
end KEYWORD2
18-
peek KEYWORD2
19-
read KEYWORD2
20-
flush KEYWORD2
21-
write KEYWORD2
15+
begin KEYWORD2
16+
end KEYWORD2
17+
peek KEYWORD2
18+
read KEYWORD2
19+
flush KEYWORD2
20+
write KEYWORD2
2221

23-
beginTransmission KEYWORD2
24-
endTransmission KEYWORD2
25-
receive KEYWORD2
26-
noReceive KEYWORD2
27-
sendBreak KEYWORD2
28-
sendBreakMicroseconds KEYWORD2
29-
setPins KEYWORD2
22+
beginTransmission KEYWORD2
23+
endTransmission KEYWORD2
24+
receive KEYWORD2
25+
noReceive KEYWORD2
26+
sendBreak KEYWORD2
27+
sendBreakMicroseconds KEYWORD2
28+
setPins KEYWORD2
3029

3130
#######################################
3231
# Constants (LITERAL1)

0 commit comments

Comments
 (0)