File tree Expand file tree Collapse file tree 3 files changed +120
-0
lines changed Expand file tree Collapse file tree 3 files changed +120
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ RS485 Passthrough
3
+
4
+ This sketch relays data sent and received between the Serial port and the RS485 interface
5
+
6
+ Circuit:
7
+ - MKR board
8
+ - MKR 485 shield
9
+ - ISO GND connected to GND of the 485 device
10
+ - Y connected to A of the 485 device
11
+ - Z connected to B of the 485 device
12
+ - A connected to Y of the 485 device
13
+ - B connected to Z of the 485 device
14
+ - Jumper positions
15
+ - FULL set to ON
16
+ - Z \/\/ Y set to ON, if the 485 device doesn't provide termination
17
+ - B \/\/ A set to ON, if the 485 device doesn't provide termination
18
+
19
+ created 4 July 2018
20
+ by Sandeep Mistry
21
+ */
22
+
23
+ #include < RS485.h>
24
+
25
+ void setup () {
26
+ Serial.begin (9600 );
27
+ RS485.begin (9600 );
28
+
29
+ // enable transmission, can be disabled with: RS485.endTransmission();
30
+ RS485.beginTransmission ();
31
+
32
+ // enable reception, can be disabled with: RS485.noReceive();
33
+ RS485.receive ();
34
+ }
35
+
36
+ void loop () {
37
+ if (Serial.available ()) {
38
+ RS485.write (Serial.read ());
39
+ }
40
+
41
+ if (RS485.available ()) {
42
+ Serial.write (RS485.read ());
43
+ }
44
+ }
45
+
Original file line number Diff line number Diff line change
1
+ /*
2
+ RS485 Receiver
3
+
4
+ This sketch receives data over RS485 interface and outputs the data to the Serial interface
5
+
6
+ Circuit:
7
+ - MKR board
8
+ - MKR 485 shield
9
+ - ISO GND connected to GND of the 485 device
10
+ - A connected to A/Y of the 485 device
11
+ - B connected to B/Z of the 485 device
12
+ - Jumper positions
13
+ - FULL set to ON
14
+ - A \/\/ B set to OFF
15
+
16
+ created 4 July 2018
17
+ by Sandeep Mistry
18
+ */
19
+
20
+ #include < RS485.h>
21
+
22
+ void setup () {
23
+ Serial.begin (9600 );
24
+ while (!Serial);
25
+
26
+ RS485.begin (9600 );
27
+
28
+ // enable reception, can be disabled with: RS485.noReceive();
29
+ RS485.receive ();
30
+ }
31
+
32
+ void loop () {
33
+ if (RS485.available ()) {
34
+ Serial.write (RS485.read ());
35
+ }
36
+ }
37
+
Original file line number Diff line number Diff line change
1
+ /*
2
+ RS485 Sender
3
+
4
+ This sketch periodically sends a string over the RS485 interface
5
+
6
+ Circuit:
7
+ - MKR board
8
+ - MKR 485 shield
9
+ - ISO GND connected to GND of the 485 device
10
+ - Y connected to A of the 485 device
11
+ - Z connected to B of the 485 device
12
+ - Jumper positions
13
+ - FULL set to ON
14
+ - Z \/\/ Y set to ON
15
+
16
+ created 4 July 2018
17
+ by Sandeep Mistry
18
+ */
19
+
20
+ #include < RS485.h>
21
+
22
+ int counter = 0 ;
23
+
24
+ void setup () {
25
+ RS485.begin (9600 );
26
+ }
27
+
28
+ void loop () {
29
+ RS485.beginTransmission ();
30
+ RS485.print (" hello " );
31
+ RS485.println (counter);
32
+ RS485.endTransmission ();
33
+
34
+ counter++;
35
+
36
+ delay (1000 );
37
+ }
38
+
You can’t perform that action at this time.
0 commit comments