Skip to content
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

Conflict when using with pn532. #859

Open
maltortan opened this issue Dec 26, 2023 · 2 comments
Open

Conflict when using with pn532. #859

maltortan opened this issue Dec 26, 2023 · 2 comments

Comments

@maltortan
Copy link

While trying pn532 with hsu the websocket won't get connected with response "disconnected" but when using pn532 with spi the websocket won't respond.
When using the same code with code pn532 remove it works. Is there a conflict in serial input?
Is there any way it can be fixed.
Tried multiple types of packages for pn532 same result. Tried on esp8266 and esp32 same result.

#include <WiFiManager.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#include <WebSocketsClient.h>
#include <SPIFFS.h>
#include <mDash.h>

#define PN532_SCK (18)
#define PN532_MOSI (19)
#define PN532_SS (5)
#define PN532_MISO (23)

packages and pins I am using.

@Links2004
Copy link
Owner

the WebSocketsClient only needs network no serial, SPI or any IO ports.

most likely the loop is blocked to long by the PN532 lib, and as a result the network connection timesout.

I recomand to check how often your loop is run.

@amichael04
Copy link

This issue puzzled me for a while. In the end it seems that calling if (NfcAdapter.tagPresent()) was blocking the thread too long.

To solve this issue, you need to utilise both ESP32 cores. This link was very useful for what I needed. I simply called websocket.loop() in one task and my readNFC() function in another.

NOTE: You MUST set the websocket task to have the priority tskIDLE_PRIORITY. Otherwise, your ESP will hit a boot loop due to it blocking freeRTOS tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants