MakeCode extension for the PN532 NFC RFID module.
The MakerBit connects to the BBC micro:bit to provide easy connections to a wide variety of sensors, actuators and other components.
![]() |
![]() |
|---|---|
| MakerBit | MakerBit+R with motor controller |
This extension supports reading and writing data from RFID cards and tags using a PN532 NFC board.
makerbit.onRFIDPresented(function () {
basic.showString(makerbit.convertNumberToHex(makerbit.rfidGetUID(), HexDigits.d0))
makerbit.rfidWriteString("Hello!")
basic.showString(makerbit.rfidReadString())
})
Create an event handler for an RFID tag. If an RFID tag is detected then the code within the event handler is executed. During execution, a busy flag is used to prevent simultaneous calls to the handler. The busy flag is cleared when the event handler is exited.
makerbit.onRFIDPresented(() => {
})Retrieves the UID of an RFID tag. Returned as a hex string, or empty string if no tag is present.
makerbit.rfidGetUID()Initializes the RFID tag in the MIFARE Classic format and writes the string data to the card as a MIFARE "well-known-type" text record. The maximum string length is 36 characters.
makerbit.rfidWriteString("Hello")Reads the string data stored within the card. The data is assumed to be stored as a MIFARE "well-known-type" record of type text or URI.
makerbit.rfidReadString()Initializes the RFID tag in the MIFARE Classic format and writes the data to the card as a MIFARE "well-known-type" URI record. The maximum length is 38 characters. Do not include the http:// prefix.
makerbit.rfidWriteURL("1010technologies.com")Convert an integer number to a hexadecimal string, with an optional number of digits. Negative numbers are treated as 32-bit integers. Set the number of digits to 0 for the default (default is the smallest even number of digits needed to convert the number).
makerbit.convertNumberToHex(12345, 0)Licensed under the MIT License (MIT). See LICENSE file for more details.
- for PXT/microbit
- for PXT/calliope

