Skip to content

Commit

Permalink
Merge pull request #655 from esprfid/rdm6300-mj
Browse files Browse the repository at this point in the history
Using a SoftwareSerial to communicate with RDM6300 - take 2
  • Loading branch information
matjack1 authored Sep 21, 2024
2 parents 703e799 + 85e74bb commit 5a22a8f
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 34 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ The following table shows the typical pin layout used for connecting readers har
| GPIO-13 | D7 | D0 | MOSI | MOSI | |
| GPIO-12 | D6 | D1 | MISO | MISO | |
| GPIO-14 | D5 | | SCK | SCK | |
| GPIO-04 | D2 | | | | |
| GPIO-04 | D2 | | | | TX |
| GPIO-05 | D1 | | SS | | |
| GPIO-03 | RX | | | | TX |

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

Expand Down
3 changes: 0 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ f_cpu = 160000000L
framework = arduino
board = esp12e
build_flags = -Wl,-Teagle.flash.4m2m.ld
src_build_flags = !echo "-DBUILD_TAG="$TRAVIS_TAG
upload_speed = 460800
monitor_speed = 115200
lib_deps =
Expand All @@ -31,7 +30,6 @@ board = ${common.board}
lib_deps = ${common.lib_deps}
extra_scripts = scripts/GENdeploy.py
build_flags = ${common.build_flags}
src_build_flags = ${common.src_build_flags}
;https://github.com/platformio/platform-espressif8266/issues/153
upload_speed = ${common.upload_speed}
monitor_speed = ${common.monitor_speed}
Expand All @@ -46,7 +44,6 @@ board = ${common.board}
lib_deps = ${common.lib_deps}
build_flags = ${common.build_flags}
-DDEBUG
src_build_flags = ${common.src_build_flags}
extra_scripts = scripts/DBGdeploy.py
upload_speed = ${common.upload_speed}
monitor_speed = ${common.monitor_speed}
7 changes: 7 additions & 0 deletions src/config.esp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ bool ICACHE_FLASH_ATTR loadConfiguration(Config &config)
rfidss = hardware["sspin"];
setupPN532Reader(rfidss);
}
// RDM6300 can be configured alongside the other readers
if (config.readertype > READER_PN532)
{
int rmd6300TxPin = hardware["rdm6300pin"];
setupRDM6300Reader(rmd6300TxPin);
}

if (network.containsKey("fallbackmode"))
{
config.fallbackMode = network["fallbackmode"] == 1;
Expand Down
3 changes: 3 additions & 0 deletions src/magicnumbers.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#define WIEGANDTYPE_PICC24 24
#define WIEGANDTYPE_PICC34 34

#define RDM6300_BAUDRATE 9600
#define RDM6300_READ_TIMEOUT 20

// hardware defines

#define MAX_NUM_RELAYS 4
Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ Config config;
#include "PN532.h"
#include <Wiegand.h>
#include "rfid125kHz.h"
#include <SoftwareSerial.h>

MFRC522 mfrc522 = MFRC522();
PN532 pn532;
WIEGAND wg;
RFID_Reader RFIDr;
SoftwareSerial *rdm6300SwSerial = NULL;

// relay specific variables
bool activateRelay[MAX_NUM_RELAYS] = {false, false, false, false};
Expand Down
15 changes: 10 additions & 5 deletions src/rfid.esp
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,10 @@ void pn532Read()
*/
void genericRead()
{
/*
* Test RDM6300 125khz reader
*/
while (Serial.available() > 0)
while (rdm6300SwSerial->available() > 0)
{
RFIDr.rfidSerial(Serial.read());
char read = rdm6300SwSerial->read();
RFIDr.rfidSerial(read);
}
if (RFIDr.Available())
{
Expand Down Expand Up @@ -684,3 +682,10 @@ void ICACHE_FLASH_ATTR setupPN532Reader(int rfidss)
}
} while (false);
}

