Skip to content

Commit 5a22a8f

Browse files
authored
Merge pull request #655 from esprfid/rdm6300-mj
Using a SoftwareSerial to communicate with RDM6300 - take 2
2 parents 703e799 + 85e74bb commit 5a22a8f

File tree

10 files changed

+88
-34
lines changed

10 files changed

+88
-34
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ The following table shows the typical pin layout used for connecting readers har
112112
| GPIO-13 | D7 | D0 | MOSI | MOSI | |
113113
| GPIO-12 | D6 | D1 | MISO | MISO | |
114114
| GPIO-14 | D5 | | SCK | SCK | |
115-
| GPIO-04 | D2 | | | | |
115+
| GPIO-04 | D2 | | | | TX |
116116
| GPIO-05 | D1 | | SS | | |
117-
| GPIO-03 | RX | | | | TX |
118117

119118
For Wiegand based readers, you can configure D0 and D1 pins via settings page. By default, D0 is GPIO-4 and D1 is GPIO-5
120119

platformio.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ f_cpu = 160000000L
77
framework = arduino
88
board = esp12e
99
build_flags = -Wl,-Teagle.flash.4m2m.ld
10-
src_build_flags = !echo "-DBUILD_TAG="$TRAVIS_TAG
1110
upload_speed = 460800
1211
monitor_speed = 115200
1312
lib_deps =
@@ -31,7 +30,6 @@ board = ${common.board}
3130
lib_deps = ${common.lib_deps}
3231
extra_scripts = scripts/GENdeploy.py
3332
build_flags = ${common.build_flags}
34-
src_build_flags = ${common.src_build_flags}
3533
;https://github.com/platformio/platform-espressif8266/issues/153
3634
upload_speed = ${common.upload_speed}
3735
monitor_speed = ${common.monitor_speed}
@@ -46,7 +44,6 @@ board = ${common.board}
4644
lib_deps = ${common.lib_deps}
4745
build_flags = ${common.build_flags}
4846
-DDEBUG
49-
src_build_flags = ${common.src_build_flags}
5047
extra_scripts = scripts/DBGdeploy.py
5148
upload_speed = ${common.upload_speed}
5249
monitor_speed = ${common.monitor_speed}

src/config.esp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ bool ICACHE_FLASH_ATTR loadConfiguration(Config &config)
153153
rfidss = hardware["sspin"];
154154
setupPN532Reader(rfidss);
155155
}
156+
// RDM6300 can be configured alongside the other readers
157+
if (config.readertype > READER_PN532)
158+
{
159+
int rmd6300TxPin = hardware["rdm6300pin"];
160+
setupRDM6300Reader(rmd6300TxPin);
161+
}
162+
156163
if (network.containsKey("fallbackmode"))
157164
{
158165
config.fallbackMode = network["fallbackmode"] == 1;

src/magicnumbers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#define WIEGANDTYPE_PICC24 24
2727
#define WIEGANDTYPE_PICC34 34
2828

29+
#define RDM6300_BAUDRATE 9600
30+
#define RDM6300_READ_TIMEOUT 20
31+
2932
// hardware defines
3033

3134
#define MAX_NUM_RELAYS 4

src/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ Config config;
4646
#include "PN532.h"
4747
#include <Wiegand.h>
4848
#include "rfid125kHz.h"
49+
#include <SoftwareSerial.h>
4950

5051
MFRC522 mfrc522 = MFRC522();
5152
PN532 pn532;
5253
WIEGAND wg;
5354
RFID_Reader RFIDr;
55+
SoftwareSerial *rdm6300SwSerial = NULL;
5456

5557
// relay specific variables
5658
bool activateRelay[MAX_NUM_RELAYS] = {false, false, false, false};

src/rfid.esp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,10 @@ void pn532Read()
170170
*/
171171
void genericRead()
172172
{
173-
/*
174-
* Test RDM6300 125khz reader
175-
*/
176-
while (Serial.available() > 0)
173+
while (rdm6300SwSerial->available() > 0)
177174
{
178-
RFIDr.rfidSerial(Serial.read());
175+
char read = rdm6300SwSerial->read();
176+
RFIDr.rfidSerial(read);
179177
}
180178
if (RFIDr.Available())
181179
{
@@ -684,3 +682,10 @@ void ICACHE_FLASH_ATTR setupPN532Reader(int rfidss)
684682
}
685683
} while (false);
686684
}
685+
686+
void ICACHE_FLASH_ATTR setupRDM6300Reader(int rmd6300TxPin)
687+
{
688+
rdm6300SwSerial = new SoftwareSerial(rmd6300TxPin, -1);
689+
rdm6300SwSerial->begin(RDM6300_BAUDRATE);
690+
rdm6300SwSerial->setTimeout(RDM6300_READ_TIMEOUT);
691+
}

src/webh/esprfid.htm.gz.h

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

src/webh/esprfid.js.gz.h

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

