Code Monkey home page Code Monkey logo

Comments (7)

FlyByPC avatar FlyByPC commented on July 17, 2024 1

SCL is defined as pin 23 (not 22) in the board definitions, despite what the pinout diagram says.
Unfortunately, Pin 23 isn't brought out to the pins.

Change the SCL pin definition in C:\Users<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\variants\ttgo-t1\pins_arduino.h and it will work.

from ttgo-t-display.

lewisxhe avatar lewisxhe commented on July 17, 2024

Which pin do you use?
You can explicitly initialize the designated I2C pin,

Wire.begin(sda,scl)

Is your external pull-up resistor 110 ohms? You can use 4.7k or 10k for external pull-up.

from ttgo-t-display.

tadam777 avatar tadam777 commented on July 17, 2024

This board already includes 10k resistors on SDA and SCL :

image

For some reason I'm not able to use the default I2C pin 22, but for example with pins SDA = 21 and SCL = 15 it works flawlessly (I'm using I2C with a TMP102 temperature sensor).

Notice that pins 35 to 39 are input only so they can't be used for I2C.

#define I2C_SDA 21
#define I2C_SCL 15

void setup()
{
Wire.begin (I2C_SDA, I2C_SCL);
pinMode (I2C_SDA, INPUT_PULLUP);
pinMode (I2C_SCL, INPUT_PULLUP);
}

from ttgo-t-display.

lewisxhe avatar lewisxhe commented on July 17, 2024

Except for the specified SDA SCL, everything else is the same. I can work normally. Please rule out the problem with the module, or you can try with an I2C device.

#include <Wire.h>
#include <Arduino.h>

const uint8_t sda = 21;
const uint8_t scl = 22;

void setup()
{
    Serial.begin(9600);
    Wire.begin(sda, scl);
    while (!Serial); // Leonardo: wait for serial monitor
    Serial.println("\nI2C Scanner");
}

void loop()
{
    int nDevices = 0;
    Serial.println("Scanning...");
    for (byte address = 1; address < 127; ++address) {
        Wire.beginTransmission(address);
        byte error = Wire.endTransmission();

        if (error == 0) {
            Serial.print("I2C device found at address 0x");
            if (address < 16) {
                Serial.print("0");
            }
            Serial.print(address, HEX);
            Serial.println("  !");

            ++nDevices;
        } else if (error == 4) {
            Serial.print("Unknown error at address 0x");
            if (address < 16) {
                Serial.print("0");
            }
            Serial.println(address, HEX);
        }
    }
    if (nDevices == 0) {
        Serial.println("No I2C devices found\n");
    } else {
        Serial.println("done\n");
    }
    delay(5000); // Wait 5 seconds for next scan
}

from ttgo-t-display.

m-stefanski avatar m-stefanski commented on July 17, 2024

#define I2C_SDA 21
#define I2C_SCL 15

void setup()
{
Wire.begin (I2C_SDA, I2C_SCL);
pinMode (I2C_SDA, INPUT_PULLUP);
pinMode (I2C_SCL, INPUT_PULLUP);
}

when I am trying to do it this way, LCD screen shows garbage and I2C connection still doesn't work.

IMG_1069

Tested on PN532 with Adafruit library:


#define I2C_SDA 21
#define I2C_SCL 15

void initialize_PN532(){
    Serial.println("Initializing PN532");
    Wire.begin (PN532_SDA, PN532_SCL);
    pinMode (PN532_SDA, INPUT_PULLUP);
    pinMode (PN532_SCL, INPUT_PULLUP);
    nfc.begin();
    uint32_t versiondata = nfc.getFirmwareVersion();
    if (! versiondata) {
        Serial.print("Didn't find PN53x board");
        while (1); // halt
  }
}

This happens also when I used pins 26 / 27.

from ttgo-t-display.

tadam777 avatar tadam777 commented on July 17, 2024

In your code you define the I2C_SDA and I2C_SCL, but then you write Wire.begin (PN532_SDA, PN532_SCL) so you're probably not using the pins 21 and 15 that you defined first.
Could it be that because of this you're sending SDA/SCL data to another pin which is connected to the TFT and this give the random pixels on the screen ?

Have a look at the example (from above) :

#define I2C_SDA 21
#define I2C_SCL 15

void setup()
{
Wire.begin (I2C_SDA, I2C_SCL);
pinMode (I2C_SDA, INPUT_PULLUP);
pinMode (I2C_SCL, INPUT_PULLUP);
}

This works for me, even without the two INPUT_PULLUP lines.

I can also recommend this small sketch, which will detect any I2C device and give its address. It can be useful if you board can be configured for several addresses : https://playground.arduino.cc/Main/I2cScanner/

from ttgo-t-display.

summerfind avatar summerfind commented on July 17, 2024

In your code you define the I2C_SDA and I2C_SCL, but then you write Wire.begin (PN532_SDA, PN532_SCL) so you're probably not using the pins 21 and 15 that you defined first. Could it be that because of this you're sending SDA/SCL data to another pin which is connected to the TFT and this give the random pixels on the screen ?

Have a look at the example (from above) :

#define I2C_SDA 21 #define I2C_SCL 15

void setup() { Wire.begin (I2C_SDA, I2C_SCL); pinMode (I2C_SDA, INPUT_PULLUP); pinMode (I2C_SCL, INPUT_PULLUP); }

This works for me, even without the two INPUT_PULLUP lines.

I can also recommend this small sketch, which will detect any I2C device and give its address. It can be useful if you board can be configured for several addresses : https://playground.arduino.cc/Main/I2cScanner/

Hi all, is this too later?
can the config here be able to set other pin than 21/22, let's say 13/14?
Thanks

from ttgo-t-display.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.