1 |
× |
USB connector
<a target="_blank" rel="noopener noreferrer" href="https://www.amazon.com/naughtystarts-USB-Cable-ATMEGA328P-MEGA2560/dp/B0BXT416X7">https://www.amazon.com/naughtystarts-USB-Cable-ATMEGA328P-MEGA2560/dp/B0BXT416X7</a>
|
2 |
× |
Soldered Wire
<a target="_blank" rel="noopener noreferrer" href="https://www.amazon.com/Twocorn-no-wash-tin-Lead-Electric-Soldering/dp/B0CP7QHFL6?source=ps-sl-shoppingads-lpcontext&ref_=fplfs&smid=A3IYFNSRJM2PET&th=1">https://www.amazon.com/Twocorn-no-wash-tin-Lead-Electric-Soldering/dp/B0CP7QHFL6?source=ps-sl-shoppingads-lpcontext&ref_=fplfs&smid=A3IYFNSRJM2PET&th=1</a>
|
1 |
× |
Glasses
|
1 |
× |
RFID tags
|
1 |
× |
Sparkfun simultaneous RFID tag reader
<a target="_blank" rel="noopener noreferrer" href="https://www.sparkfun.com/sparkfun-simultaneous-rfid-reader-m6e-nano.html">https://www.sparkfun.com/sparkfun-simultaneous-rfid-reader-m6e-nano.html</a>
|
1 |
× |
Arduino uno board
<a target="_blank" rel="noopener noreferrer" href="https://store.arduino.cc/products/arduino-uno-rev3?srsltid=AfmBOoov6Dlo4yhtbzxiQDIUGyE1OZ5Xxd_XLGPZCMWrwW7m36bjAyAt">https://store.arduino.cc/products/arduino-uno-rev3?srsltid=AfmBOoov6Dlo4yhtbzxiQDIUGyE1OZ5Xxd_XLGPZCMWrwW7m36bjAyAt</a>
|
1 |
× |
Passive buzzer
<a target="_blank" rel="noopener noreferrer" href="https://robotpishop.com/products/passive-buzzer?srsltid=AfmBOop2Vj8AhKF1KMNVRLfOlxws5yrhEYXaR7AKuY4-7PkFIWEhNbWZQpM">https://robotpishop.com/products/passive-buzzer?srsltid=AfmBOop2Vj8AhKF1KMNVRLfOlxws5yrhEYXaR7AKuY4-7PkFIWEhNbWZQpM</a>
|
1 |
× |
Passive buzzer code
int duration = 500; void setup() { Serial.println(F("Press a key to begin scanning for tags.")); while (!Serial.available()); //Wait for user to send a character <a target="_blank" rel="noopener noreferrer" href="http://Serial.read">Serial.read</a>(); //Throw away the user's character tone(9, 1400, duration); delay(200); tone(9, 800, duration); delay(200); tone(9, 1800, duration); delay(200); tone(9, 600, duration); delay(200); } void loop() { }
|
1 |
× |
Sensor Code
// Library for controlling the RFID module #include "SparkFun_UHF_RFID_Reader.h" // Create instance of the RFID module RFID rfidModule; #include SoftwareSerial softSerial(2, 3); //RX, TX #define rfidSerial softSerial // Software serial (eg. Arudino Uno or SparkFun RedBoard) // #define rfidSerial Serial1 // Hardware serial (eg. ESP32 or Teensy) #define rfidBaud 38400 //#define rfidBaud 115200 #define moduleType ThingMagic_M6E_NANO // #define moduleType ThingMagic_M7E_HECTO void setup() { Serial.begin(115200); while (!Serial); //Wait for the serial port to come online if (setupRfidModule(rfidBaud) == false) { Serial.println(F("Module failed to respond. Please check wiring.")); while (1); //Freeze! } rfidModule.setRegion(REGION_NORTHAMERICA); //Set to North America rfidModule.setReadPower(500); <a target="_blank" rel="noopener noreferrer" href="//5.00">//5.00</a> dBm. Higher values may caues USB port to brown out //Max Read TX Power is 27.00 dBm and may cause temperature-limit throttling Serial.println(F("Press a key to begin scanning for tags.")); while (!Serial.available()); //Wait for user to send a character <a target="_blank" rel="noopener noreferrer" href="http://Serial.read">Serial.read</a>(); //Throw away the user's character rfidModule.startReading(); //Begin scanning for tags } void loop() { if (rfidModule.check() == true) //Check to see if any new data has come in from module { byte responseType = rfidModule.parseResponse(); //Break response into tag ID, RSSI, frequency, and timestamp if (responseType == RESPONSE_IS_KEEPALIVE) { Serial.println(F("Scanning")); } else if (responseType == RESPONSE_IS_TAGFOUND) { //If we have a full record we can pull out the fun bits int rssi = rfidModule.getTagRSSI(); //Get the RSSI for this tag read long freq = rfidModule.getTagFreq(); //Get the frequency this tag was detected at long timeStamp = rfidModule.getTagTimestamp(); //Get the time this was read, (ms) since last keep-alive message byte tagEPCBytes = rfidModule.getTagEPCBytes(); //Get the number of bytes of EPC from response Serial.print(F(" rssi[")); Serial.print(rssi); Serial.print(F("]")); Serial.print(F(" freq[")); Serial.print(freq); Serial.print(F("]")); Serial.print(F(" time[")); Serial.print(timeStamp); Serial.print(F("]")); //Print EPC bytes, this is a subsection of bytes from the response/msg array Serial.print(F(" epc[")); for (byte x = 0 ; x < tagEPCBytes ; x++) { if (rfidModule.msg[31 + x] < 0x10) Serial.print(F("0")); //Pretty print Serial.print(rfidModule.msg[31 + x], HEX); Serial.print(F(" ")); } Serial.print(F("]")); Serial.println(); } else if (responseType == ERROR_CORRUPT_RESPONSE) { Serial.println("Bad CRC"); } else if (responseType == RESPONSE_IS_HIGHRETURNLOSS) { Serial.println("High return loss, check antenna!"); } else { //Unknown response Serial.println("Unknown error"); } } } //Gracefully handles a reader that is already configured and already reading continuously //Because Stream does not have a .begin() we have to do this outside the library boolean setupRfidModule(long baudRate) { rfidModule.begin(rfidSerial, moduleType); //Tell the library to communicate over serial port //Test to see if we are already connected to a module //This would be the case if the Arduino has been reprogrammed and the module has stayed powered rfidSerial.begin(baudRate); //For this test, assume module is already at our desired baud rate delay(100); //Wait for port to open //About 200ms from power on the module will send its firmware version at 115200. We need to ignore this. while (rfidSerial.available()) <a target="_blank" rel="noopener noreferrer" href="http://rfidSerial.read">rfidSerial.read</a>(); rfidModule.getVersion(); if (rfidModule.msg[0] == ERROR_WRONG_OPCODE_RESPONSE) { //This happens if the baud rate is correct but the module is doing a ccontinuous read rfidModule.stopReading(); Serial.println(F("Module continuously reading. Asking it to stop...")); delay(1500); } else { //The module did not respond so assume it's just been powered on and communicating at 115200bps rfidSerial.begin(115200); //Start serial at 115200 rfidModule.setBaud(baudRate); //Tell the module to go to the chosen baud rate. Ignore the response msg rfidSerial.begin(baudRate); //Start the serial port, this time at user's chosen baud rate delay(250); } //Test the connection rfidModule.getVersion(); if (rfidModule.msg[0] != ALL_GOOD) return false; //Something is not right //The module has these settings no matter what rfidModule.setTagProtocol(); //Set protocol to GEN2 rfidModule.setAntennaPort(); //Set TX/RX antenna ports to 1 return true; //We are ready to rock
|