New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MFRC522 Error 12 on ESP8266 #258
Comments
We are getting exact same error |
It's not that you've wired it up to 5v rather than 3.3? |
We tried so many things, including switching to hardware SPI pins of ESP12, which solved that exception mentioned. Now, the only problem is that we can not get any NFC cards read by module via ESP12. We are only switching the reader's SPI pins between STM32F407-Discovery Board and ESP12 module. Same code (except for pin setup) works just great on STM32-Discovery, but fails to read NFC cards without throwing any exception. |
Sounds like this is an SPI issue on ESP8266 rather than anything specific to this driver? IMO you probably need to get a digital storage scope on it and look at the differences in signals that are sent - it may end up being pretty obvious. |
We would try to compare whole communication sequence of STM32 and ESP12. We connected the logic analyzer to ESP12's SPI pins and we managed to capture all communication signals. Then we connected the logic analyzer to STM32-Discovery. The original exception is thrown when we connect MOSI pin to analyzer (other pins do not cause any exceptions). So we failed to compare. FYI: I will try to convert current driver to use I2C. |
have you tried a different MOSI pin? It sounds like the one you're using can't supply enough power for some reason. Could also be something to do with the ESP8266 not setting up the pin mode correctly to output? |
nope, we haven't. you mean we should try to use different SPI pin group on Discovery? |
Oh, I see what you mean - I thought you were talking about problems with ESP8266. You could try different pins, but working out what's wrong with this is up to you I'm afraid since I can only afford to support the boards that I sell. |
@tve I know we'd seen some glitches on the I2C implementation. Looking at |
Mhh, that's certainly possible and worth an experiment. The double writes come from Espressif's i2c code, if I remember correctly. |
Interestingly the Arduino code looks slightly different: Ours: https://github.com/espruino/Espruino/blob/master/targets/esp8266/jshardware.c#L439 I wonder whether just writing '0' to the set/clear registers has some undesired effect. ... I am torn though. Doing |
We managed to get samples via connecting the CodeESP (fail)Logic analyzer dump - ESP (fail) STM32 (success) |
I'll also add, using the same hardware / pinout with Arudino sketches / libraries works without any issue. |
@gfwilliams I didn't mange to find the line in the source code which the software SPI clock frequency is set. I wonder if I would get a workaround for this job if I could set the software SPI clock frequency to 400 kHz. A hardcoded solution would satisfy for now. |
You can't change the software SPI frequency... Are you 100% sure you're capturing the same communications in each case? On STM32 it looks like it's sending 2 bytes each time rather than 1. |
We are working with @ceremcem and we are still chasing this problem. Current situation is that In our ESP-12 - MFRC522 pin configuration is :
My test code is as follows:
I want to use software SPI port. I created new object from SPI class.
What am i doing wrong ? Wiring Question:As you know the |
I just did some tests. I'm not seeing any glitches, other than cross-talk between the lines. Both HW and SW SPI seem to work fine. I don't have an SPI device handy so I just looped MISO & MOSI back into one another. SW SPI runs at just under 1Mhz, HW you can control. Here's my little test program:
Output should be:
@gfwilliams I switched the i2c and digitalWrite implementations to use a single I/O write with an if statement like they do in arduino 'cause I tried it to see whether it makes a difference and I found that it's just so slightly faster. But no difference WRT glitches or so. tve/Espruino@6e09066 |
Not if you use an appropriate pull-down resistor. 10k works for me |
@tve thanks! Interesting that it's faster... Most likely it's wiring then. I'd say use software SPI - there are less possible things to go wrong. It getting 12 returned sounds like either an MOSI or CS not working properly. |
I'm pretty sure GPIO16 is known not to work? |
Yes, sorry, I forgot to mention; we have re-discovered that, cut the PCB route and soldered it to another GPIO (I can't recall right now). FYI: I suspect that the firmware may be somewhat wrong since it was one of those I had compiled by myself (as you may remember) |
gpio15 shouldn't be connected to gnd but to a pull-down resistor. If something decides to output a '1' you're goinna get quite some heat and current leading to issues. |
@tve Regarding to your suggestion, I connected GPIO15 to GND via 10K resistor and GPIO2 to VDD (3.3V) via 2.2K resistor, then tried your test code. When I tried software SPI, output was as expected, and as follows:
But when I tried hardware SPI, output wasn't the same as before:
After this successful test, I used software spi in my test code. It is WORKINGThis is my test code:
Output is :
But I have some problems.When I put the
After I got this error, i reverted the code to exclude |
You need to initialise the reader on
So basically the 'bug' here was that you'd shorted pin D15 to ground, and then also connected it to CS? I think we can probably close this issue. |
everything works as expected, with a little hack: we need to call Steps to regenerate the problem:
Why do we need two |
It's probably because by default chip select will be pulled low because you are using D15 which has a pull down. If you add digitalWrite(D15,1) alongside SPI.setup it'll probably fix it. |
It's exactly right. It is working... Thanks @gfwilliams and @tve |
Thanks @gfwilliams, thanks @tve! |
Hello friends I'm new to developing with esp8266, I'm trying to connect both an RFID reader rc522 and screen nextion 2.4 "in a NodeMCU 1.0, using arduino IDE v 1.6.11 to read an RFID tag and display the UID in Nextion 2.4 screen ". I managed to connect and work with each separately, but I can not make them work together. when the connections operate separately in NodeMCU v 1.0 are the following: Nextion 2.4 "||| MCU Node 1.0 5V-------------- 5V RC522 ||| MCU Node 1.0 3.3V------ 3.3V Both devices need to use the pin D7 (RXD2), I would like to use both at the same time, I read that I use UART but do not understand how to apply. any help is welcome |
Error
Code
Connection (NodeMCU)
Unsure what
Error 12
is and why it's appearing, any help appreciated.The text was updated successfully, but these errors were encountered: