ESP32 7 inch display - how to connect sensor using i2c pin and also use touch with it

I want to connect an additional sensor for use, but currently it conflicts with the touchscreen. Is there a way to fix this?

«1

Comments

  • The 5-inch and 7-inch boards have only one set of I2C, pins 19 and 20. So when using other I2C devices, you need to share the same I2C set with the touch function. In addition, because the touch function will initialize I2C at the beginning of the program, when you use other I2C devices, you do not need to use the begin function to initialize, otherwise the touch function will fail. When you want to communicate with other I2C devices, you need to follow these steps: use the begintransmission function to specify the communication address, and the write function and read function for reading and writing, and finally use endtransmission to end the communication. Avoid too long a communication time, otherwise it will affect the touch function.

  • I can not get I2C to work on the 5inch board (DIS07050H).
    Using the I2C scanner example code posted on another question here in the forum, works perfectly and finds my three I2C devices. However, adding the graphics library and related code causes I2C to not find any devices. I removed the Wire.begin() per your instructions above, and only use the BeginTransmission() and EndTransmission() but still does not work. Any suggestions on how to fix this?
    https://drive.google.com/file/d/1vqpHt207rqYvrqK1WKX0DHN8FP_sPJii/view?usp=sharing

  • When using the BeginTransmission function, please note to fill in the parameters. For example, if the address of the I2C device you are using is 0x11, you need to change it to BeginTransmission(0x11), but you don't need to fill it in when using the EndTransmission() function. In addition, during communication, ensure it does not take too long, otherwise it will affect the touch function. The duration of each device should be as short as possible and strictly controlled.
    Meanwhile, when using the write function in BeginTransmission to send data, you need to comply with the instructions required by the sensor you are using, otherwise you will not be able to write or read data from the sensor you are using
    For example, a sensor I use requires that it will enter the readable mode after writing 0x55, so I need to first:
    Wire.write(0x55);
    Then read the value of the sensor:
    buf = Wire.read();
    You need to check the sensor's data sheet for specific operations to confirm

  • Do you have any code suggestions for me? Because I still can't follow your advice

  • Please refer to the instructions after 5:02 in this video, which will explain how to use I2C without affecting touch functionality:

  • But in the video clip, he doesn't use the touch screen at all. I tried it and in the case of using the touch screen, i2c and the sensor can be used normally, but if they are used at the same time, the touch will freeze

  • They cannot be used at the same time, because there is only one IIC port, so asynchronous communication is required to enable touch and sensor. During communication, make sure it does not take up too long, otherwise it will affect the touch function. The duration of each device should be as short as possible and strictly controlled. In particular, do not put the operation of reading and writing sensors in the loop function, and do not use an infinite loop, which will always occupy IIC and make the touch of the screen unavailable.

    You can simulate the uart0 port as an IIC port, but it should be noted that the uart0 port is multiplexed with USB, so you cannot debug when using uart0

  • edited June 27

    I have just discovered I have the same issue. I have attached my project code which works as expected when the touch functionality is disabled. I understand from the comments in this thread why the issue is introduced, but I also do not know how to configure for asynchronous communication.
    Any further advice on using the touch screen function to change screens and using the I2C bus for peripherals for gathering data would be most gratefully received.
    I would like to be able to use the touch screen function to change between screens, but if I cannot then I could use external buttons, but not ideal.
    I have also attached the BME Library I am using as it is not a standard Adafruit one.

  • Is there a possible hardware solution to add additional I2C ports? I don't think an I2C multiplexer would help because it would still only have the one I2C channel to communicate back to the ESP32, but are there any other options?

  • edited June 28

    I have 4 devices using the I2C port, (real time clock, BME280, TFT Screen it’s self and then there is the touch screen. With the example code, when the touch screen is used it does not allow other I2C devices to use the I2C bus, I need the code to have the touch screen to check only periodically and not all the time, hence freeing up the bus for other devices to be able to use it. I would also like to add a I2C Wi-Fi module as well. The problem is only when the touch screen is enabled when using the demo code as a starting base.
    There must be a away to use these all together, just need some example code to show and an explanation of how to use the touch screen and other I2C devices together on the same bus, as I have not found it as yet.

Sign In or Register to comment.