Giao tiếp Mạch Đọc RFID RDM6300 với Arduino

Mạch RFID RDM6300 là một mạch thu phát RFID tần số 125 kHz. Nó được sử dụng để đọc ID của thẻ RFID và trả về vi điều khiển hoặc máy tính qua giao tiếp UART. Mạch có kích thước nhỏ gọn và dễ sử dụng, phù hợp với nhiều ứng dụng đọc thẻ RFID tần số 125 kHz.

Module RDM6300 được thiết kế nhỏ gọn và có kèm theo anten RFID. Module có chuẩn giao tiếp UART với thông số baudrate cố định là: 9600, N, 8, 1. Mã RFID trả về sẽ là mã ASCII gồm 10 chữ số.

Thông số kỹ thuật:

  • Điện áp sử dụng: 5VDC
  • Chuẩn giao tiếp: UART TTL
  • Baudrate: 9600, N, 8, 1
  • Tần số giao tiếp: 125Khz
  • Time to read: < 100ms
  • Khoảng cách nhận thẻ: 20~50mm
  • Supported cards: EM/TK 4100, EM/TK4102, EM4200 or compatible
  • Kích thước: 38.5 x 19 x 9mm

Sơ đồ chân:


P1 P2 P3
1 - TX    1 -  ANT1 1 - LED  
2 - RX    2 -  ANT2 2 - 5V    
3 - NC      3 - GND
4 - GND    
5 - 5V        

Sơ đồ mạch để giao tiếp RDM6300 với Arduino:



Thư viện:

Code:

#include 
#include 

#define RDM6300_RX_PIN 4 // read the SoftwareSerial doc above! may need to change this pin to 10...
#define READ_LED_PIN 13

Rdm6300 rdm6300;

void setup()
{
	Serial.begin(115200);

	pinMode(READ_LED_PIN, OUTPUT);
	digitalWrite(READ_LED_PIN, LOW);

	rdm6300.begin(RDM6300_RX_PIN);

	Serial.println("\nPlace RFID tag near the rdm6300...");
}

void loop()
{
	/* get_new_tag_id returns the tag_id of a "new" near tag,
	following calls will return 0 as long as the same tag is kept near. */
	if (rdm6300.get_new_tag_id())
		Serial.println(rdm6300.get_tag_id(), HEX);

	/* get_tag_id returns the tag_id as long as it is near, 0 otherwise. */
	digitalWrite(READ_LED_PIN, rdm6300.get_tag_id());

	delay(10);
}

Kiểm tra đầu đọc RFID RDM6300

Khi code và phần cứng của bạn đã sẵn sàng, hãy kết nối Arduino với máy tính xách tay và tải code lên. Sau đó, mở màn hình nối tiếp ở tốc độ baud 9600 và quét thẻ RFID trên Ăng-ten của Module. Số thẻ sẽ được in trên màn hình nối tiếp.

Video:

API

  • void begin(Stream *stream) - Initialize instance to read from a given stream.
  • void begin(int rx_pin, uint8_t uart_nr=1) - Initialize instance to read from a given pin.
  • void set_tag_timeout(uint32_t tag_timeout_ms) - sets the tag "valid" timeout, (300ms default)
    RDM6300 sends packet every 65ms when tag is near- better higher values for debouncing.
  • uint32_t get_tag_id() - Returns the tag_id as long as it is near, 0 otherwise.
  • uint32_t get_new_tag_id() - Returns the tag_id of a "new" near tag,
    following calls will return 0 as long as the same tag is kept near.
  • bool update() - Updates the internal values must be called repeatedly! deprecated!
  • bool is_tag_near() - Returns whether a tag is held near. deprecated! use get_tag_id().

Nhận xét

Mới hơn Cũ hơn