src/websrc/esprfid.htm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,25 @@ <h6 class="text-muted">Please refer the <a href="https://github.com/esprfid/esp-
219219
</span>
220220
</div>
221221
</div>
222+
<div class="" id="rdm6300" style="display:none">
223+
<div class="row form-group">
224+
<label class="col-xs-3">RDM6300 TX pin<i style="margin-left: 10px;" class="glyphicon glyphicon-info-sign" aria-hidden="true" data-toggle="popover" data-trigger="hover" data-placement="right" data-content="Choose which ESP pin is connected to RDM6300 TX pin"></i></label>
225+
<span class="col-xs-9 col-md-5">
226+
<select class="form-control input-sm" id="rdm6300pin">
227+
<option value="0">GPIO-0</option>
228+
<option value="1">GPIO-1</option>
229+
<option value="2">GPIO-2</option>
230+
<option selected="selected" value="4">GPIO-4</option>
231+
<option value="5">GPIO-5</option>
232+
<option value="12">GPIO-12</option>
233+
<option value="13">GPIO-13</option>
234+
<option value="14">GPIO-14</option>
235+
<option value="15">GPIO-15</option>
236+
<option value="16">GPIO-16</option>
237+
</select>
238+
</span>
239+
</div>
240+
</div>
222241
<div class="" id="mfrc522Form" style="display:none">
223242
<div class="row form-group">
224243
<label class="col-xs-3">SPI SS<i style="margin-left: 10px;" class="glyphicon glyphicon-info-sign" aria-hidden="true" data-toggle="popover" data-trigger="hover" data-placement="right" data-content="Choose which ESP port is connected to RFID Hardware SDA pin"></i></label>

src/websrc/js/esprfid.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var config = {
3434
"readertype": 1,
3535
"wgd0pin": 4,
3636
"wgd1pin": 5,
37+
"rdm6300pin": 4,
3738
"sspin": 0,
3839
"rfidgain": 32,
3940
"wifipin": 255,
@@ -149,21 +150,40 @@ function syncBrowserTime() {
149150

150151
function handleReader() {
151152
var rType = parseInt(document.getElementById("readertype").value);
152-
if (rType === 0 || rType === 4) {
153+
if (rType === 0) {
153154
document.getElementById("wiegandForm").style.display = "none";
154155
document.getElementById("mfrc522Form").style.display = "block";
155156
document.getElementById("rc522gain").style.display = "block";
156-
} else if (rType === 1 || rType === 5) {
157+
document.getElementById("rdm6300").style.display = "none";
158+
} else if (rType === 1) {
157159
document.getElementById("wiegandForm").style.display = "block";
158160
document.getElementById("mfrc522Form").style.display = "none";
159-
} else if (rType === 2 || rType === 6) {
161+
document.getElementById("rdm6300").style.display = "none";
162+
} else if (rType === 2) {
160163
document.getElementById("wiegandForm").style.display = "none";
161164
document.getElementById("mfrc522Form").style.display = "block";
162165
document.getElementById("rc522gain").style.display = "none";
166+
document.getElementById("rdm6300").style.display = "none";
163167
} else if (rType === 3) {
164168
document.getElementById("wiegandForm").style.display = "none";
165169
document.getElementById("mfrc522Form").style.display = "none";
166170
document.getElementById("rc522gain").style.display = "none";
171+
document.getElementById("rdm6300").style.display = "block";
172+
} else if (rType === 4) {
173+
document.getElementById("wiegandForm").style.display = "none";
174+
document.getElementById("mfrc522Form").style.display = "block";
175+
document.getElementById("rc522gain").style.display = "none";
176+
document.getElementById("rdm6300").style.display = "block";
177+
} else if (rType === 5) {
178+
document.getElementById("wiegandForm").style.display = "block";
179+
document.getElementById("mfrc522Form").style.display = "none";
180+
document.getElementById("rc522gain").style.display = "none";
181+
document.getElementById("rdm6300").style.display = "block";
182+
} else if (rType === 6) {
183+
document.getElementById("wiegandForm").style.display = "none";
184+
document.getElementById("mfrc522Form").style.display = "block";
185+
document.getElementById("rc522gain").style.display = "none";
186+
document.getElementById("rdm6300").style.display = "block";
167187
}
168188
}
169189

@@ -197,6 +217,7 @@ function listhardware() {
197217
document.getElementById("readertype").value = config.hardware.readertype;
198218
document.getElementById("wg0pin").value = config.hardware.wgd0pin;
199219
document.getElementById("wg1pin").value = config.hardware.wgd1pin;
220+
document.getElementById("rdm6300pin").value = config.hardware.rdm6300pin;
200221
document.getElementById("gpioss").value = config.hardware.sspin;
201222
document.getElementById("gain").value = config.hardware.rfidgain;
202223
document.getElementById("gpiorly").value = config.hardware.rpin;
@@ -249,6 +270,7 @@ function savehardware() {
249270
config.hardware.readertype = parseInt(document.getElementById("readertype").value);
250271
config.hardware.wgd0pin = parseInt(document.getElementById("wg0pin").value);
251272
config.hardware.wgd1pin = parseInt(document.getElementById("wg1pin").value);
273+
config.hardware.rdm6300pin = parseInt(document.getElementById("rdm6300pin").value);
252274
config.hardware.useridstoragemode = document.getElementById("useridstoragemode").value;
253275
config.hardware.requirepincodeafterrfid = document.getElementById("requirepincodeafterrfid").checked;
254276
config.hardware.allowpincodeonly = document.getElementById("allowpincodeonly").checked;

0 commit comments

Comments
 (0)