Repeated transaction happens with esp32

In my project, i am working with arduino and iqs7211a touch pad and its working fine.
but now i want to try with esp32 but its not working and throws me repeated transaction error in readrandombytes function. so how can i resolve this.?
this is the read and write function please help me resolve this.

void readRandomBytes(uint8_t memoryAddress, int numBytes, uint8_t bytesArray[], bool stopOrRestart)
{
  uint8_t i = 0;  // A simple counter to assist with loading bytes into the user supplied array.
  Wire.beginTransmission(_deviceAddress);
  Wire.write(memoryAddress);
  Wire.endTransmission();
  do
  {
  Wire.requestFrom((uint16_t)_deviceAddress, (size_t)numBytes);
  }
  while(Wire.available() == 0);  // Wait for response, this sometimes takes a few attempts

  while(Wire.available() && i<numBytes) 
  {
    bytesArray[i] = Wire.read();
    i++;
  }
  Wire.endTransmission();
  // Wire.endTransmission(true);
  // uint8_t i = 0;  // A simple counter to assist with loading bytes into the user supplied array.
  // Wire.beginTransmission(_deviceAddress);
  // Wire.write(memoryAddress);
  // Wire.endTransmission(true);

  // while (Wire.requestFrom((uint16_t)_deviceAddress, (size_t)numBytes, false) != numBytes)
  // {
  //   // Wait for response, this sometimes takes a few attempts
  // }

  // while (Wire.available() && i < numBytes)
  // {
  //   bytesArray[i++] = Wire.read();
  // }

// And Bob's your uncle.
}

void writeRandomBytes(uint8_t memoryAddress, int numBytes, uint8_t bytesArray[], bool stopOrRestart)
{
  //  // Select the device with the address of "_deviceAddress" and start communication.
  // Wire.beginTransmission(_deviceAddress);
  // // Specify the memory address where the IQS7211A must start saving the data, as designated by the "memoryAddress" variable.
  // Wire.write(memoryAddress);
  // // Write the bytes as specified in the array which "arrayAddress" pointer points to.
  // for(int i=0; i<numBytes; i++)
  // {
  //   Wire.write(bytesArray[i]);
  // }
  // // End the transmission, user decides to STOP or RESTART.
  // Wire.endTransmission(stopOrRestart);

  Wire.beginTransmission(_deviceAddress);
  Wire.write(memoryAddress);
  for (int i = 0; i < numBytes; i++)
  {
    Wire.write(bytesArray[i]);
  }
  Wire.endTransmission();
}

Are you using any library other than wire.h? If so, make sure that the other library supports ESP32?

I moved your topic to an appropriate forum category @bhanu_riosh.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Thanks for the reply,

this is the link to library, and they don't know that its supports esp32.

Thank You.

Hi, you may try to change this part

do
  {
  Wire.requestFrom((uint16_t)_deviceAddress, (size_t)numBytes);
  }
  while(Wire.available() == 0);  // Wait for response, this sometimes takes a few attempts

to

do
  {
  Wire.requestFrom((uint16_t)_deviceAddress, (size_t)numBytes);
   delay(10);
  }
  while(Wire.available() == 0);  // Wait for response, this sometimes takes a few attempts

Just a guess, but the esp32 is much quicker than an UNO or the like ..

You may also (additionally) check if a "false" might be helpful as a last parameter in wire.requestFrom():

Wire.requestFrom(address, quantity, stop)

Parameters
address: the 7-bit slave address of the device to request bytes from.

quantity: the number of bytes to request.

stop: true or false. true will send a stop message after the request, releasing the bus. False will continually send a restart after the request, keeping the connection active.

Not sure but you may give it a try ...

hello,

i tried by sending stop or restart also bu i got this warning and this is log

src/IQS7211A.cpp: In function 'void readRandomBytes(uint8_t, int, uint8_t*, bool)':
src/IQS7211A.cpp:596:50: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
   Wire.requestFrom(IQS_ADR,numBytes,stopOrRestart);
                                                  ^
In file included from include/IQS7211A.h:6,
                 from src/IQS7211A.cpp:1:
C:/Users/vishn/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.h:126:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int, int)'
     uint8_t requestFrom(int address, int size, int sendStop);
             ^~~~~~~~~~~
C:/Users/vishn/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.h:122:12: note: candidate 2: 'size_t TwoWire::requestFrom(uint8_t, size_t, bool)'
     size_t requestFrom(uint8_t address, size_t len, bool stopBit);
            ^~~~~~~~~~~
src/IQS7211A.cpp:596:50: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
   Wire.requestFrom(IQS_ADR,numBytes,stopOrRestart);
                                                  ^
In file included from include/IQS7211A.h:6,
                 from src/IQS7211A.cpp:1:
C:/Users/vishn/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.h:126:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int, int)'
     uint8_t requestFrom(int address, int size, int sendStop);
             ^~~~~~~~~~~
C:/Users/vishn/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.h:120:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint16_t, uint8_t, bool)'
     uint8_t requestFrom(uint16_t address, uint8_t size, bool sendStop);
             ^~~~~~~~~~~
src/IQS7211A.cpp:596:50: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
   Wire.requestFrom(IQS_ADR,numBytes,stopOrRestart);
                                                  ^
In file included from include/IQS7211A.h:6,
                 from src/IQS7211A.cpp:1:
C:/Users/vishn/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.h:126:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int, int)'
     uint8_t requestFrom(int address, int size, int sendStop);
             ^~~~~~~~~~~
C:/Users/vishn/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.h:119:12: note: candidate 2: 'size_t TwoWire::requestFrom(uint16_t, size_t, bool)'
     size_t requestFrom(uint16_t address, size_t size, bool sendStop);
            ^~~~~~~~~~~
src/IQS7211A.cpp:596:50: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
   Wire.requestFrom(IQS_ADR,numBytes,stopOrRestart);
                                                  ^
In file included from include/IQS7211A.h:6,
                 from src/IQS7211A.cpp:1:
C:/Users/vishn/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.h:126:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int, int)'
     uint8_t requestFrom(int address, int size, int sendStop);
             ^~~~~~~~~~~
C:/Users/vishn/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.h:122:12: note: candidate 2: 'size_t TwoWire::requestFrom(uint8_t, size_t, bool)'
     size_t requestFrom(uint8_t address, size_t len, bool stopBit);

but after this repeated issue was resolved product id is not verified before this some times product verified was as fine.

hello

i got some improvement in working.

first have a look at the log, after that below, I will share the main. c, read and write functions changes but still repeated transaction happening,
this is recent log,

