Mesh networked computer terminals with RFID logon - part 6

Going back a few weeks I was having trouble with stability of the RFID readers. Which I've now fixed with a far less complicated solution.

The library has an option to turn the RFID antenna on and off. Simply shutting it off and turning back on to check the card periodically seems a 100% stable solution.

Obviously you should also check the card hasn't been swapped by checking the ID hasn't changed but here is a a minimal sketch to do this. As checking for a card stops it appearing as new it's easy to get the logic messed up but this is a tested and working example.

Note to self: start putting stuff on GutHub.

#include <SPI.h>
#include <MFRC522.h>

const uint8_t SS_PIN = D8;    //My example code is for a WeMos D1 mini, change these to match your setup
const uint8_t RST_PIN = D0;   //My example code is for a WeMos D1 mini, change these to match your setup
MFRC522 rfid(SS_PIN, RST_PIN);

bool cardPresentWhenLastChecked = false;
bool antennaEnabled = true;
uint32_t cardCheckTimer = 0;

void setup()
  Serial.println(F("Checking for RFID card removal"));
void loop()
  if(millis() > cardCheckTimer)
    //Start a check of the card
    if(antennaEnabled == false)
        //Turn the antenna back on
        antennaEnabled = true;
        //It takes time to wake up the RFID card so the sketch needs to wait before checking for it
        cardCheckTimer = millis() + 20ul;
    else if(antennaEnabled == true)
      if(millis() > cardCheckTimer)
        //Check for a card after a delay for it to power up
        if(rfid.PICC_IsNewCardPresent() == true)
          if(cardPresentWhenLastChecked == false)
            //Card was absent but has been presented
            Serial.println(F("Card presented"));
            cardPresentWhenLastChecked = true;
        else if(rfid.PICC_IsNewCardPresent() == false && cardPresentWhenLastChecked == true)
          //The card was present but has been removed
          Serial.println("Card removed");
          cardPresentWhenLastChecked = false;
        //Switch off the antenna, otherwise the card will not show as 'new' when checked again
        antennaEnabled = false;
        //Wait before checking the card again
        cardCheckTimer = millis() + 100ul;

Ender 2 magnetic bed upgrade

I'm still down the prop mines so can't post much without spoilers, but as alluded to I've been doing a lot of  3D printing again recently. The Ender 2 is great but the bed material was getting nasty and it's always been a pain to get things off as it's not removable.
My Ender 3 has a basic removable, flexible bed which is so much nicer. You can't get Ender 2 removable beds easily but you can for the Ender 3, very cheaply. This is a magnetic one which avoids any clips and as I have a second I may upgrade the Ender 3.
I assumed the bed would cut down easily to go on the Ender 2. Which has a tiny bed compared to almost any modern printer. I popped the bed off the printer, which is dead easy, marked it out with some tape and it cut easily with a nice sharp craft knife.
You can see how small the Ender 2 bed is compared to the not huge Ender 3. I wandered a tiny bit with the craft knife despite running it against as steel edge, but once on the printer it's not a problem as you'd never deliberately print that close to the edge of the bed.
Just running off my first test print now but after some faff re-levelling the bed, which is tiresome on an Ender 2, things look very promising.

Update: The small surface area makes for quite weak attraction with the base. Tall prints, especially, seem to cause the bed to slip and kill the print. I've fixed this with a couple of clips. So I've still got a removable bed it's just not an instant off one. Which is not exactly a hardship.