tag:blogger.com,1999:blog-42771067031167000082024-03-20T21:09:52.761+01:00AccessThingA diary of my journey towards a DIY access control system for our house.Unknownnoreply@blogger.comBlogger11125tag:blogger.com,1999:blog-4277106703116700008.post-87329590068662339982016-09-29T22:15:00.003+02:002016-09-29T22:15:35.547+02:00KiCAD schematic symbolsTonight I worked on the I/O-portion of the RPi HAT add-on board.<br />
KiCAD didn't have schematic symbols for the <a href="http://www.ti.com/product/sn74hc244" target="_blank">74HC244</a> Octal buffer/line driver and the <a href="https://www.maximintegrated.com/en/products/interface/transceivers/MAX3483E.html" target="_blank">MAX3483E</a> RS-485 transceiver I want to use, so I spent the evening creating the two symbols in a library file.<br />
The library is available at <a href="https://github.com/Sthing/AccessThing/tree/master/KiCAD/Libraries">https://github.com/Sthing/AccessThing/tree/master/KiCAD/Libraries</a>.<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4277106703116700008.post-79885163784890631052016-09-15T19:39:00.004+02:002016-09-15T19:45:46.768+02:00Two steps back, on step forwardIt has been more than a year since I wrote about my efforts to create a <a href="http://access.thing.dk/2015/08/print-for-touch-keypad.html">print for the keypad</a>. Since then I have mostly gone backwards...<br />
<br />
I found out that soldering a 0.4mm Quad Flat No-leads package requires good eyes. I did the soldering wrong at first, and probably toasted the chip when testing it - at least it did not work after resoldering it under a microscope. I *knew* that I had two extra chips somewhere - but could not find them.<br />
<br />
Thus I decided to go with a ready-made breakout board instead. Etched a new circuit board - and discovered that placing the electrodes behind a 6mm fibre cement board did not work even though I had tested it before doing the first printed circuit board.<br />
<br />
New strategy: Create 12 "buttons" from a aluminum rod on a lathe. Use a long time figuring out how to solder leads to the aluminum. Drill holes in fiber board and mount buttons. Decide it looks ugly and scratch the concept.<br />
<br />
Finally I gave up and bought a water proof stainless steel matrix keypad from <a href="https://chenttech.en.alibaba.com/product/60344336545-802136019/IP68_waterproof_3x4_digital_numeric_metal_keypads.html" target="_blank">Alibaba.com</a>. It cost me 30 USD for the keypad, 30 USD shipping, and ~15USD in VAT, a total of 75 USD. It is more than I like, but it works! ;-) So now I am back to using a PCF8574 8-bit I/O expander for the keypad.<br />
<div class="separator" style="clear: both; text-align: center;">
<img alt="" border="0" height="342" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXc0J-52T-WCTCJ_WoQLuSWreHUsHRATyFWEYVeVb2KNbJfi6TCUPUFmOlpuaWcUclwyfqwUAgfmxvFhVLvrosvVcZ9TcBiuir5CRrSx8imQRWL1uGv3o18Zxy_NgPzOifmVtHhHSfMg4/s400/CTKPS09-12.jpg" title="CTKPS09-12 keypad" width="400" /></div>
I have spent so little time on the project lately, that it is hard to remember how far I have come. So tonight I will start a <a href="http://access.thing.dk/p/todo.html">To-do list</a>. Hopefully that will make it a little easier to spend an hour or two on actually working - and not just remembering how far I got the last time.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4277106703116700008.post-86144631758838163222015-08-20T21:41:00.002+02:002015-08-20T21:43:55.678+02:00Print for touch keypadAt some time I decided to use the Freescale's <a href="http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MPR121">MPR121 Proximity Capacitive Touch Sensor Controller </a>for the keypad at the entrance.<br />
The chip has 0.4mm pin spacing so I decided not to try isolation milling and because of the print size (about 3x4 inches) it would not be cheap to order a finished print. I could use a breakout board - readily available at eBay for a few dollars - but I got stubborn and decided to etch my own print.<br />
I ordered <a href="http://www.reichelt.de/Double-Coated-PCBs/BEL-75X100-2/3/index.html?&ACTION=3&LA=2&ARTICLE=33773&GROUPID=3369&artnr=BEL+75X100-2">photo sensitive PCB from Reichelt</a> and found out that I had to illuminate the board for about 25 minutes with the lamp I used. I got stubborn again and started building a UV-LED based PCB lamp. It took to long - and I am not quite done - but today I produced the print I needed. Now I only need to illuminate the board for 40 seconds ;-)<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVCg2iclZ2BpnDj6YA4IWSi2MaC1u0oowa_hHwvAzlCmkvITPYFy8dp0ib5PL7XQqS4w4b_oMi-1CbDwhP7mDdE44lIFepZ4GeUb4VtrNkQSL9ui1VkOJD6mt5sLmG1lVBDug_ZU94vZo/s1600/IMG_8301.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="425" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVCg2iclZ2BpnDj6YA4IWSi2MaC1u0oowa_hHwvAzlCmkvITPYFy8dp0ib5PL7XQqS4w4b_oMi-1CbDwhP7mDdE44lIFepZ4GeUb4VtrNkQSL9ui1VkOJD6mt5sLmG1lVBDug_ZU94vZo/s640/IMG_8301.JPG" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Large pads because it will be placed behind a 6mm board.</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWBUXJGf8F1lCwikgxYgIrRlQ0c-Knz8RNIzZ42Px1Ik6gewPY7MBmOZhS5LTP6d8IbsCpuIBYLUma9S35wtT4XhVoGAmg3_CzWRfn5BpfhyHQFUxWVemKftYjiFnn_oUhuUPT7ieph-8/s1600/IMG_8302.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="426" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWBUXJGf8F1lCwikgxYgIrRlQ0c-Knz8RNIzZ42Px1Ik6gewPY7MBmOZhS5LTP6d8IbsCpuIBYLUma9S35wtT4XhVoGAmg3_CzWRfn5BpfhyHQFUxWVemKftYjiFnn_oUhuUPT7ieph-8/s640/IMG_8302.JPG" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Traces from the pads back to the MPR121 chip on the reverse.</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivaMjfy3av4MMHLOpsXIUimj1kgHHkVWKzcUvPOb0FKL3WahehR77GRV1f62j-inKMEpYGk9nY60cTb6CC4xa8fdJQvroK_divzVbFp89zV8szabQEybaJPWAGCRQ_Ow1gf1RVcshi3o0/s1600/IMG_8307.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="426" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivaMjfy3av4MMHLOpsXIUimj1kgHHkVWKzcUvPOb0FKL3WahehR77GRV1f62j-inKMEpYGk9nY60cTb6CC4xa8fdJQvroK_divzVbFp89zV8szabQEybaJPWAGCRQ_Ow1gf1RVcshi3o0/s640/IMG_8307.JPG" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Close up of the area where the chip is to be mounted.</td></tr>
</tbody></table>
Next week I hope to solder the chip and test the board.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4277106703116700008.post-53147673816128064072014-11-20T23:43:00.004+01:002014-11-20T23:43:59.008+01:00The bigger pictureTonight I will try to list the hardware components I plan to include in the system, and try to figure out how to connect them all.<br />
<ul>
<li>Input/output devices outside the door, controlled by an Arduino-like microcontroller:</li>
<ul>
<li><a href="http://www.ebay.com/itm/190863389215?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649">Card reader for ISO 14443A cards</a> (like MIFARE and NFC).<br />MFRC522 chip, SPI interface.</li>
<li><a href="http://www.ebay.com/itm/125Khz-RFID-Mini-Module-Kits-KeyCard-ID-Card-/251195475040">Card reader for EM4100 125kHz RFID cards</a>.<br />Serial 9600/8/N/1 interface, 3 pins: Serial data, Data ready pulse, <span style="text-decoration: overline;">RESET.</span></li>
<li>Some sort of keypad.<br />Until recently I planned to use a cheap ($2) <a href="http://www.sunsky-online.com/product/default!view.do?subject.id=213418">4x3 key membrane switch matrix keypad</a>. It is very easy to use with the <a href="http://playground.arduino.cc/Code/Keypad">Arduino Keypad library</a> - but this eats 7 I/O-pins. However the library now supports the use of I²C port expanders (like <a href="http://www.nxp.com/documents/data_sheet/PCF8574.pdf">PCF8574</a> or <a href="http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf">MCP23017</a>) which lowers the number of required pins to 2: SDA and SCL - and they can be reused for other I²C devices.<br />Two weeks ago I discovered the <a href="https://www.freescale.com/webapp//sps/site/prod_summary.jsp?code=MPR121">Freescale MPR121 Proximity Capacitive Touch Sensor Controller</a>. It is a small (3mm x 3mm) chip that allows up to 12 electrodes to be used as touch inputs. The interface is I²C. I requested a free sample (3 pcs) from their website and 5 days later FedEx arrived with an envelope from Malaysia. Thank you, Freescale! So now I have to try and see if capacitive touch can provide a better interface than the membrane switch keypad.</li>
<li><a href="http://www.ebay.com/itm/400347868649?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649">Nokia 5110 84x48 pixel display</a>.<br />Philips <a href="https://www.sparkfun.com/datasheets/LCD/Monochrome/Nokia5110.pdf">PCD8544</a> controller, SPI interface.</li>
</ul>
<li>Sensors and actuators in the door and door frame, controlled by a Raspberry Pi:</li>
<ul>
<li><a href="http://www.abloy.com/Abloy/COM/Brochure%20downloads/Electromechanical%20lock%20cases/8802441_EL580_EL582_PE580.pdf">Ruko/Abloy EL582</a> solenoid lock.<br />1 output to control the solenoid (through a MOSFET).<br />2 inputs for position of bolt and handle.</li>
<li>A reed contact and a recessed magnet mounted in door and frame to detect if the door is really closed.<br />1 input.</li>
<li>A microswitch in back of the strike plate to detect if the dead bolt is in place.<br />1 input.</li>
</ul>
<li>Power supply - supplied by 230VAC mains.</li>
<ul>
<li>A 12V 7.2Ah lead acid battery so the access control system can keep running during power failures.</li>
<li>A battery charger (230VAC => 12VDC).</li>
<li>12V => 5V and/or 3.3V regulators for the electronics.</li>
<li>Perhaps use an analog input to monitor the voltage of the 12V battery.</li>
</ul>
<li>Wild ideas:</li>
<ul>
<li>A PIR-sensor to detect unathorized entry.</li>
<li>Monitor my <a href="https://www.indiegogo.com/projects/kibbi-complete-home-security-solution">Kibbi</a>-sensors for open windows.</li>
<li>A 12V sirene - if unauthorized entry is detected.<br />1 output (through a MOSFET).</li>
<li>A laser-grid in front of the door - to signal "armed" status ;-)</li>
</ul>
</ul>
<div>
And now it is late, and the connections must wait for another time. SPI, I²C, serial, RS485 - who knows.</div>
<br />
<br />Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-4277106703116700008.post-16181384092817435092014-10-31T00:02:00.000+01:002014-10-31T00:02:15.436+01:00Reboot! Join a hacker space.How time flies!<br />
<br />
It has been a year since my last post. The project has been at a complete standstill while other things happened in my life - like repapering the kids' rooms and restoring the front of a rotting caravan.<br />
<br />
All the while I have longed to continue the project but continually failed to actually *do* something. Eventually I decided to join our local hacker space <a href="http://hal9k.dk/">Hal9k</a>. I get around-the-clock access to the facilities, and - more importantly - club night every Thursday. Tonight is the third time I attend - and I love it. The other members are doing all kind of great (and weird) things, and are ready to tell about their projects. I have added a repeating weekly appointment to my calendar, so from now on Thursday night is dedicated to the AccessThing project. Great!<br />
<br />
So far I have spent the time remembering where I left the project a year ago, assembling my <a href="http://hdmipi.com/">HDMIPi</a> screen, and finally tonight made an LED blink when connected to the <a href="http://elinux.org/RPi_Low-level_peripherals#Bash_shell_script.2C_using_sysfs.2C_part_of_the_raspbian_operating_system">GPIOs</a> of the Raspberry Pi. I really like that the pins can be manipulated by writing to device files under /sys/class/gpio/.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO3hln6WHQakk6IjrEiuGVPW4ovDIClOqZ1C9nYmsUJWtZ3GlHB4egShO7GhD3aykx8_JI2HzAX_A6tVMWi_H38Jjq06pyjATOShuoNQqlsmQm8MjfxoHmXSH1JUCUmZD5PNTX00Mm1nw/s1600/HDMIPi+++GPIO.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO3hln6WHQakk6IjrEiuGVPW4ovDIClOqZ1C9nYmsUJWtZ3GlHB4egShO7GhD3aykx8_JI2HzAX_A6tVMWi_H38Jjq06pyjATOShuoNQqlsmQm8MjfxoHmXSH1JUCUmZD5PNTX00Mm1nw/s1600/HDMIPi+++GPIO.jpg" height="226" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">My HDMIPi connected to a breadboard - and my first LED connected to GPIO25.</td></tr>
</tbody></table>
<br />
Two weeks ago I also decided to order another kind of MOSFET. The <a href="http://www.irf.com/product-info/datasheets/data/irl540n.pdf">IRL540N</a> I had bought last summer needs a higher gate-source voltage than 3.3V (from the GPIOs of the Raspberry Pi). So I ordered a roll of 50 low voltage <a href="http://www.irf.com/product-info/datasheets/data/irlml2502.pdf">IRL2502</a> MOSFETs from eBay. When they arrived today I had to pull out my magnifier - they are kind of tiny: 2.9mm x 2.3mm including the legs! Max ratings are 20V Drain-Source and 4.2A (at a higher Gate-Source voltage), so they should easily handle the 12V/220mA I need to drive the <a href="http://www.abloy.com/Abloy/COM/Brochure%20downloads/Electromechanical%20lock%20cases/8802441_EL580_EL582_PE580.pdf">Ruko/Abloy EL582</a> solenoid lock. But it might take a little practice to solder them.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjouNB59Yyar44uaIWumBIUIlLe0vgMB7C9nJvqEjcd0zqZCpWQ1qzEkkI_g5vM82X_3byHNC66tpz2AIkqsLOa9F5FCkFHKr1JZcUUC-YhFh0o8Dq3yVySFuLOwJZ8jplCiZF6MHebrMI/s1600/MOSFETs.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjouNB59Yyar44uaIWumBIUIlLe0vgMB7C9nJvqEjcd0zqZCpWQ1qzEkkI_g5vM82X_3byHNC66tpz2AIkqsLOa9F5FCkFHKr1JZcUUC-YhFh0o8Dq3yVySFuLOwJZ8jplCiZF6MHebrMI/s1600/MOSFETs.jpg" height="259" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">IRL540N and IRL2502.</td></tr>
</tbody></table>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4277106703116700008.post-80711462105101184032013-10-20T20:24:00.000+02:002013-10-20T20:24:03.834+02:00Pull request sentToday I finally finished my rewrite of the MFRC522 library and sent a pull request to the upstream repository: <a href="https://github.com/miguelbalboa/rfid/pull/9">https://github.com/miguelbalboa/rfid/pull/9</a>. Now I look forward to hear Miguel's response - will he welcome my changes or reject them as "too invasive"?<br />
Since last time I also added functions to use the MIFARE Classic Decrement/Increment/Restore/Transfer commands and an example of how to use them (it requires changing the sector trailer).<br />
<br />
The next step in the project is building the electronics for driving a <a href="http://www.abloy.com/Abloy/COM/Brochure%20downloads/Electromechanical%20lock%20cases/8802441_EL580_EL582_PE580.pdf">Ruko/Abloy EL582</a> solenoid lock I have bought for use in this project. I expect that to be a lot simpler than rewriting the MFRC522 library ;-)Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-4277106703116700008.post-83365788272630631172013-10-16T01:13:00.000+02:002013-10-16T01:13:27.141+02:00MFRC522 library cleanupAlmost 8 weeks ago I wrote: "I will translate the comments to English, clean up, and implement proper anticollision and support for 7 and 10 byte UIDs."<br />
<br />
I have now finished the following subjects:<br />
<br />
<ul>
<li>Anticollision</li>
<li>4, 7 and 10 byte UIDs (ie cascade levels 1, 2 and 3)</li>
<li>Cleanup</li>
<li>Verbose comments in English</li>
<li>Tested Authentication and reading from MIFARE Classic cards.</li>
</ul>
<div>
I still need a little work on:</div>
<div>
<ul>
<li>Testing writes to MIFARE Classic cards (should not be a problem).</li>
<li>Support for reading and writing MIFARE Ultralight cards.</li>
<li>Updated example scripts</li>
<li>Updated keywords.txt </li>
</ul>
</div>
<br />
So now I actually believe I will finish this job - and hopefully soon so I can get on to building some electronics for the electric lock.Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-4277106703116700008.post-81369489095592102372013-08-22T17:21:00.000+02:002013-08-22T17:21:21.894+02:00MIFARE: Initialization and anticollisionOh my - where did those four weeks go? Well, vacation and getting back to work took most of my time - but I did do a little work on the project.<div>
<br /></div>
<div>
The <a href="http://www.ebay.com/itm/400347868649?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649">Nokia 5110 84x48 pixel display</a> I mentioned last was tested briefly. The code from Adafruit worked just fine - and so did the backlight when I stopped connecting the pin to Vcc and used GND instead. Doh!</div>
<div>
<br /></div>
<div>
The <a href="http://www.ebay.com/itm/190863389215?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2648">MIFARE reader kit</a> has arrived. It is based on the NXP MFRC522 Contactless Reader IC, and uses SPI for communication with the micro controller. The <a href="http://www.nxp.com/documents/data_sheet/MFRC522.pdf">data sheet</a> for the MFRC522 IC clearly documents how to operate the reader chip, and (I quote) "The digital module manages the complete ISO/IEC 14443 A framing and error detection (parity and CRC) functionality." So far so good. But not a word about the protocol for communicating with the MIFARE chips.</div>
<div>
Some time with google.com reveals that the first level of missing information is contained in "ISO/IEC 14443-3 Identification cards -- Contactless integrated circuit cards -- Proximity cards -- Part 3: Initialization and anticollision". It is available for CHF 162 (about USD 175)! Hrmm - more than I like. Luckily the final draft from the <a href="http://wg8.de/">WG8 working group</a> is freely available <a href="http://wg8.de/wg8n1496_17n3613_Ballot_FCD14443-3.pdf">here</a>! Using this protocol I can get the UID of the RFID card. Accessing the card contents is another matter - but never mind, I only need the UID.</div>
<div>
<br /></div>
<div>
I looked around for existing Arduino code to access the reader and cards, and mostly I found variations of the same code:</div>
<div>
<ul>
<li>The "original" from Dr. Leong at <a href="http://www.b2cqshop.com/products/203-arduino-rfid-module-kit-1356-mhz-with-tags-spi-w-and-r-by-cooqrobot.aspx">B2CQSHOP</a> with Chinese comments.</li>
<li>A modified version from <a href="http://www.grantgibson.co.uk/blog/2012/04/how-to-get-started-with-the-mifare-mf522-an-and-arduino/">Grant Gibson</a>.</li>
<li>A library version from <a href="https://github.com/miguelbalboa/rfid">Miguel Balboa</a> with Spanish comments.</li>
</ul>
<div>
None of these variants support cards with 7 and 10 byte UIDs (the most common is 4 bytes - or at least used to be. MIFARE Ultralight has 7 byte UIDs). Also the code does not support the anticollision protocol, ie it only works if there is only one card in the RF field (I might be wrong on this one, I have not studied the code enough to be certain).</div>
</div>
<div>
<br /></div>
<div>
Actually there is another piece of software: NXP has a Visual C++ <a href="http://www.nxp.com/products/interface_and_connectivity/nfc_contactless_reader_ics/series/MFRC522.html#documentation">project available for download</a> (look for "200312"). After a cursory look I have decided to forget about NXP's code, and concentrate on the Arduino code from Miguel Balboa. I will translate the comments to English, clean up, and implement proper anticollision and support for 7 and 10 byte UIDs. All changes will be offered as a GitHub pull request to Miguel, but I do not yet know if he is interested. Stay tuned!</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4277106703116700008.post-85118107841540258412013-07-26T22:50:00.001+02:002013-07-26T22:50:30.123+02:00Using a matrix keypad is easy!Today I wanted to try out the <a href="http://www.sunsky-online.com/product/default!view.do?subject.id=213418">keypad</a> I have bought for my project. It is a cheap ($2) 4x3 key membrane switch matrix keypad.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfCmPY-yPG51nMMFxYe-ONT2_2_cIBrS5gzZ2PPQQwHN4lnYsaCyXUQRr2H9AmVGvpdQI8YMD4koViN2RROIIcjaOZabuwOXQ_u9SvZipP-5uHdp5t85k2I_CgLJmj3WitRfdHJFMUgR4/s1600/IMG_20130726_221702.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="272" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfCmPY-yPG51nMMFxYe-ONT2_2_cIBrS5gzZ2PPQQwHN4lnYsaCyXUQRr2H9AmVGvpdQI8YMD4koViN2RROIIcjaOZabuwOXQ_u9SvZipP-5uHdp5t85k2I_CgLJmj3WitRfdHJFMUgR4/s400/IMG_20130726_221702.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The keypad connected to my Iteaduino 2.2.</td></tr>
</tbody></table>
Using the Keypad library from <a href="http://playground.arduino.cc/Code/Keypad">http://playground.arduino.cc/Code/Keypad</a> I was up and running in a few minutes. If I can spare the 7 IO-pins required this is almost too easy ;-)<br />
<br />
I will have to find another way to connect it, as this connection uses pin 8 (ICP1), that I intend to use for the <a href="http://access.thing.dk/2013/07/decodingreading-125khz-rfid-tags-live.html">manchester decoding of EM4100 RFID tags</a>. However this is no problem, as I think I will end up using a barebone Arduino for the finished product.<br />
<br />
I am still waiting for the <a href="http://www.ebay.com/itm/190863389215?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2648">MIFARE reader kit</a>, so next I will look at my $3 <a href="http://www.ebay.com/itm/400347868649?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649">Nokia 5110 84x48 pixel display</a>. It has a Philips PCD8544 controller using SPI for communication. It is well documented, and Adafruit has both a <a href="http://learn.adafruit.com/nokia-5110-3310-monochrome-lcd">tutorial</a> and a <a href="https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library">library</a> for it.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4277106703116700008.post-58219536458651283702013-07-24T00:58:00.000+02:002013-07-24T00:58:54.488+02:00Decoding/reading 125kHz RFID tags - live at GitHubInitially I would like to create a system that could use any existing RFID-tag. That way we could use existing tags we already had from our jobs, transportation etc. So I ordered a <a href="http://www.ebay.com/itm/125Khz-RFID-Mini-Module-Kits-KeyCard-ID-Card-/251195475040">125kHZ RFID kit</a> and a <a href="http://www.ebay.com/itm/190863389215?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649">13.56MHz Mifare kit</a>. Both kits included both a reader circuit and a couple of sample cards.<br />
<br />
When the 125kHz kit arrived I did not have the courage to connect it to my Arduino, as I was afraid of toasting the inputs with RS232 level signals. I waited for my <a href="http://www.ebay.com/itm/261073779300?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649">DSO Quad pocket oscilloscope</a> to arrive (more about that in a later post) and hooked it up. It revealed that the claim about onboard level converters for RS232 was bogus. Pin 3 was only an inverted signal of pin 2. The good thing was that I only needed the TTL level signals and that it worked great as soon as I connected pin 2 (TX) to the Arduino pin 10 and ran this sketch:<br />
<pre><span style="color: #7e7e7e;">/*</span>
<span style="color: #7e7e7e;"> Receives from software serial, sends to hardware serial.</span><span style="color: #7e7e7e;"> </span>
<span style="color: #7e7e7e;"> RX is digital pin 10 (connect to TX of other device)</span>
<span style="color: #7e7e7e;"> */</span>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); <span style="color: #7e7e7e;">// RX, TX</span>
<span style="color: #cc6600;">
</span></pre>
<pre><span style="color: #cc6600;">void</span> <span style="color: #cc6600;"><b>setup</b></span>() {
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">begin</span>(9600);
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">println</span>(<span style="color: #006699;">"Scan card..."</span>);
mySerial.<span style="color: #cc6600;">begin</span>(9600); <span style="color: #7e7e7e;">// set the data rate for the SoftwareSerial port</span>
}
<span style="color: #cc6600;">void</span> <span style="color: #cc6600;"><b>loop</b></span>() { <span style="color: #7e7e7e;">// run over and over</span>
<span style="color: #cc6600;">if</span> (mySerial.<span style="color: #cc6600;">available</span>()) {
<span style="color: #cc6600;"><b>Serial</b></span>.<span style="color: #cc6600;">write</span>(mySerial.<span style="color: #cc6600;">read</span>());</pre>
<pre> }
}
</pre>
<br />
Using the serial console in the Arduino IDE I received a steady stream of lines:<br />
<blockquote class="tr_bq">
4E000194380003<br />4E000194380003<br />4E000194380003<br />4E000194380003</blockquote>
Somehow I had started suspecting the cards to be EM4100 compatible, and that is a 64 bit chip.<br />
But each line is only 14 digits - and I expected 16 hexadecimal digits (for 64 bits).<br />
The RFID receiver circuit has a pin labelled "Manchester code output", so I decided to try and decode that signal myself. Not yet comfortable with the Arduino platform I used the tool I knew best: PHP.<br />
My PC could not directly interface with the manchester output pin, so I used the oscilloscope's ability to dump the captured trace to a CSV-file, and then parsed the CSV using PHP.<br />
While working on my parser I found out about two things:<br />
<br />
<ol>
<li>The 64 bits on the EM4100 chip includes 11 header bits, a stop bit and 14 parity bits. This leaves 8 bits for a facility code and 32 bits for the UID.</li>
<li>Another eBay dealer sells the same kit - and he includes a description of the serial output: 2 hex digits facility code, 10 decimal digits UID and 2 digits parity data. </li>
</ol>
<br />
Not every trace was parsable, but I ended up with parsable CSV-files for each of the cards supplied with the kit. The Awid chip used for access control at my old work place however could not be parsed - it seems not to be EM4100 compatible.<br />
Using "<span style="font-family: Courier New, Courier, monospace;">php dump.php DATA-Thick-card-500us.csv 3 70 12 18</span>" I can get this output:<br />
<blockquote class="tr_bq">
4E 0001943800</blockquote>
- which almost looks like the serial output from the receiver circuit. However I have given up on the 2 parity digits - I cannot fit 14 bits in 2 hex digits ;-) But who cares - the parity data is redundant.<br />
<div>
<br /></div>
<div>
The dump.php program tries both manchester and biphase decoding.</div>
<div>
The program and two CSV-files are available on <a href="https://github.com/Sthing/AccessThing/tree/master/misc/scope_manchester_decoding">https://github.com/Sthing/AccessThing/tree/master/misc/scope_manchester_decoding</a>.</div>
<div>
<br /></div>
<div>
Printed on the card is "0001943800 029,43256". Initially I did not get it - but it is simply the 32 bit UID as a 10 digit decimal number followed by the high and low 16 bits as decimal: 29 * 2^16 + 43256 = 0001943800.</div>
<div>
<br /></div>
<div>
The next step was to implement almost the same functionality on the Arduino. I was inspired by the <a href="https://www.inkling.com/read/arduino-cookbook-michael-margolis-2nd/chapter-18/recipe-18-8">Arduino Cookbook</a> to use Input Capture on the 16 bit Timer/Counter1. The result was an Arduino library (EM4100) that can capture EM4100 data from a manchester signal. It is available on <a href="https://github.com/Sthing/AccessThing/tree/master/Arduino/libraries/EM4100">https://github.com/Sthing/AccessThing/tree/master/Arduino/libraries/EM4100</a>.</div>
<br />
About the "any tag" idea: Well - I have become (a little) wiser. There are a lot of RFID standards and de facto standards - and a lot of custom implementations. I will have to settle for less - and EM4100 and MIFARE seems like good candidates.<br />
<br />
Now it is getting really late and in the morning my brother and I are going canoing. I should get some sleep ;-)Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-4277106703116700008.post-55338060790609162772013-07-11T19:12:00.001+02:002013-07-11T19:14:22.487+02:00Welcome to my journey!Today I have created the blog and written about the <a href="http://access.thing.dk/p/background.html">background</a> for the project.<br />
<div>
<br /></div>
<div>
Even though it is not my native language I have decided to write in English. I hope someone outside Denmark can benefit from my work that way.<br />
<div>
<br /></div>
<div>
And thus it begins...</div>
</div>
Unknownnoreply@blogger.com0