Improved keyboard wedge

Shamelessly plugs my pn532 fork :sweat_smile: I know this one works on arduino chips (atmega).

4 Likes

thanks for the PN532 library, im having a hard time making my pn532 work at all, ill give it a go (on a nano) ā€¦

Ive been playing with RDM6300 (LF only) and it read my NExT consistently, but the antenna needs to touch the skin for it to read ā€¦
Also been playing with digistump, but somehow i cannot get the RDM6300 to work on it ā€¦

1 Like

Ok, I adjusted line 125 in Adafruit_PN532.cpp. to:
spi_dev = new Adafruit_SPIDevice(ss, clk, miso, mosi, 50000,.
Now I get a consistent connection.
Thanks so much for all the recommendations :slight_smile:

1 Like

Ok, managed to get my PN532 (V3) to work , but only on SPI com ā€¦ but it works!

Probably a (very) dumb question (im really not good at programing ā€¦):
Anyway to go into the library and pull all the commends?

PS: sorry @Devilclarke , i wasnā€™t able to get your library running (defiantly user [me] error). I like a lot of things from it. Do you have pinout for each com?
Also, are you able to manually set the pins? Iā€™m trying to run on Nano (and maybe on attiny85).

1 Like

Hi @Devilclarke ,
I also am trying to use your Library. However it seems to me, that you just copied the installation instructions from the repositories you forked from, without any changes.
There are two readme.md files.
One links to https://github.com/elechouse/PN532/archive/PN532_HSU.zip and the other one links to https://codeload.github.com/Seeed-Studio/PN532/zip/master.
Neither one of those is actually your fork.

When cloning the repo into my libraries folder I get the following compilation error in my Arduino IDE.

In file included from /home/user/Arduino/libraries/PN532/PN532_SWHSU.cpp:2:
/home/user/Arduino/libraries/PN532/PN532_SWHSU.h:5:10: fatal error: SoftwareSerial.h: No such file or directory
    5 | #include <SoftwareSerial.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Adafruit Trinket M0.

Maybe cloning the repo is not actually how to install this, or maybe I am missing a dependency?

Anyhow, I can see how @XEMON canā€™t figure out how to use this, lol.

I am not sure what you mean by this?

Im trying to pull the UID of the card and compare it to known UID for identification.
I am able to pull each of the bit of the uid, but not the UID as a single item ā€¦
also get some issue with formating (HEX vs DEC, ā€¦)

I have a hard time doing data conversion in C

edit: I am flying blind here ā€¦ the bit i know about programing I learned it on my own, and all the PLC i do iat work i learned on my own too ā€¦ so things that may be obvious to programmer/coder are not necessarily to me ā€¦ sorry if my ā€œissuesā€ are too simple or obvious to address.

Imo the best way to figure out how to do this type of thing is to read the example code, that the library you are using provides.
These libraries usually come with a ISO14443a_uid example.
Playing around with that code works well for my learning style.
Learn X in Y minutes is cool website if you want a very condensed learning resource: Learn c++ in Y Minutes.
You can also DM me your code. I might not have time to look at your code, but I would gladly give you some pointers.

Ahh I see why if I remember rightly the softwareserial library is incompatible with the trinkets so it wonā€™t work.

1 Like

The trinkets use a USB serial as their default serial device so software serial should work but you might have to modify various bits and pieces first

1 Like

Thanks, i tried it, but all the functions are print to serial only.
Managed to extrat teh UID bit by bit, then convert convert them to string, then make a complete UID string ā€¦
But for some reasons, it extracted in decimal, not hex. ā€¦ well, same same ā€¦ I can make it work ā€¦

Also shouldnā€™t need software serial if you are using pn532 in i2c or spi mode are you trying to use hsu?

I am using SPI, but of course the IDE will still try to compile the whole library anyway and fails with the same error.

I have however stumbled upon another issue regarding this project: Keyboard layouts!

I have been pondering how to generate passwords and it seems to be a fairly hard problem.
I set up a Linux mint VM using the Password zaƤaƤAB98HbvCĀ§(.
At least, that is how my Machine (german layout) interprets it.
LUKS seems to handle the keypresses differently. After a reboot I can no longer unlock the encrypted test VM.

I am curious how the following sample code works on your machines. Also does anyone have an idea, if there is maybe a safe set of characters, that can be used for this?

Click to expand!
#include <Keyboard.h>

void setup(void) {
  delay(2000);
  uint8_t whatever[16] = { 'Ƥ', 'Ƅ', 97, 0x27, 0x61, 'Ć¼', 'A', 'B', '9', '8', 'H', 'b', 'v', 'C', '#', '*' };
  Keyboard.begin();
  for (uint8_t i = 0; i < 16; i++) {
    Keyboard.write(whatever[i]);
  }
  Keyboard.end();
    
}
void loop(void) {
  delay(2000);
}

Easy fixā€¦ Find the Keyboard.begin() and replace it with
Keyboard.begin(layout)

You can find the appropriate layout in the Arduino reference page

1 Like

Devilclarkeā€™s repo works great.
The PN532 is far superior to the MFRC522. Iā€™ve created the code for ESP32 and PN532 using Devilclarkeā€™s lib. This one uses I2C instead of SPI, saving some cables. Iā€™ve not bothered with the array password, since I am not going to use it, but it should be easy to add it. It works a lot better than my MFRC522-code.
My wedge is now working exactly as I want, now I only need to make an eclosure.
If anyone else is using ESP32, feel free to steal and modify:

5 Likes

Thank you for this.

Awesome, thanks.
Ill give it a go, if i can make it work ill make a 3D printed case and publish it somewhere.

Edit: ESP32 is on its way ā€¦

1 Like

Merry Christmas everyone!
I have developed my own little keyboard wedge. It is still somewhat rough around the edges, but I consider it ready for publishing.
Take a look:

5 Likes

Well itā€™s been a whileā€¦

Iā€™m afraid I was having to deal with the black dog, and while the new meds seem to be helping with that they also left me feeling like I couldnā€™t be bothered doing anything for a while.

So, I have just ignored most of my last rewrite which was non functional, and ported release one over to platformio as a development platform.

My current plan is to add the following featuresā€¦

  1. (Completed) XOR the password with the UID and store the encrypted password in the array. If the UID can decrypt that entry we can use that (advantage, no clear text passwords or UIDs are stored on the controller. The encryption is not strong though, this will not slow down a determined attacker). This could be modified to search the chip for the encrypted password but I am not sure why you would want to do this, garbage on your chip would look suspicious.

  2. (Completed) Configurable headers and footers for the password stored on the chip itself. If you want to use PASS^ and ^ respectively you can. The Password cannot contain the footer though. PASS^^^ would be a null password not a single ^.

  3. (Completed) Add support for the reader to ā€œpressā€ the F15 key every 5 minutes. This is because my laptop goes to sleep in long meetings and cuts me off. I want to add this as I already have this microcontroller connected, so making it do double duty.

  4. Add support for a PN532 reader.

  5. (Completed) Configurable keyboard layout. The Keyboard library supports multiple languages, so we should be able to change that and send it other characters.

The new code including a UF2 file for a trinket is at (https://GitHub.com/zwack-am/ZKBW2/) I will make this a bit more obvious when I have completed item 1. Item 4 will be the next release, and then porting to the pico.

6 Likes

This sounds awesome!

there are great library for the PN532 out there (and they work).
Ive been looking at teh PN5180, it is suposed to get even better reads, but i cannot make it work ā€¦ at all ā€¦ (might make a dedicated thread for it)

1 Like

I am very familiar with that feeling. I feel like I have lost years to that limbo state.
Its really good to hear you are fighting the black dog.

Also, I had not heard of platformio, until now. It looks pretty cool.