Components and supplies
1
Jumper wires (generic)
1
Arduino UNO
1
UHF RFID tags
1
Toggle Switch, Toggle
1
SparkFun Simultaneous RFID Reader - M6E Nano
2
Pushbutton Switch, Momentary
2
Resistor 10k ohm
Tools and machines
1
Soldering iron (generic)
1
3D Printer (generic)
Apps and platforms
1
Arduino IDE
Project description
Code
Timer Code
c_cpp
1#include <SoftwareSerial.h> 2SoftwareSerial softSerial(2, 3); 3#include "SparkFun_UHF_RFID_Reader.h" 4RFID nano; 5#define buzzer 9 6#define buzzergnd 10 7 8//place variables - data placement 9int place = 1; 10float seconds; 11float personTime; 12unsigned long currentMillis = 0; 13unsigned long prevMillis = millis; 14unsigned long minutes = 0; 15int heat = 1; 16 17//switches and such 18const int buttonPin = 6; 19int buttonPushCounter = 1; 20int buttonState = 0; 21int lastButtonState = 0; 22int onbtn = 9; 23int offbtn = 8; 24 25// create structure to filter 26struct DubFilter { 27 uint8_t EPC[12]; 28 //unsigned long LastTime; // optionally you could add data to capture 29}; 30 31// maximum number of unique EPC 32#define MaxEPC 15 33struct DubFilter dub[MaxEPC]; 34 35 36void setup() { 37//RFID 38pinMode(onbtn, INPUT); 39pinMode(offbtn, INPUT); 40pinMode(12, OUTPUT); 41pinMode(7, OUTPUT); 42pinMode(buzzer, OUTPUT); 43pinMode(buzzergnd, OUTPUT); 44digitalWrite(buzzergnd, LOW); 45Serial.begin(115200); 46while(! Serial); 47 48if(setupNano(38400) == false){ 49 Serial.println("Module failed to respond"); 50 while (1); 51} 52nano.setRegion(REGION_NORTHAMERICA); 53nano.setReadPower(1500); 54 55// init de-dub 56for (uint8_t i=0 ; i < MaxEPC ; i++) 57 dub[i].EPC[0] = 0; 58 59Serial.println("Ready"); 60Serial.println("Turn on switch to begin race"); 61/*while(!Serial.available()); 62 Serial.read(); 63 nano.startReading(); 64 digitalWrite(12, HIGH); 65 Serial.println("RFID Reader active. Ready to begin race"); 66*/ 67//timing 68pinMode(buttonPin, INPUT); 69 70} 71 72void startRace(){ 73 Serial.print("Race "); 74 Serial.print(heat); 75 Serial.println(" started"); 76 heat++; 77 flash(); 78} 79 80//where the magic happens 81void runTimer(){ 82 83 currentMillis = millis(); 84 seconds = currentMillis - prevMillis; 85 float personTime = seconds/1000; 86 87 if(seconds < 100){ 88 startRace(); 89 } 90 91 //data - THIS IS WHERE IT ALL GOES DOWN 92 if(nano.check() == true){ 93 byte responseType = nano.parseResponse(); 94 95 if(responseType == RESPONSE_IS_TAGFOUND){ 96 97 // it is already in the list 98 if ( DeDub() ) return ; 99 100 Serial.print(place); 101 Serial.print(" "); 102 byte tagEPCBytes = nano.getTagEPCBytes(); 103 for(byte x = 0 ; x< tagEPCBytes ; x++){ 104 if(nano.msg[31 + x] < 0x10) Serial.print("0"); 105 106 Serial.print(char(nano.msg[31 + x])); 107 Serial.print(("")); 108 } 109 unsigned minutes = (personTime + .0005) /60; 110 personTime -= minutes * 60; 111 Serial.print(" "); 112 Serial.print(minutes); 113 Serial.print(':'); 114 if ((personTime + 0.0005) < 10) 115 Serial.print('0'); 116 Serial.println(personTime, 2); 117 place++; 118 // flash(); 119 // delay(10); 120 } 121 } 122} 123 124/** 125 * This routine will check against the table 126 * If EPC is already in the table true will be returned. 127 * if NOT EPC will be added to the list and false is turned 128 */ 129bool DeDub() { 130 uint8_t i,x; 131 bool MissMatch = false; 132 133 // get the num EPC bytes 134 uint8_t tagEPCBytes = 12; 135 136 // check each entry in the table 137 for (i = 0 ; i < MaxEPC; i++){ 138 139 // if empty entry 140 if (dub[i].EPC[0] == 0) break; 141 142 MissMatch = false; 143 for(x = 0 ; x< tagEPCBytes ; x++){ 144 145 // check for miss match 146 if(nano.msg[31 + x] != dub[i].EPC[x] ){ 147 MissMatch = true; 148 break; 149 } 150 } 151 152 // A this point we check for MisMatch (false means we have a Match) 153 if (! MissMatch) return true; 154 155 } 156 157 // EPC was not in the list already 158 if (i == MaxEPC) { 159 Serial.println("Table is full\ 160Can NOT add more"); 161 } 162 else { 163 // add to the list 164 for(x = 0 ; x< tagEPCBytes ; x++){ 165 // Add to the list 166 dub[i].EPC[x] = nano.msg[31 + x]; 167 } 168 } 169 return(false); 170} 171 172void flash(){ 173 tone(buzzer, 2349); 174 delay(150); 175 noTone(buzzer); 176} 177 178void stopTimer(){ 179 180 seconds = 0; 181 place = 1; 182 minutes = 0; 183 prevMillis = millis(); 184 185} 186 187void loop() { 188 // put your main code here, to run repeatedly: 189buttonState = digitalRead(buttonPin); 190 if(buttonState == HIGH){ 191 runTimer(); 192 digitalWrite(7, HIGH); 193 } 194 else{ 195 stopTimer(); 196 digitalWrite(7, LOW); 197 } 198 199int onbtnstate = digitalRead(onbtn); 200int offbtnstate = digitalRead(offbtn); 201if (onbtnstate == HIGH){ 202 nano.startReading(); 203 digitalWrite(12, HIGH); 204 Serial.println("RFID Reader Active"); 205 delay(100); 206} 207if (offbtnstate == HIGH){ 208 nano.stopReading(); 209 digitalWrite(12, LOW); 210 Serial.println("RFID Reader deactivated"); 211 delay(100); 212} 213 214} 215 216boolean setupNano(long baudRate) 217{ 218 nano.begin(softSerial); //Tell the library to communicate over software serial port 219 220 //Test to see if we are already connected to a module 221 //This would be the case if the Arduino has been reprogrammed and the module has stayed powered 222 softSerial.begin(baudRate); //For this test, assume module is already at our desired baud rate 223 while (softSerial.isListening() == false); //Wait for port to open 224 225 //About 200ms from power on the module will send its firmware version at 115200. We need to ignore this. 226 while (softSerial.available()) softSerial.read(); 227 228 nano.getVersion(); 229 230 if (nano.msg[0] == ERROR_WRONG_OPCODE_RESPONSE) 231 { 232 //This happens if the baud rate is correct but the module is doing a ccontinuous read 233 nano.stopReading(); 234 235 Serial.println(F("Module continuously reading. Asking it to stop...")); 236 237 delay(1500); 238 } 239 else 240 { 241 //The module did not respond so assume it's just been powered on and communicating at 115200bps 242 softSerial.begin(115200); //Start software serial at 115200 243 244 nano.setBaud(baudRate); //Tell the module to go to the chosen baud rate. Ignore the response msg 245 246 softSerial.begin(baudRate); //Start the software serial port, this time at user's chosen baud rate 247 248 delay(250); 249 } 250 251 //Test the connection 252 nano.getVersion(); 253 if (nano.msg[0] != ALL_GOOD) return (false); //Something is not right 254 255 //The M6E has these settings no matter what 256 nano.setTagProtocol(); //Set protocol to GEN2 257 258 nano.setAntennaPort(); //Set TX/RX antenna ports to 1 259 260 return (true); //We are ready to rock 261} 262
Timer Code
c_cpp
1#include <SoftwareSerial.h> 2SoftwareSerial softSerial(2, 3); 3#include 4 "SparkFun_UHF_RFID_Reader.h" 5RFID nano; 6#define buzzer 9 7#define buzzergnd 8 10 9 10//place variables - data placement 11int place = 1; 12float seconds; 13float 14 personTime; 15unsigned long currentMillis = 0; 16unsigned long prevMillis = millis; 17unsigned 18 long minutes = 0; 19int heat = 1; 20 21//switches and such 22const int buttonPin 23 = 6; 24int buttonPushCounter = 1; 25int buttonState = 0; 26int lastButtonState 27 = 0; 28int onbtn = 9; 29int offbtn = 8; 30 31// create structure to filter 32struct 33 DubFilter { 34 uint8_t EPC[12]; 35 //unsigned long LastTime; // optionally 36 you could add data to capture 37}; 38 39// maximum number of unique EPC 40#define 41 MaxEPC 15 42struct DubFilter dub[MaxEPC]; 43 44 45void setup() { 46//RFID 47pinMode(onbtn, 48 INPUT); 49pinMode(offbtn, INPUT); 50pinMode(12, OUTPUT); 51pinMode(7, OUTPUT); 52pinMode(buzzer, 53 OUTPUT); 54pinMode(buzzergnd, OUTPUT); 55digitalWrite(buzzergnd, LOW); 56Serial.begin(115200); 57while(! 58 Serial); 59 60if(setupNano(38400) == false){ 61 Serial.println("Module failed 62 to respond"); 63 while (1); 64} 65nano.setRegion(REGION_NORTHAMERICA); 66nano.setReadPower(1500); 67 68// 69 init de-dub 70for (uint8_t i=0 ; i < MaxEPC ; i++) 71 dub[i].EPC[0] = 0; 72 73Serial.println("Ready"); 74Serial.println("Turn 75 on switch to begin race"); 76/*while(!Serial.available()); 77 Serial.read(); 78 79 nano.startReading(); 80 digitalWrite(12, HIGH); 81 Serial.println("RFID 82 Reader active. Ready to begin race"); 83*/ 84//timing 85pinMode(buttonPin, INPUT); 86 87} 88 89void 90 startRace(){ 91 Serial.print("Race "); 92 Serial.print(heat); 93 Serial.println(" 94 started"); 95 heat++; 96 flash(); 97} 98 99//where the magic happens 100void 101 runTimer(){ 102 103 currentMillis = millis(); 104 seconds = currentMillis - 105 prevMillis; 106 float personTime = seconds/1000; 107 108 if(seconds < 100){ 109 110 startRace(); 111 } 112 113 //data - THIS IS WHERE IT ALL GOES DOWN 114 if(nano.check() 115 == true){ 116 byte responseType = nano.parseResponse(); 117 118 if(responseType 119 == RESPONSE_IS_TAGFOUND){ 120 121 // it is already in the list 122 if 123 ( DeDub() ) return ; 124 125 Serial.print(place); 126 Serial.print(" 127 "); 128 byte tagEPCBytes = nano.getTagEPCBytes(); 129 for(byte x = 0 130 ; x< tagEPCBytes ; x++){ 131 if(nano.msg[31 + x] < 0x10) Serial.print("0"); 132 133 134 Serial.print(char(nano.msg[31 + x])); 135 Serial.print(("")); 136 137 } 138 unsigned minutes = (personTime + .0005) /60; 139 personTime 140 -= minutes * 60; 141 Serial.print(" "); 142 Serial.print(minutes); 143 144 Serial.print(':'); 145 if ((personTime + 0.0005) < 10) 146 Serial.print('0'); 147 148 Serial.println(personTime, 2); 149 place++; 150 // flash(); 151 // 152 delay(10); 153 } 154 } 155} 156 157/** 158 * This routine will check against 159 the table 160 * If EPC is already in the table true will be returned. 161 * if NOT 162 EPC will be added to the list and false is turned 163 */ 164bool DeDub() { 165 166 uint8_t i,x; 167 bool MissMatch = false; 168 169 // get the num EPC bytes 170 171 uint8_t tagEPCBytes = 12; 172 173 // check each entry in the table 174 for 175 (i = 0 ; i < MaxEPC; i++){ 176 177 // if empty entry 178 if (dub[i].EPC[0] 179 == 0) break; 180 181 MissMatch = false; 182 for(x = 0 ; x< tagEPCBytes ; 183 x++){ 184 185 // check for miss match 186 if(nano.msg[31 + x] != dub[i].EPC[x] 187 ){ 188 MissMatch = true; 189 break; 190 } 191 } 192 193 // 194 A this point we check for MisMatch (false means we have a Match) 195 if (! MissMatch) 196 return true; 197 198 } 199 200 // EPC was not in the list already 201 if (i 202 == MaxEPC) { 203 Serial.println("Table is full\ 204Can NOT add more"); 205 } 206 207 else { 208 // add to the list 209 for(x = 0 ; x< tagEPCBytes ; x++){ 210 211 // Add to the list 212 dub[i].EPC[x] = nano.msg[31 + x]; 213 } 214 215 } 216 return(false); 217} 218 219void flash(){ 220 tone(buzzer, 2349); 221 delay(150); 222 223 noTone(buzzer); 224} 225 226void stopTimer(){ 227 228 seconds = 0; 229 place 230 = 1; 231 minutes = 0; 232 prevMillis = millis(); 233 234} 235 236void loop() 237 { 238 // put your main code here, to run repeatedly: 239buttonState = digitalRead(buttonPin); 240 241 if(buttonState == HIGH){ 242 runTimer(); 243 digitalWrite(7, HIGH); 244 245 } 246 else{ 247 stopTimer(); 248 digitalWrite(7, LOW); 249 } 250 251int 252 onbtnstate = digitalRead(onbtn); 253int offbtnstate = digitalRead(offbtn); 254if 255 (onbtnstate == HIGH){ 256 nano.startReading(); 257 digitalWrite(12, HIGH); 258 259 Serial.println("RFID Reader Active"); 260 delay(100); 261} 262if (offbtnstate 263 == HIGH){ 264 nano.stopReading(); 265 digitalWrite(12, LOW); 266 Serial.println("RFID 267 Reader deactivated"); 268 delay(100); 269} 270 271} 272 273boolean setupNano(long 274 baudRate) 275{ 276 nano.begin(softSerial); //Tell the library to communicate over 277 software serial port 278 279 //Test to see if we are already connected to a module 280 281 //This would be the case if the Arduino has been reprogrammed and the module has 282 stayed powered 283 softSerial.begin(baudRate); //For this test, assume module is 284 already at our desired baud rate 285 while (softSerial.isListening() == false); 286 //Wait for port to open 287 288 //About 200ms from power on the module will send 289 its firmware version at 115200. We need to ignore this. 290 while (softSerial.available()) 291 softSerial.read(); 292 293 nano.getVersion(); 294 295 if (nano.msg[0] == ERROR_WRONG_OPCODE_RESPONSE) 296 297 { 298 //This happens if the baud rate is correct but the module is doing a 299 ccontinuous read 300 nano.stopReading(); 301 302 Serial.println(F("Module 303 continuously reading. Asking it to stop...")); 304 305 delay(1500); 306 } 307 308 else 309 { 310 //The module did not respond so assume it's just been powered 311 on and communicating at 115200bps 312 softSerial.begin(115200); //Start software 313 serial at 115200 314 315 nano.setBaud(baudRate); //Tell the module to go to the 316 chosen baud rate. Ignore the response msg 317 318 softSerial.begin(baudRate); 319 //Start the software serial port, this time at user's chosen baud rate 320 321 delay(250); 322 323 } 324 325 //Test the connection 326 nano.getVersion(); 327 if (nano.msg[0] 328 != ALL_GOOD) return (false); //Something is not right 329 330 //The M6E has these 331 settings no matter what 332 nano.setTagProtocol(); //Set protocol to GEN2 333 334 335 nano.setAntennaPort(); //Set TX/RX antenna ports to 1 336 337 return (true); 338 //We are ready to rock 339} 340
Timing Software
c_cpp
Timing Software
1/* 2 Welcome! 3Ensure all cables are properly connected. 4First, press on the Right Arrow in the upper left hand corner. When 5you hover on it, it will say "Upload". Wait for the message 6"Done Uploading" to appear in the bottom of this screen. 7Then click on the magnifying glass in the upper right corner. 8UNABLE TO UPLOAD ERROR? - Make sure your board is connected 9properly. If you receive thhis error, reference the troubleshooting 10section of the manual. 11 12System is ready to begin when "Ready" message appears. 13 14TO START A RACE 151. Activate starter arm switch (red toggle) 162. Starter button is now ready to start, push it to start a race OR 17if starter gun is connected, pull the trigger to start a race 183. Deactivate starter arm switch (red toggle) 19 20MID-RACE OPERATION 21If split times are desired, press the RFID activation button (silver 22button) and wait for all athletes to cross the finish line. To start 23the next lap, press the start button. 24 25TO END A RACE 26When athletes are about to finish the race, activate the RFID reader 27with the silver activate button. Once all athetes are across, 28turn the RFID reader off by pressing the button again. To end the 29timer, activate the starter arm switch and press the start button. 30 31Questions? Comments? Concerns? 32Contact John McKellar at (208) 201-6279 33 34 35 36 37 38 39 DO NOT TYPE IN THIS PROGRAM, ESPECIALLY THE SENSITIVE CODE BELOW. 40 TYPING INTO IT WILL CAUSE THE SYSTEM TO STOP WORKING. 41 */ 42#include <SoftwareSerial.h> 43SoftwareSerial softSerial(2, 3); 44#include "SparkFun_UHF_RFID_Reader.h" 45RFID nano; 46 47 48//place variables - data placement 49int place = 1; 50float seconds; 51float personTime; 52unsigned long currentMillis = 0; 53unsigned long prevMillis = millis; 54unsigned long minutes = 0; 55int heat = 1; 56bool gunReady = false; 57bool panelReady = false; 58int rfidcounter = 1; 59#define piezo 10 60bool data = true; 61int note = 2000; 62 63#define buzzgnd 9 64 65//switches and such 66const int buttonPin = 6; 67int buttonPushCounter = 1; 68int buttonState = 0; 69int lastButtonState = 0; 70int rfidbtn = 8; 71int gun = 13; 72int gunCounter = 1; 73int gunState = 0; 74int lastGunState = 0; 75int lapno = 1; 76 77// create structure to filter 78struct DubFilter { 79 uint8_t EPC[12]; 80 //unsigned long LastTime; // optionally you could add data to capture 81}; 82 83// maximum number of unique EPC 84#define MaxEPC 40 85struct DubFilter dub[MaxEPC]; 86 87 88void setup() { 89 90//RFID 91pinMode(gun, INPUT); 92pinMode(rfidbtn, INPUT); 93pinMode(12, OUTPUT); 94 95 96digitalWrite(buzzgnd, LOW); 97 98Serial.begin(115200); 99while(! Serial); 100 101if(setupNano(38400) == false){ 102 Serial.println("Module failed to respond"); 103 while (1); 104} 105 106nano.setRegion(REGION_NORTHAMERICA); 107nano.setReadPower(2700); 108 109// init de-dub 110for (uint8_t i=0 ; i < MaxEPC ; i++) 111 dub[i].EPC[0] = 0; 112 113Serial.println("Ready"); 114pinMode(buttonPin, INPUT); 115 116pinMode(piezo, OUTPUT); 117pinMode(buzzgnd, OUTPUT); 118} 119void startRace(){ 120 lapno = 1; 121 Serial.print("Race "); 122 Serial.print(heat); 123 Serial.println(" started"); 124 125 heat++; 126 lap(); 127} 128 129void lap(){ 130 Serial.print("Lap "); 131 Serial.println(lapno); 132 133 place = 1; 134 for (uint8_t i=0 ; i < MaxEPC ; i++) 135 dub[i].EPC[0] = 0; 136 137 lapno++; 138} 139 140//where the magic happens 141void runTimer(){ 142 143 currentMillis = millis(); 144 seconds = currentMillis - prevMillis; 145 float personTime = seconds/1000; 146unsigned minutes = (personTime + .0005) /60; 147 personTime -= minutes * 60; 148 149 150 151 152 153 //data - THIS IS WHERE IT ALL GOES DOWN 154 if(nano.check() == true){ 155 byte responseType = nano.parseResponse(); 156 157 if(responseType == RESPONSE_IS_TAGFOUND){ 158 159 // it is already in the list 160 161 if ( DeDub() ) return ; 162 163 Serial.print(place); 164 Serial.print(" "); 165 byte tagEPCBytes = nano.getTagEPCBytes(); 166 for(byte x = 0 ; x< tagEPCBytes ; x++){ 167 if(nano.msg[31 + x] < 0x10) Serial.print("0"); 168 169 Serial.print(char(nano.msg[31 + x])); 170 Serial.print(("")); 171 } 172 173 Serial.print(" "); 174 Serial.print(minutes); 175 Serial.print(':'); 176 if ((personTime + 0.0005) < 10) 177 Serial.print('0'); 178 Serial.println(personTime, 2); 179 180 place++; 181tone(piezo, note, 1000); 182tone(12, note, 1000); 183 } 184 } 185 186} 187void playTone(){ 188 tone(piezo, note, 1000); 189 tone(12, note, 1000); 190 191} 192 193/** 194 * This routine will check against the table 195 * If EPC is already in the table true will be returned. 196 * if NOT EPC will be added to the list and false is turned 197 */ 198bool DeDub() { 199 uint8_t i,x; 200 bool MissMatch = false; 201 202 // get the num EPC bytes 203 uint8_t tagEPCBytes = 12; 204 205 // check each entry in the table 206 for (i = 0 ; i < MaxEPC; i++){ 207 208 // if empty entry 209 if (dub[i].EPC[0] == 0) break; 210 211 MissMatch = false; 212 for(x = 0 ; x< tagEPCBytes ; x++){ 213 214 // check for miss match 215 if(nano.msg[31 + x] != dub[i].EPC[x] ){ 216 MissMatch = true; 217 break; 218 } 219 } 220 221 // A this point we check for MisMatch (false means we have a Match) 222 if (! MissMatch) return true; 223 224 } 225 226 // EPC was not in the list already 227 if (i == MaxEPC) { 228 Serial.println("Table is full\ 229Can NOT add more"); 230 } 231 else { 232 // add to the list 233 for(x = 0 ; x< tagEPCBytes ; x++){ 234 // Add to the list 235 dub[i].EPC[x] = nano.msg[31 + x]; 236 } 237 } 238 return(false); 239} 240void flash(){ 241 242} 243void stopTimer(){ 244 seconds = 0; 245 place = 1; 246 minutes = 0; 247 prevMillis = millis(); 248} 249void loop() { 250 // put your main code here, to run repeatedly: 251 gunState = digitalRead(gun); 252buttonState = digitalRead(buttonPin); 253 if(buttonState == HIGH){ 254 if(gunState == HIGH){ 255 256 if(gunCounter %2 != 0){ 257 startRace(); 258 gunCounter++; 259 tone(piezo, note, 1000); 260 261 delay(150); 262 } 263 264 else if(gunCounter %2 == 0){ 265 gunCounter++; 266 Serial.print("Race "); 267 Serial.print(heat - 1); 268 Serial.println(" Ended"); 269 tone(piezo, note, 1000); 270 271 delay(150); 272 273 274 } 275 276} 277} 278else if(buttonState == LOW){ 279 if(gunState == HIGH){ 280 lap(); 281 tone(piezo, note, 500); 282 delay(175); 283 } 284} 285 286if(gunCounter %2 == 0){ 287 runTimer(); 288 } 289 290 291 if(gunCounter %2 != 0){ 292 stopTimer(); 293 for (uint8_t i = 0 ; i < MaxEPC ; i++) 294 dub[i].EPC[0] = 0; 295 } 296 297 298 299 300int rfidbtnstate = digitalRead(rfidbtn); 301if (rfidbtnstate == HIGH){ 302 rfidcounter++; 303 if(rfidcounter %2 == 0){ 304 nano.startReading(); 305 digitalWrite(7, HIGH); 306 digitalWrite(5, LOW); 307 308 //Serial.println("RFID reader activated"); 309 } 310 else if(rfidcounter %2 != 0){ 311 nano.stopReading(); 312 digitalWrite(7, LOW); 313 digitalWrite(5, HIGH); 314 //Serial.println("RFID Reader deactivated"); 315 } 316 317 delay(200); 318} 319 320 321if(Serial.available() > 0){ 322 char code = Serial.read(); 323 if(code == '1'){ 324 nano.startReading(); 325 digitalWrite(7, HIGH); 326 digitalWrite(5, LOW); 327 Serial.println("RFID ON"); 328 329 } 330 if(code == '2'){ 331 332 nano.stopReading(); 333 digitalWrite(7, LOW); 334 digitalWrite(5, HIGH); 335 Serial.println("RFID OFF"); 336 } 337} 338//end loop 339 340} 341boolean setupNano(long baudRate) 342{ 343 nano.begin(softSerial); //Tell the library to communicate over software serial port 344 345 //Test to see if we are already connected to a module 346 //This would be the case if the Arduino has been reprogrammed and the module has stayed powered 347 softSerial.begin(baudRate); //For this test, assume module is already at our desired baud rate 348 while (softSerial.isListening() == false); //Wait for port to open 349 350 //About 200ms from power on the module will send its firmware version at 115200. We need to ignore this. 351 while (softSerial.available()) softSerial.read(); 352 353 nano.getVersion(); 354 355 if (nano.msg[0] == ERROR_WRONG_OPCODE_RESPONSE) 356 { 357 //This happens if the baud rate is correct but the module is doing a ccontinuous read 358 nano.stopReading(); 359 360 Serial.println(F("Module continuously reading. Asking it to stop...")); 361 362 delay(1500); 363 } 364 else 365 { 366 //The module did not respond so assume it's just been powered on and communicating at 115200bps 367 softSerial.begin(115200); //Start software serial at 115200 368 369 nano.setBaud(baudRate); //Tell the module to go to the chosen baud rate. Ignore the response msg 370 371 softSerial.begin(baudRate); //Start the software serial port, this time at user's chosen baud rate 372 373 delay(250); 374 } 375 376 //Test the connection 377 nano.getVersion(); 378 if (nano.msg[0] != ALL_GOOD) return (false); //Something is not right 379 380 //The M6E has these settings no matter what 381 nano.setTagProtocol(); //Set protocol to GEN2 382 383 nano.setAntennaPort(); //Set TX/RX antenna ports to 1 384 385 return (true); //We are ready to rock 386} 387
Downloadable files
Schematic
Schematic
Circuit Diagram
Circuit Diagram

Documentation
Chip Holder
Chip Holder
Comments
Only logged in users can leave comments