Skip to content

Search the documentation

Kit
Firmware

Smart Home RFID cards

The house has an RFID reader. Hold a card or a tag close to it and the house reads the card’s number. The reader powers the card with radio waves, and the card answers with its number.

home.rfid.read_card() gives the number of the card held close to the reader, as text. It gives None when there is no card.

reader = home.rfid
if reader is None:
print("The RFID reader did not start")
else:
card = reader.read_card()
print("Card:", card)

home.rfid.is_card_present() gives True when a card is held close to the reader, and it does not read the number. home.rfid is None if the reader did not start, so check for that first.

A card number is ten characters of lower case letters and digits, for example 3906f6945d. The first eight are the card’s own id and the last two are a check. Every card has its own number. Yours will not be 3906f6945d.

To find your card’s number, run the program above in a loop, hold your card on the reader, and write down what it prints.

The number is text. Compare it with ==, and write the number exactly as it was printed: lower case, no spaces.

card = home.rfid.read_card()
if card == "3906f6945d": # put your own card's number here
home.servo.set_angle(90) # open the door

Ask the reader once, keep the answer in a variable, and use that variable. Each read is a real radio conversation, and two reads in a row can give two different answers, because the card may be gone by the second one.

  • Hold the card flat on the reader and close to it.
  • Hold it still for a moment. Your program only sees a card when it asks, so a very quick tap between two reads can be missed.
  • If read_card() is always None, even with a card held on the reader, check the reader’s wiring. The firmware cannot tell a reader that is missing from a reader that sees no card.
  • The reader’s pins are on the Smart Home pins page.

The MoBot app has an RFID access mode. The house compares the number of the card on the reader with the cards saved in that mode, character for character. So a saved number must be written the way read_card() gives it: ten lower case characters.

  • Doorbell is a door that learns cards. It saves their numbers in a file on the house, so it remembers them after a power cut.
  • Card door is the blocks version: find your card’s number first, then teach the door.
  • RFIDReader reference lists every call.