Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a SoftwareSerial to communicate with RDM6300 #591

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,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
4 changes: 4 additions & 0 deletions src/config.esp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ bool ICACHE_FLASH_ATTR loadConfiguration(Config &config)
rfidss = hardware["sspin"];
setupPN532Reader(rfidss);
}
else if (config.readertype > READER_PN532)
{
setupRDM6300Reader();
}
config.fallbackMode = network["fallbackmode"] == 1;
config.autoRestartIntervalSeconds = general["restart"];
config.wifiTimeout = network["offtime"];
Expand Down
4 changes: 4 additions & 0 deletions src/magicnumbers.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#define WIEGANDTYPE_PICC24 24
#define WIEGANDTYPE_PICC34 34

#define RDM6300_BAUDRATE 9600
#define RDM6300_READ_TIMEOUT 20
#define RDM6300_RX_PIN 4

// 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 *rdm6300_sw_serial = NULL;

// relay specific variables
bool activateRelay[MAX_NUM_RELAYS] = {false, false, false, false};
Expand Down
11 changes: 9 additions & 2 deletions src/rfid.esp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ void pn532Read()

void genericRead()
{
while (Serial.available() > 0)
while (rdm6300_sw_serial->available() > 0)
{
RFIDr.rfidSerial(Serial.read());
RFIDr.rfidSerial(rdm6300_sw_serial->read());
}
if (RFIDr.Available())
{
Expand Down Expand Up @@ -566,3 +566,10 @@ void ICACHE_FLASH_ATTR setupPN532Reader(int rfidss)
}
} while (false);
}

void ICACHE_FLASH_ATTR setupRDM6300Reader()
{
rdm6300_sw_serial = new SoftwareSerial(RDM6300_RX_PIN, -1);
rdm6300_sw_serial->begin(RDM6300_BAUDRATE);
rdm6300_sw_serial->setTimeout(RDM6300_READ_TIMEOUT);
}