void ICACHE_FLASH_ATTR setupRDM6300Reader(int rmd6300TxPin)
{
rdm6300SwSerial = new SoftwareSerial(rmd6300TxPin, -1);
rdm6300SwSerial->begin(RDM6300_BAUDRATE);
rdm6300SwSerial->setTimeout(RDM6300_READ_TIMEOUT);
}
18 changes: 9 additions & 9 deletions src/webh/esprfid.htm.gz.h

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions src/webh/esprfid.js.gz.h

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/websrc/esprfid.htm
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,25 @@ <h6 class="text-muted">Please refer the <a href="https://github.com/esprfid/esp-
</span>
</div>
</div>
<div class="" id="rdm6300" style="display:none">
<div class="row form-group">
<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>
<span class="col-xs-9 col-md-5">
<select class="form-control input-sm" id="rdm6300pin">
<option value="0">GPIO-0</option>
<option value="1">GPIO-1</option>
<option value="2">GPIO-2</option>
<option selected="selected" value="4">GPIO-4</option>
<option value="5">GPIO-5</option>
<option value="12">GPIO-12</option>
<option value="13">GPIO-13</option>
<option value="14">GPIO-14</option>
<option value="15">GPIO-15</option>
<option value="16">GPIO-16</option>
</select>
</span>
</div>
</div>
<div class="" id="mfrc522Form" style="display:none">
<div class="row form-group">
<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>
Expand Down
28 changes: 25 additions & 3 deletions src/websrc/js/esprfid.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var config = {
"readertype": 1,
"wgd0pin": 4,
"wgd1pin": 5,
"rdm6300pin": 4,
"sspin": 0,
"rfidgain": 32,
"wifipin": 255,
Expand Down Expand Up @@ -149,21 +150,40 @@ function syncBrowserTime() {

function handleReader() {
var rType = parseInt(document.getElementById("readertype").value);
if (rType === 0 || rType === 4) {
if (rType === 0) {
document.getElementById("wiegandForm").style.display = "none";
document.getElementById("mfrc522Form").style.display = "block";
document.getElementById("rc522gain").style.display = "block";
} else if (rType === 1 || rType === 5) {
document.getElementById("rdm6300").style.display = "none";
} else if (rType === 1) {
document.getElementById("wiegandForm").style.display = "block";
document.getElementById("mfrc522Form").style.display = "none";
} else if (rType === 2 || rType === 6) {
document.getElementById("rdm6300").style.display = "none";
} else if (rType === 2) {
document.getElementById("wiegandForm").style.display = "none";
document.getElementById("mfrc522Form").style.display = "block";
document.getElementById("rc522gain").style.display = "none";
document.getElementById("rdm6300").style.display = "none";
} else if (rType === 3) {
document.getElementById("wiegandForm").style.display = "none";
document.getElementById("mfrc522Form").style.display = "none";
document.getElementById("rc522gain").style.display = "none";
document.getElementById("rdm6300").style.display = "block";
} else if (rType === 4) {
document.getElementById("wiegandForm").style.display = "none";
document.getElementById("mfrc522Form").style.display = "block";
document.getElementById("rc522gain").style.display = "none";
document.getElementById("rdm6300").style.display = "block";
} else if (rType === 5) {
document.getElementById("wiegandForm").style.display = "block";
document.getElementById("mfrc522Form").style.display = "none";
document.getElementById("rc522gain").style.display = "none";
document.getElementById("rdm6300").style.display = "block";
} else if (rType === 6) {
document.getElementById("wiegandForm").style.display = "none";
document.getElementById("mfrc522Form").style.display = "block";
document.getElementById("rc522gain").style.display = "none";
document.getElementById("rdm6300").style.display = "block";
}
}

Expand Down Expand Up @@ -197,6 +217,7 @@ function listhardware() {
document.getElementById("readertype").value = config.hardware.readertype;
document.getElementById("wg0pin").value = config.hardware.wgd0pin;
document.getElementById("wg1pin").value = config.hardware.wgd1pin;
document.getElementById("rdm6300pin").value = config.hardware.rdm6300pin;
document.getElementById("gpioss").value = config.hardware.sspin;
document.getElementById("gain").value = config.hardware.rfidgain;
document.getElementById("gpiorly").value = config.hardware.rpin;
Expand Down Expand Up @@ -249,6 +270,7 @@ function savehardware() {
config.hardware.readertype = parseInt(document.getElementById("readertype").value);
config.hardware.wgd0pin = parseInt(document.getElementById("wg0pin").value);
config.hardware.wgd1pin = parseInt(document.getElementById("wg1pin").value);
config.hardware.rdm6300pin = parseInt(document.getElementById("rdm6300pin").value);
config.hardware.useridstoragemode = document.getElementById("useridstoragemode").value;
config.hardware.requirepincodeafterrfid = document.getElementById("requirepincodeafterrfid").checked;
config.hardware.allowpincodeonly = document.getElementById("allowpincodeonly").checked;
Expand Down

0 comments on commit 5a22a8f

Please sign in to comment.