Xinyuan-LilyGO/TTGO-T-Display

I2C Connection Issue with PN532

JpEncausse opened this issue · 1 comments

Hi, I have an Issue reading PN532 from I2C.

Looking for PN532...
Found chip PN532
Firmware ver. 1.6
[  2550][E][Wire.cpp:513] requestFrom(): i2cRead returned Error 263

I don't think it is the wireing or the NFC board because it see it. I do think it might be something related with TTGO-T-Display that might use the Wire also ?

image

#include <Arduino.h>

// ------------------------------------------
//  TFT_eSPI
// ------------------------------------------

#include <TFT_eSPI.h>
#define ADC_EN    14  //ADC_EN is the ADC detection enable port
TFT_eSPI tft = TFT_eSPI(135, 240);

void setupTFT() {
  Serial.print("Setup TFT");
  
  pinMode(ADC_EN, OUTPUT);
  digitalWrite(ADC_EN, HIGH);
  
  tft.init();
  tft.setRotation(1);
  tft.setCursor(0, 0);
  tft.fillScreen(TFT_BLACK);
  tft.setTextDatum(MC_DATUM);

  tft.setTextSize(2);
  tft.drawString("TFT is Ready", tft.width() / 2, tft.height() / 2);
}

// ------------------------------------------
//  NFC
//  https://github.com/elechouse/PN532
// ------------------------------------------

#define I2C_SDA   21
#define I2C_SCL   22

#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h> 
#include <NfcAdapter.h>

PN532_I2C pn532i2c(Wire);
//PN532 nfc(pn532i2c);
NfcAdapter nfc = NfcAdapter(pn532i2c);

bool setupNFC(){
    Wire.begin(I2C_SDA, I2C_SCL);
    Serial.println("Looking for PN532...");
    nfc.begin();

    return true;
}  

void loopNFC(){
    delay(100);
    if (nfc.tagPresent()) {
        NfcTag tag = nfc.read();
        tag.print();
    }
}

// ------------------------------------------
//  LOOP
// ------------------------------------------

void setup() {
  Serial.begin(115200);
  delay(1000);

  // Setup the TFT display
  setupTFT();

  // Setup the NFC
  setupNFC();
}

void loop() {
  //loopNFC();
  delay(500);
}

I'm using PlatformIO with ElectroHouse library loaded aside.

[env]
platform = espressif32
framework = arduino
monitor_speed = 115200

[env:ttgo-lora32-v1]
extends = env
board = ttgo-lora32-v1
lib_deps = 
	bodmer/TFT_eSPI@^2.5.23

Playing around with many variables it seems to works (mostly)
I assume the board is somehow buggy.