initial
This commit is contained in:
@ -0,0 +1,44 @@
|
||||
/*
|
||||
RS-485 Passthrough
|
||||
|
||||
This sketch relays data sent and received between the Serial port and the RS-485 interface
|
||||
|
||||
Circuit:
|
||||
- MKR board
|
||||
- MKR 485 Shield
|
||||
- ISO GND connected to GND of the RS-485 device
|
||||
- Y connected to A of the RS-485 device
|
||||
- Z connected to B of the RS-485 device
|
||||
- A connected to Y of the RS-485 device
|
||||
- B connected to Z of the RS-485 device
|
||||
- Jumper positions
|
||||
- FULL set to ON
|
||||
- Z \/\/ Y set to ON, if the RS-485 device doesn't provide termination
|
||||
- B \/\/ A set to ON, if the RS-485 device doesn't provide termination
|
||||
|
||||
created 4 July 2018
|
||||
by Sandeep Mistry
|
||||
*/
|
||||
|
||||
#include <ArduinoRS485.h>
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
RS485.begin(9600);
|
||||
|
||||
// enable transmission, can be disabled with: RS485.endTransmission();
|
||||
RS485.beginTransmission();
|
||||
|
||||
// enable reception, can be disabled with: RS485.noReceive();
|
||||
RS485.receive();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (Serial.available()) {
|
||||
RS485.write(Serial.read());
|
||||
}
|
||||
|
||||
if (RS485.available()) {
|
||||
Serial.write(RS485.read());
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
RS-485 Receiver
|
||||
|
||||
This sketch receives data over RS-485 interface and outputs the data to the Serial interface
|
||||
|
||||
Circuit:
|
||||
- MKR board
|
||||
- MKR 485 shield
|
||||
- ISO GND connected to GND of the RS-485 device
|
||||
- A connected to A/Y of the RS-485 device
|
||||
- B connected to B/Z of the RS-485 device
|
||||
- Jumper positions
|
||||
- FULL set to ON
|
||||
- A \/\/ B set to OFF
|
||||
|
||||
created 4 July 2018
|
||||
by Sandeep Mistry
|
||||
*/
|
||||
|
||||
#include <ArduinoRS485.h>
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial);
|
||||
|
||||
RS485.begin(9600);
|
||||
|
||||
// enable reception, can be disabled with: RS485.noReceive();
|
||||
RS485.receive();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (RS485.available()) {
|
||||
Serial.write(RS485.read());
|
||||
}
|
||||
}
|
||||
|
37
libraries/ArduinoRS485/examples/RS485Sender/RS485Sender.ino
Normal file
37
libraries/ArduinoRS485/examples/RS485Sender/RS485Sender.ino
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
RS-485 Sender
|
||||
|
||||
This sketch periodically sends a string over the RS-485 interface
|
||||
|
||||
Circuit:
|
||||
- MKR board
|
||||
- MKR 485 shield
|
||||
- ISO GND connected to GND of the RS-485 device
|
||||
- Y connected to A of the RS-485 device
|
||||
- Z connected to B of the RS-485 device
|
||||
- Jumper positions
|
||||
- FULL set to ON
|
||||
- Z \/\/ Y set to ON
|
||||
|
||||
created 4 July 2018
|
||||
by Sandeep Mistry
|
||||
*/
|
||||
|
||||
#include <ArduinoRS485.h>
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void setup() {
|
||||
RS485.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
RS485.beginTransmission();
|
||||
RS485.print("hello ");
|
||||
RS485.println(counter);
|
||||
RS485.endTransmission();
|
||||
|
||||
counter++;
|
||||
|
||||
delay(1000);
|
||||
}
|
Reference in New Issue
Block a user