How to get tag ID using MFRC522 and ESP8266 NodeMCU 0.1 - rfid

I am using an ESP8266 NodeMCU v0.1 and MFRC RC522. Please can anyone tell me how I can send the tag ID to my web server and how to connect NodeMCU to RC522?

I have managed to use this example with few modifications.
https://github.com/Jorgen-VikingGod/ESP8266-MFRC522
Wiring as follows:
SDA(SS) - D4 (GPIO2)
SCK - D5 (GPIO14) (hw spi)
MOSI - D7 (GPIO13) (hw spi)
MISO - D6 (GPIO12) (hw spi)
IRQ -
GND - G
RST - D3 (GPIO0) (FLASH)
3.3V - 3V
And in the code I have redefined these variables:
#define RST_PIN D3
#define SS_PIN D4
Worked for me.

Related

HDLC frame HCS and FCS

I have an HDLC frame like blow and I want to calculate the HCS and FCS algorithm.
Its based on DLMS protocol noted in green book page 128.
Here is an example of this frame:
Ex.1:
Frame=`(7EA016030002002352A25EE6E700C401C10012000211927E)Hex`
HCS = `( 52A2 )Hex`
Data= `( 5EE6E700C401C100120002 )Hex`
FCS = `( 1192 )Hex`
FCS can be computed using the method in 8.5.3 and the lookup can be generated using the method in 8.5.4 of the Green Book 8.3.
HCS is calculated in the same way.

How can I retrieve wLength of a hid device in linux?