16:34:39.529 -> ets Jun  8 2016 00:22:57
16:34:39.529 -> 
16:34:39.529 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
16:34:39.529 -> configsip: 0, SPIWP:0xee
16:34:39.529 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
16:34:39.529 -> mode:DIO, clock div:2
16:34:39.529 -> load:0x3fff0030,len:1184
16:34:39.529 -> load:0x40078000,len:13192
16:34:39.529 -> load:0x40080400,len:3028
16:34:39.529 -> entry 0x400805e4
16:34:39.670 -> Start Serial communication
16:34:39.670 -> IQS7211A Setup start
16:34:42.426 -> Device Ready
16:34:42.471 -> before update
16:34:42.471 -> [  2792][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:42.660 -> after update
16:34:42.660 -> i am here
16:34:42.703 -> Software Reset Bit set.
16:34:42.703 -> [  3029][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:42.796 -> prodNumLow:251
16:34:42.796 -> prodNumHigh:2
16:34:42.796 -> Product Number: 763   (Confirmed IQS7211A)
16:34:42.796 -> Major Version Number: i am here
16:34:42.842 -> 1
16:34:42.890 -> Minor Version Number: 0
16:34:42.937 -> [  3249][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:42.937 -> [  3250][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:42.937 -> [  3263][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:42.937 -> [  3275][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:42.983 -> [  3288][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:42.983 -> [  3300][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:42.983 -> [  3313][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:43.031 -> [  3325][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:43.031 -> [  3338][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:43.077 -> [  3412][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:43.121 -> IQS7211A Initialization complete.
16:34:43.354 -> [  3672][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:43.400 -> [  3727][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
16:34:43.447 -> Gesture:        Finger 1 X:         Finger 1 Y:         Finger 2 X:         Finger 2 Y:
16:35:01.756 -> func_val:0
16:35:01.756 -> No gesture
16:35:03.530 -> func_val:0
16:35:03.530 -> No gesture
16:35:03.671 -> func_val:0
16:35:03.671 -> No gesture

this is main.c

#include <Arduino.h>
#include <Wire.h>
#include "IQS7211A.h"
// put function declarations here:
extern IQS7211A_MEMORY_MAP IQSMemoryMap;
void setup() {
  uint16_t prod_num;
  Serial.begin(115200);
  while (!Serial);
  Serial.println("Start Serial communication");
  Serial.println("IQS7211A Setup start");
  while (!begin());
  Serial.println("Device Ready");
  disableCommsReqEn(RESTART);
  Serial.println("before update");
  updateInfoFlags(RESTART);
   Serial.println("after update");
  if(checkReset())
  {
    Serial.println("Software Reset event occured.");
    //If the Show Reset bit is set, acknowledge the reset event
    acknowledgeReset(RESTART);
    Serial.println("Acknowledge reset.");
  }
  else
  {
    Serial.println("i am here");
    //Perform SW Reset
    SW_Reset(RESTART);
    Serial.println("Software Reset Bit set.");
    // Read the Info flags
    updateInfoFlags(RESTART);
    //Check if Show Reset bit is set
    if (checkReset())
    {
      Serial.println("Software Reset event occured.");
      //If the Show Reset bit is set, acknowledge the reset event
      acknowledgeReset(RESTART);
      Serial.println("Acknowledge reset.");
    }
  }

  prod_num =getProductNum(RESTART);
  Serial.print("Product Number: "); Serial.print(prod_num);

  if (prod_num == IQS7211A_PRODUCT_NUM)
  {
    Serial.println("   (Confirmed IQS7211A)");
  }
  else
  {
    Serial.println("   Device is not a IQS7211A!");
    while (1);
  }

  Serial.print("Major Version Number: "); Serial.println(getSoftwareMajorNum(RESTART));
  Serial.print("Minor Version Number: "); Serial.println(getSoftwareMinorNum(RESTART));

  writeMM(RESTART);
  // Clear the Comms Request Enable bit
  disableCommsReqEn(RESTART);
  // ATI after writing settings from h-file.
  TP_ReATI(STOP);
  Serial.println("IQS7211A Initialization complete.");

   while (!waitForReady());
  //Enable Gesture Events and TP Events
  enableGestureEvent(RESTART);
  enableTPEvent(RESTART);
  // Enable Event Mode
  setEventMode(STOP);
  // Print the headers
  Serial.println("Gesture:        Finger 1 X:         Finger 1 Y:         Finger 2 X:         Finger 2 Y:");
}
int val;
void loop() {
  // put your main code here, to run repeatedly:

while (!waitForReady());
updateGestures(RESTART);
updateAbsCoordinates(RESTART, FINGER_1);
updateAbsCoordinates(STOP, FINGER_2);
val = IQSMemoryMap.iqs7211a_gesture_events.iqs7211a_gesture_events_lsb;
Serial.print("func_val:");
Serial.println(val);

switch (val)
{
  case 0:
    Serial.println("No gesture");
    break;
  case 1:
    Serial.println("Single tap");
    break;
  case 2:
    Serial.println("Press and Hold");
    break;
  case 4:
    Serial.print("Swipe X Neg  ");
    // mySerial.println("3");
    break;
  case 8:
    Serial.print("Swipe X Pos  ");
    // mySerial.println("2");
    break;
  case 16:
    Serial.print("Swipe Y Pos  ");
    // mySerial.println("0");
    break;
  case 32:
    Serial.print("Swipe Y Neg  ");
    // mySerial.println("1");
    break;
  default:
    break;
}
}


this is read and write functions

void readRandomBytes(uint8_t memoryAddress, int numBytes, uint8_t bytesArray[], bool stopOrRestart)
{
  uint8_t i = 0;  // A simple counter to assist with loading bytes into the user supplied array.
  Wire.beginTransmission(IQS_ADR);
  Wire.write(memoryAddress);
  Wire.endTransmission(RESTART);
  do
  {
  Wire.requestFrom(IQS_ADR,numBytes,1);
  delay(50);
  }
  while(Wire.available() == 0);  // Wait for response, this sometimes takes a few attempts
  while (Wire.available() && i < numBytes)
  {
    bytesArray[i++] = Wire.read();
  }

// And Bob's your uncle.
}

void writeRandomBytes(uint8_t memoryAddress, int numBytes, uint8_t bytesArray[], bool stopOrRestart)
{
   // Select the device with the address of "_deviceAddress" and start communication.
  Wire.beginTransmission(IQS_ADR);
  // Specify the memory address where the IQS7211A must start saving the data, as designated by the "memoryAddress" variable.
  Wire.write(memoryAddress);
  // Write the bytes as specified in the array which "arrayAddress" pointer points to.
  for(int i=0; i<numBytes; i++)
  {
    Wire.write(bytesArray[i]);
  }
  // End the transmission, user decides to STOP or RESTART.
  Wire.endTransmission(stopOrRestart);

}

so how can i stop this repeated transaction?

thank You

The warnings refer to two different declarations of the same function in the expressif32 wire library:

:/Users/vishn/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.h:126:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int, int)'
     uint8_t requestFrom(int address, int size, int sendStop);
             ^~~~~~~~~~~
C:/Users/vishn/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.h:122:12: note: candidate 2: 'size_t TwoWire::requestFrom(uint8_t, size_t, bool)'
     size_t requestFrom(uint8_t address, size_t len, bool stopBit);

candidate 1: 'uint8_t TwoWire::requestFrom(int, int, int)'
candidate 2: 'size_t TwoWire::requestFrom(uint8_t, size_t, bool)'

Very likely not the reason for your problem.

Hello,

ok.

I hope you have seen the log then what will be the problem with the repeated transaction?

Thank You.

As I do not have access to an IQS7211A device it is quite difficult to assist you.

I found a similar library on github for the IQS7222
https://github.com/colinlaganier/IQS7222Library

that uses similar functions inside the lib and seems to have similar constants/defines ...

The problem occurs inside the IQS7211A lib which I could not find (except on the vendors webpage where they request personal data ...).

You might change the title of your topic to "Problem with IQS7211A and ESP32 while using Wire" to address members who have experience with the device.

BTW your log file shows a strange line at:

16:34:42.796 -> Product Number: 763   (Confirmed IQS7211A)
16:34:42.796 -> Major Version Number: i am here
16:34:42.842 -> 1
16:34:42.890 -> Minor Version Number: 0

Where does the text "i am here" come from at this place?

Good luck!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.