Arduino and NFC
-
the lib itead supplied
http://imall.iteadstudio.com/im130625002.htmllooks like a generic lib from adafruit
// PN532 library by adafruit/ladyada // MIT license /* authenticateBlock, readMemoryBlock, writeMemoryBlock contributed */ /* by Seeed Technology Inc (www.seeedstudio.com) */ /* Modified history: */ /* Nov 5,2012 modified by Frankie.Chu at Seeed. */ /* Add some program comments of some key functions; */ /* Modified the basic interface functions spiwrite() and spiread() */ /* to be write() and read(),and they will call the functions of */ /* class SPIClass but not to simulate timing of SPI; */ /* Rename all of the functions to be like the abAbAb; */ /* Modified the constructor of PN532 class; */
-
Ah yep, saw that. What are you actually using to read the code after the reader unit though?
what do you mean?just tried the spi lib straight from adafruit's github, same thing. works fine with my other tags but nothing on the ring.
I've put the ring in just about every conceivable position. If there was a sweetspot i feel i would have found it by now./e
turned on debugging in the lib, its not picking up anything from the ring, doesn't seem to be an issue with the lib as far as i can tell -
Ok, maybe I'm looking at the wrong reader unit here - the one I'm seeing is an all-in-one reader which outputs to another device via SPI. That device is an Arduino? I'm wondering what code you're running on that.
-
Yah, my pn532 is communicating with my uno via spi. I've just been testing with the example files in the lib rather than my lock code. Same setup as that video I posted, I've just removed the strike from the equation.
I enabled debugging in the lib which was spitting out the unadulterated spi stream. No data while holding the ring in various positions.
Reading: 0x0 0x0 0xFF 0x0 0xFF 0x0According to the app on my phone (NFC TagInfo) the chip in the tag that works is identical to the chips in the ring aside from the id.
Tom replied to my email and said they would look into getting some inlays sent to me, so hopefully I will be able to test with one of those as well soon.
What NFC modules have you ordered? I will start looking around and order some in the next few days so we cover a larger spectrum in our testing. Will be ordering various antenna's as well, I still have a nagging feeling that is the problem with mine./**************************************************************************/ /*! @brief Reads n bytes of data from the PN532 via SPI @param buff Pointer to the buffer where data will be written @param n Number of bytes to be read */ /**************************************************************************/ void Adafruit_PN532::readspidata(uint8_t* buff, uint8_t n) { digitalWrite(_ss, LOW); delay(2); spiwrite(PN532_SPI_DATAREAD); #ifdef PN532DEBUG Serial.print("Reading: "); #endif for (uint8_t i=0; i<n; i++) { delay(1); buff[i] = spiread(); #ifdef PN532DEBUG Serial.print(" 0x"); Serial.print(buff[i], HEX); #endif } #ifdef PN532DEBUG Serial.println(); #endif digitalWrite(_ss, HIGH); }
/**************************************************************************/ /*! @brief Low-level SPI read wrapper @returns The 8-bit value that was read from the SPI bus */ /**************************************************************************/ uint8_t Adafruit_PN532::spiread(void) { int8_t i, x; x = 0; digitalWrite(_clk, HIGH); for (i=0; i<8; i++) { if (digitalRead(_miso)) { x |= _BV(i); } digitalWrite(_clk, LOW); digitalWrite(_clk, HIGH); } return x; }
-
Ah ok, thanks for that - I'm still waiting for my modules to turn up so that I can form a more knowledgeable opinion on things. Probably should have ordered them earlier!
http://www.ebay.com.au/itm/321097986980
http://www.ebay.com.au/itm/221249331693
http://www.ebay.com.au/itm/161120806341
http://www.ebay.com.au/itm/151217926952
http://www.ebay.com.au/itm/321324810397A bit of a scattergun approach, but I'll end up using them all I'm sure.
-
Well, I got my small red unit after work today... and it is a pain to get working. The seller provided sketch refuses to compile and the adafruit one isn't set up properly for the unit. Sigh.
So, I'm playing around with getting that one working at all, let alone with the rings. -
Well, I got my small red unit after work today... and it is a pain to get working. The seller provided sketch refuses to compile and the adafruit one isn't set up properly for the unit. Sigh.
Pass along the sketch, I can take a look after work.
-
It's all in here, I'm off to bed!
http://www.elechouse.com/elechouse/images/product/PN532_module_V3/PN532_%20Manual_V3.pdf
-
It's all in here, I'm off to bed!
Wow, that lib is all sorts of ugly. Probably better off getting the adafruit lib working.
What is the issue with it?
-
Yeah, you see now why I went to bed hey!
It simply wont verify and compile for me, I was working through it bit by bit and repairing things as I went but I got overtired and ran out of coffee and cigarettes. It was a bad scene.
I'll try again tonight and see how it goes, I'd like to get theirs working at least and then try the Adafruit one after. -
Sigh. I reckon I've got a dud. The adafruit setup for I2C reports that the PN532 is there, and ready, but the **** thing wont even read the tags that came with it.
Next! -
I've used my ring successfully with Adafruit PN532 breakout board. They also have a PN532 arduino shield.
-
I've used my ring successfully with Adafruit PN532 breakout board. They also have a PN532 arduino shield.
Nice, thanks! How is the performance with the ring?
-
You know, I hadn't really tested that. I'll let you know after I run it through some tests. I [i:12xo79s3]can [/i:12xo79s3]tell you that the sweet spot is right at the 'base' of the antenna i.e. the side of the loop closest to the IC.
-
It's good to know someone is having a bit of luck! I'm stuck waiting on the postman again.
-
My elechouse reader (looks like the same red one Lokki has) came today, and I've just spent a couple of hours trying to get it to work.
Good news is it works with the supplied cards and arduino uno. I used the downloads from here
HTTPS://github.com/elechouse/PN532
Connected to I2C
Literally just got it reading so still need to understand it more but those files are worth a try.
Can't try it with anything else though...
-
Haha! I'm an idiot - all my issues were caused by not installing the PN532 libraries as seperate libraries.
The libraries contained within the PN532 directory have to be copied seperately into the Arduino libraries directory (sometimes I am really really bad at reading instructions).Small red elechouse clone card reader is now working via I2C!
-
Haha! I'm an idiot - all my issues were caused by not installing the PN532 libraries as seperate libraries.
Nice! How's it working with the ring?
Basically I just need to find a module/antenna that can read the ring reliably through a somewhat thin layer of ABS plastic. Since I'm making the enclosure with my 3d printer, I have flexibility in terms of thickness, but obviously, thicker is better to ensure it can take some abuse. -
Now that I've actually done the right thing with the libraries I've had a pay around with the example files and the reader works perfectly with the rings every time. The only one it has minor issues with is the Alpha with the slightly dodgy carbon fiber that John ended up replacing. That one needs to actually contact the top of the board before it will make a good read. Every other inlay reads within 15mm or so. It's worth noting that the elechouse board reads best from the top where all the SMD components are mounted so any covering layer will need to be thin to get a good read.
-
Yeah, now that it's working and I'm happy with it again it seems to be a really solid little unit. I'm not sure if you noticed, but the Arduino Uno next to it is actually a microduino unit. I'm going to see if I can set it all up as minimalistically as possible with just the reader, microduino core and a latching relay or two for the car engine start. If that works out well I'll see about adding a second reader for the driver's door!
It wont work as nicely in my skyline as it will eventually in my dodge because of the steering lock though. Has anyone ever seen an aftermarket electric fail-open latch that would work in a steering column?