Skip to content

Commit 89edf86

Browse files
committed
Add custom Stream support and AltSoftSerial example!
1 parent 6dc3ac0 commit 89edf86

File tree

5 files changed

+64
-5
lines changed

5 files changed

+64
-5
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* A simple example to interface with rdm6300 rfid reader using AltSoftSerial.
3+
* We use AltSoftSerial uart instead of the default software uart driver.
4+
*
5+
* Connections:
6+
* | Board | RX Pin | PWM Unusable | Pin Unusable |
7+
* |------------------+--------+--------------+--------------|
8+
* | Teensy 3.0 & 3.1 | 20 | 22 | 21 |
9+
* | Teensy 2.0 | 10 | - | 9 |
10+
* | Teensy++ 2.0 | 4 | 26, 27 | 25 |
11+
* | Arduino Uno | 8 | 10 | 9 |
12+
* | Arduino Leonardo | 13 | - | 5 |
13+
* | Arduino Mega | 48 | 44, 45 | 46 |
14+
* | Wiring-S | 6 | 4 | 5 |
15+
* | Sanguino | 14 | 12 | 13 |
16+
*
17+
* Arad Eizen (https://github.com/arduino12) 08/05/19, 09/06/19, 22/06/19.
18+
*/
19+
20+
#include <rdm6300.h>
21+
#include <AltSoftSerial.h>
22+
23+
#define RDM6300_RX_PIN 8
24+
#define READ_LED_PIN 13
25+
26+
Rdm6300 rdm6300;
27+
AltSoftSerial alt_soft_serial;
28+
29+
30+
void setup()
31+
{
32+
Serial.begin(115200);
33+
34+
pinMode(READ_LED_PIN, OUTPUT);
35+
digitalWrite(READ_LED_PIN, LOW);
36+
37+
alt_soft_serial.begin(RDM6300_BAUDRATE);
38+
rdm6300.begin(&alt_soft_serial);
39+
40+
Serial.println("\nPlace RFID tag near the rdm6300...");
41+
}
42+
43+
void loop()
44+
{
45+
/* if non-zero tag_id, update() returns true- a new tag is near! */
46+
if (rdm6300.update())
47+
Serial.println(rdm6300.get_tag_id(), HEX);
48+
49+
digitalWrite(READ_LED_PIN, rdm6300.is_tag_near());
50+
51+
delay(10);
52+
}

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rdm6300",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"keywords": "rdm6300, rfid",
55
"description": "A simple library to interface with rdm6300 rfid reader.",
66
"repository":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Rdm6300
2-
version=1.1.3
2+
version=1.1.4
33
author=Arad Eizen
44
maintainer=Arad Eizen <https://github.com/arduino12>
55
sentence=A simple library to interface with rdm6300 rfid reader.

src/rdm6300.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
#include <Arduino.h>
88

99

10+
void Rdm6300::begin(Stream *stream)
11+
{
12+
_stream = stream;
13+
if (!_stream)
14+
return;
15+
_stream->setTimeout(RDM6300_READ_TIMEOUT);
16+
}
17+
1018
void Rdm6300::begin(int rx_pin, uint8_t uart_nr)
1119
{
1220
/* init serial port to rdm6300 baud, without TX, and 20ms read timeout */
@@ -28,9 +36,7 @@ void Rdm6300::begin(int rx_pin, uint8_t uart_nr)
2836
_software_serial->begin(RDM6300_BAUDRATE);
2937
}
3038
#endif
31-
if (!_stream)
32-
return;
33-
_stream->setTimeout(RDM6300_READ_TIMEOUT);
39+
begin(_stream);
3440
}
3541

3642
void Rdm6300::end()

src/rdm6300.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
class Rdm6300
3535
{
3636
public:
37+
void begin(Stream *stream);
3738
void begin(int rxPin, uint8_t uart_nr=1);
3839
void end(void);
3940
bool update(void);

0 commit comments

Comments
 (0)