some problems about rfid_Cloner_2 (buttons)
cx4 opened this issue · 17 comments
I don't know what reason I confirm and delete buttons are not sensitive,Use the resistor has direction requirement?
Hello, in the GUI.cpp there's the following line:
gui_mode = MODE_INTRO;
You could change it into the following:
gui_mode = MODE_BUTTON_CALIBRATION_VIEW;
After uploading the code and turning on the device it should look like this:
Make sure to test it with battery instead of USB cable (it affects the analog input reading).
Only 1 (analog) pin is used to receive input of all the buttons (using voltage dividers). It would be all fine but the battery voltage is decreasing over time and the readings when specific buttons are pressed also decrease. To tackle that problem I added 10K resistor that is constantly dividing voltage (producing constant readings - "51" visible on the image above), it allows to constantly monitor the voltage and automatically calibrate the buttons in real time.
I would do the following in this case:
- make sure the resistors have the correct values (220 - "decline", 470 - "accept")
- observe what is the expected and actual analog reading for both of these buttons. If the reading is off and that is the reason for the buttons to not work then there are 2 possibilities:
- Set
#define INPUT_TOLERANCE 0.12
(in Buttons.cpp) to a slightly higher value.
(INPUT_TOLERANCE is how far from the expected the reading can be and still get classified as some button, e.g. If reading is: 113 and expected reading is 100, then with INPUT_TOLERANCE equal to 0.12 the button press would not be noticed. If INPUT_TOLERANCE was increased to 0.14 then the button press would be registered. The tolerance cannot be set too high, otherwise buttons will interfere with each other, however 0.12 is very safe value I think and it could be increased.) - Change buttonMap initial expected_read value (also in Buttons.cpp) to match readings of your buttons.
ButtonMap buttonMap[BUTTON_COUNT] = {
50.5, BUTTON_NONE, "NONE", [](){},
100.0, BUTTON_UP, "UP", [](){},
191.0, BUTTON_DOWN, "DOWN", [](){},
315.0, BUTTON_LEFT, "LEFT", [](){},
449.0, BUTTON_RIGHT, "RIGHT", [](){},
629.0, BUTTON_YES, "ACCEPT", [](){},
871.0, BUTTON_NO, "DECLINE", [](){},
};
It would be kind of waste to not use display after all this soldering:p, are you sure that the display is not going to work? Did it get like physically broken? (I remember that when I was playing with display like this I was almost sure it won't work anymore but it turned out the connections were wrong).
You could use the first version with NodeMcu and it should work, what you'd have to do is:
- connect the rfid module the way it is shown in the 2nd version of the cloner
- change this part of the 1st version code:
#define RST_PIN 8
#define SS_PIN 10
replace it with:
#define RST_PIN D3
#define SS_PIN D8
- use D4 and SD3 pins to connect LEDs, and use D0 pin to connect the button + change the code accordingly, so it looks like:
#define BTN_PIN D0
#define LED_YELLOW_PIN D4
#define LED_GREEN_PIN SD3
Zener diodes used in the first version won't be required because NodeMcu has 3.3V pin.
I change the code with Cloner_1 . But uploading firmware , there is an error, SD3 was not declared in this scope . and how to use D4 and SD3 to connect LEDs .
Thank you very much for your help.
My bad, SD3 is not defined, you could use pin 10, which is SD3:
#define LED_GREEN_PIN 10 //SD3
Just in case if it is confusing why pin 10 is "SD3" here's a diagram: link
I just pressed some keyboard shortcut (or touched the touchpad...) and closed the issue by accident
Thank you. Another problem is how to connection the leds and button with esp8266
You could take a look at the first version wiring and connect it the same way but to different pins
https://github.com/michalmonday/RFID-cloner/tree/master/rfidCloner#wiring
So instead of using pins 9, 5, 4 and RAW, use:
- D0 (button)
- SD3 (green)
- D4 (yellow)
- 3.3V (red)
I just found out that I didn't include pinMode(pin, OUTPUT);
for both of the led pins, maybe that is the reason why it doesn't work right now with NodeMcu, but that's just a guess, anyway...
What I would do is to verify that everything is connected properly:
- I would upload the code below:
#define BTN_PIN D0
#define LED_YELLOW_PIN D4
#define LED_GREEN_PIN 10
void setup() {
pinMode(BTN_PIN, INPUT_PULLUP);
pinMode(LED_YELLOW_PIN, OUTPUT);
pinMode(LED_GREEN_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
delay(500);
digitalWrite(LED_YELLOW_PIN, HIGH);
digitalWrite(LED_GREEN_PIN, HIGH);
delay(500);
digitalWrite(LED_YELLOW_PIN, LOW);
digitalWrite(LED_GREEN_PIN, LOW);
bool button_state = digitalRead(BTN_PIN);
Serial.println("Button state is:" + String(button_state));
}
It should toggle both LEDs every half second and print the state of the button every 1 second (that can be read in Arduino IDE -> Tools -> Serial Monitor)
- If the LEDs are working properly and the button is responsive I would upload example provided by rfid library to make sure that the RC522 module is connected and working properly (Arduino IDE -> File -> Examples -> MFRC522 -> DumpInfo).
You'll have to change the 2 lines below in that example:
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
into:
constexpr uint8_t RST_PIN = D3;
constexpr uint8_t SS_PIN = D8;
After uploading that example you'll have to open serial monitor and present a card to the rfid reader module, information about the card should be displayed in the serial monitor.
Thank you very much. You're responding so quickly. But don't you sleep? it's supposed to be 1: 00 in the morning in Britain. take care
I just noticed that I made another mistake at the:
https://github.com/michalmonday/RFID-cloner/tree/master/rfidCloner%202#wiring
SCK should be D5 and SS should be D8, MISO should be D6 and MOSI should be D7, sorry about it...
Btw usually go to sleep around 2-3am, just a sleeping pattern like that
It doesn't work. I decided to buy a arduino nano board to try.
If you'd like to try to make it work with esp then just let me know on discord (michalmonday#3687), I'm sure something can be done...
Because I can't write C ++, I want to try it with micropython.
Sorry for my english not good. I'm using google translate to comment here. Why do you have to use resistors for buttons? Why don't we fight the esp pins directly?
Hi, thanks to resistors (that act as voltage dividers) all the buttons can be read by using a single pin (as seen on image below). This project used a display and a RFID module, both using a lot of pins. But I think that using an input shift register would probably be a better solution, mostly because the voltage differs depending on the battery level, I tried to take that into account in the code (by scaling expected voltage ranges for each button based on baseline voltage level) but I'm not sure if it's a robust method, it seemed to work in my case though.