I want to retrieve wLength (that can be specified by a hid device). The clear answer maybe is to send a ctrl signal to device. But I tried it by the following code:
struct usbfs_ctrltransfer ctrl = {
.bmRequestType = LIBUSB_ENDPOINT_IN,
.bRequest = LIBUSB_REQUEST_GET_CONFIGURATION,
.wValue = 0,
.wIndex = 0,
.wLength = 1,
...
}
....
r = ioctl(fd, 0, &ctrl);
....
The result of this code was just an error value (I think that was -1!).
I reloaded the hid module (kernel module) in debug mode(modprobe hid debug=100 --> don't panic for this large debug level!). In this case the hid print out the true value of the wLength.
/build/buildd/linux-3.13.0/drivers/hid/usbhid/hid-core.c: submitting ctrl urb: Get_Report wValue=0x0100 wIndex=0x0001 wLength=64
I track it in Linux kernel source code and I found that this information are printed in usb_get_intfdata.
In summary I wonder to know if there is an equal function in userland or not?
The answer to this question is using udev. ‌By reading special attribute, called bmAttributes, you can find the I/O's actual length.
Using below code to read it:
....
udev_device_get_sysattr_value(dev, "bmAttributes")
....

HID reports/scan codes for RN 42 HID's gamepad profile

i'm creating a bluetooth HID gamepad with a arduino leonardo and the RN 42 HID module.
I can actually use the module to iterate a keyboard or a mouse but i didn't understand how to
send the right scan codes to iterate a gamepad or a joystick.
In the user's guide of the module they said that the raw report had to be sent like that:
0xFD,0x06,Buttons 0-7,Buttons 8-15,X1,Y1,X2,Y2
Any idea on how to set the report?
First, you have to init a SoftwareSerial instance.
Then you have to enter Command Mode of the RN-42 module with a sequence of $$$, set up the HID joystick mode (SH, 0240) and name the device (SN, ...), set the baud rate (SU, ...), etc.
After the successful initialization of the module, you can send HID joystick reports as follows:
SoftwareSerial bluetooth(bluetoothRX, bluetoothTX);
//...
// Command Mode
// --------------
bluetooth.begin(9600);
delay(50);
bluetooth.print("$$$");
delay(50);
bluetooth.print("SN,HIDJoystick\r\n");
delay(50);
bluetooth.print(" SU,57\r\n");
delay(50);
bluetooth.print("S~,6\r\n");
delay(600);
bluetooth.print("SH,0240\r\n");
delay(200);
bluetooth.print("R,1\r\n");
delay(400);
// HID Joystick Report
// --------------
bluetooth.write((byte)0xFD); //Start HID Report
bluetooth.write((byte)0x6); //Length byte
// 1. X/Y-Axis
bluetooth.write(45); //First X coordinate
bluetooth.write(-33); //First Y coordinate
// 2. X/Y-Axis
bluetooth.write(45); //Second X coordinate
bluetooth.write(-33); //Second Y coordinate
// Buttons
bluetooth.write(B10000001); // Second Byte (Buttons 1-8)
bluetooth.write(B10000000); // Second Byte (Buttons 9-16)
Please note that the buttons are controlled via binary values.

TI Basic: How to end Lbl blocks

I'm making a simple text-based battle between the player and a dragon. I use Menus to have the player select from a set of options. The Menu then obviously goes to the Lbl assigned to the selected option. Within the while loop for the game I can end the Lbls by using the End command to go back to the start of the loop, but when the player chooses the difficulty, there is no loop. How do I prevent all the subsequent Lbls from being executed in this code:
:Menu("DIFFICULTY?", "EASY", 00, "MEDIUM", 01, "HARD", 02)
:Lbl 00
:75->D
://some end statement
:Lbl 01
:150->D
://some end statement
:Lbl 02
:300->D
://some end statement
Because currently, all Labels are executed resulting in the dragon having 300 health no matter the option chosen. (I don't want a work around with scalars or some other trick, I want to know how I can emulate what I described in a general situation so I can use the technique in future programs).
You can add another label at the end and go to it after setting the dragon's health.
Like this:
:Menu("DIFFICULTY?", "EASY", 00, "MEDIUM", 01, "HARD", 02)
:Lbl 00
:75->D
:GoTo 03
:Lbl 01
:150->D
:GoTo 03
:Lbl 02
:300->D
://you don't need a GoTo here since there are no more labels and Lbl 03 is the next line.
:Lbl 03
://The rest of your code...
This will exit out of the switch-style setup you are using and continue with the code.
Personally, I would use an if then, elseIf then, else, endIf block to achieve this goal.

Sending the right HID Keycode?

I'm currently developing a very smal and specific HID Keyboard with a atmega microcontroller. The biggest problem i have is that a keycode is very specific for the locale that is currently set on the host pc.
All normal chars like a-z are working very well but some special chars are producing bad results when the key is pressed.
For example the + Key, which is 0xE1 & 0x2E (LeftShift & KeyboardEqualSign) does only work on a US Keyboard. But i use a German Layout, so i get a ß instead.
How can i now get the right keycodes for the German Layout? I cant find any document that describes such keys... I think the HID Keycodes are really bad designed to support multiple keyboard layouts :(
Do i need to lookup my keys on a german layout what they would be in us? So for the + Sign its probably the ] key? But why the heck its a so stupid design? Is there any wrapper for that?
had the same problem. I took a picture of an en_us keyboard and compared it to my german keyboard and then I transfered that on the keycodes... Its not yet finished because its a suprisingly lot of work and I do not need other characters right now. Most important characters should be there. Its sorted after Iso8859, I let the iso codes stay maybe that helps someone.
Here you go:
iso8859 hex code, modifier, usb hid keycode, character
0x22, shift,0x1F , "
0x23, 0,0x31 , #
0x24, shift,0x21 , $
0x25, shift,0x22 , %
0x26, shift,0x23 , &
0x27, shift,0x31 , '
0x28, shift,0x25 , (
0x29, shift,0x26 ,
0x2A, shift,0x30 , *
0x2B, 0,0x30 , +
0x2C, 0,0x36 , ,
0x2D, 0,0x38 , -
0x2E, 0,0x37 , .
0x2F, shift,0x24 , /
0x30 to 0x39 are the numbers, no changes here to en_us
0x3A, shift,0x37 , :
0x3B, shift,0x36 , ;
0x3C, 0,0x64 , <
0x3D, shift,0x27 , =
0x3E, shift,0x64 , >
0x3F, shift,0x2D , ?
0x40, altgr,0x14 , #
*Upper case letter, no changes here to en_us
0x59, shift,0x1D ,switch Z,Y
0x5A, shift,0x1C;
0x5B, altgr,0x25 , [
0x5C, altgr,0x2D , "\"
0x5D, altgr,0x26 , ]
0x5E, 0,0x35 , ^
0x5F, shift,0x38 , _
0x60, shift,0x2E , `
*lower case letters, no changes here to en_us
0x79, 0,0x1D ,switch z,y
0x7A, 0,0x1C
0x7B, altgr,0x24 , {
0x7C, altgr,0x64 , |
0x7D, altgr,0x27 , }
0x7E, altgr,0x30 , ~
*0x80 to 0x9F not in use
0xA0 Not existing "nonbreaking space"
havent done yet
0xC4, shift,0x34 ,Ä
havent done yet
0xD6, shift,0x33 ,Ö
havent done yet
0xDC, shift,0x2F ,Ü
havent done yet
0xE4, 0,0x34 , ä
havent done yet
0xF5, 0,0x33 ,ö
havent done yet
0xFC, 0,0x2F ,ü
havent done yet
Hope that helps you or the next stumbling upon that problem :)
Best regards

Resources