Problem with IQS7211A and ESP32 while using Wire

Hello,
In my project, i am working with IQS7211A with esp32 but with wire.h library its not working but its working fine with the Arduino. i code execution is happening but not working as expected.
this is the log of the device.

Start Serial communication
10:10:36.963 -> IQS7211A Setup start
10:10:36.963 -> Device Ready
10:10:37.010 -> before update
10:10:37.010 -> [    30][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.010 -> after update
10:10:37.010 -> Software Reset event occured.
10:10:37.010 -> Acknowledge reset.
10:10:37.010 -> [    53][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.010 -> prodNumLow:251
10:10:37.010 -> prodNumHigh:2
10:10:37.010 -> Product Number: 763   (Confirmed IQS7211A)
10:10:37.058 -> Major Version Number: 238
10:10:37.058 -> Minor Version Number: 238
10:10:37.058 -> [    88][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.058 -> [    89][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.058 -> [   102][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.105 -> [   114][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.105 -> [   127][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.105 -> [   139][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.105 -> [   152][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.151 -> [   164][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.151 -> [   177][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.151 -> [   199][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.151 -> IQS7211A Initialization complete.
10:10:37.198 -> [   233][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.198 -> [   245][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
10:10:37.198 -> Gesture:        Finger 1 X:         Finger 1 Y:         Finger 2 X:         Finger 2 Y:
10:10:37.244 -> func_val:0
10:10:37.244 -> No gesture
10:10:37.290 -> func_val:0
10:10:37.290 -> No gesture
10:10:37.337 -> func_val:0
10:10:37.337 -> No gesture
10:10:37.337 -> func_val:0
10:10:37.337 -> No gesture
10:10:37.384 -> func_val:0

and this is the main.c code

#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;
}
}


please have a look and let me know how can resolve this.
Thank You.

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.

I guess that you try to mix 3.3V and 5V devices on the I2C bus - then a level shifter is required.

Hello guys,

In my project, I am using an IQS550 touchpad module with esp32 but I got an i2c communication error the same code is working for Arduino and it's not working with esp32.

so this is the code part,

oid I2C_Setup(void)
{
  // Set I2C clock frequency
  Wire.begin(21,22);
  Wire.setClock(400000);
}

void IQS5xx_AcknowledgeReset(void) 
{
    static uint8_t System_ctrl_0 = ACK_RESET;  
	I2C_Write(SystemControl0_adr, &System_ctrl_0, 1);
	Serial.println("i am in acknowledgeReset");
}

uint8_t I2C_Write(uint16_t ui16RegisterAddress, uint8_t *pData, uint8_t ui8NoOfBytes)
{
  uint8_t ui8Retry = 4;

  ui8Success = I2C_Write2(ui16RegisterAddress, pData, ui8NoOfBytes);
  Serial.println("i am in write 2");
  Serial.println("err_code:");
  Serial.println(ui8Success);
  
  //
  // If comms was not successful, retry 4 more times
  //
  while ((!ui8Success))
  {
    delay(100);
    ui8Success = I2C_Write2(ui16RegisterAddress, pData, ui8NoOfBytes);
    ui8Retry--;
  }

  Serial.println("i am in writeS 2");
  Serial.println("err_code:");
  Serial.println(ui8Success);

  if (ui8Success)
  {
    return (TRUE);
  }
  else
  {
    Serial.println("Comms write error");
    return (FALSE);
  }
}

so here first, i set the wire.h library then for acknowledgment reset need to write the register but communication is not happening.
please help me to resolve this.
Thank You.

That could be a hardware problem, post your annotated schematic showing all connections, power, ground, and power sources. Also include links to technical information on each of the hardware devices. Frizzies do not contain enough information to be of any help.

Hi, @bhanu_riosh

What model Arduino?
If a 5V logic model, the ESP32 is a 3V3 controller.

What voltage are you operating the 550 on?

As @gilshultz has requested, a schematic would be of help.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

1 Like

@bhanu_riosh,

Your two or more topics on the same or similar subject have been merged.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

1 Like

It could be multiple problems, both hardware and software.

Can you show the rest of the code or give a link to it ?
For example the "I2C_Write2()" and the "IQS7211A.h" and every other file that you use.
The "I2C_Write2()" is associated with software I2C code.
A retry on the I2C bus is almost useless. There are sensors that disappear from the I2C bus when they are busy, and sometimes in very rare situations a retry might work if a noise glitch disturbed the I2C bus. In every other situation, when someone puts a retry in the code, that indicates a underlying problem.

Can you make a fresh start with the most common code and most common libraries that everyone uses ?

In the Arduino IDE, could you right-click on the code and select "Format Document".

Hello,

Sorry, the previous ticket is for IQS7211A and this ticket is for IQS550.

Both are different touchpads.

Hello,
Thanks for the reply,

https://www.azoteq.com/design/software-and-tools/
this is the link to the IQS550 touchpad Arduino library, and please let me know how can i implement this.

Already i am doing the same thing like developing the code from scratch and I can able to detect the device using the i2c scanner code.
but after this, i couldn't implement any function.

Please help me to resolve this.
Thank You.

Do you mean the "IQS5XX B000 Arduino example code" and the "IQS7211A Arduino Example Code" ? I must fill in my name and my email to see it :frowning_face:


For the IQS5XX, they made code with a custom I2C library which is for the Arduino Uno. They should not have done that. If you want to run that on a ESP32, then someone has to read everything about the device and go through all the code to fix it. That is not an easy task.


The IQS7211A uses the Arduino Wire library in a normal way. There is still a lot to read about the chip to understand it. I don't know how to help without having that device.
There is indeed a problem with the libraries with the "Stop" or "Restart" condition and with the provided example. They are making a mess of the parameter for that. The error messages that you get are correct. To fix that, the library has to be changed.

Can you read the datasheet of the IQS7211A to check if it really needs a "Restart" on the I2C bus ? I might work with only "Stop". Then you can change the code to have a "Stop" everywhere.

Sparkfun has the IQS7211A device in a MIKROE Touchpad: https://www.sparkfun.com/products/19188
In the tab "Documents" there is a link to Github, but that is not Arduino compatible code.

Hello,

Actually, we are working on this module only and not the IQS7211A module as of now. yes, I do understand the complexity of the library porting from Arduino to esp32 but I don't have another option. So I need to make it work with esp32 only.

i couldn't able to upload the zip file, its just normal email id filling, and doesn't require any registration.
Please fill the normal user details then it start downloading it

I have downloaded it to look at the code, but I'm not willing to spend days to learn about the sensor and trying to make sense of the code. Sorry.

Reading and writing data is easy, but it is all the things around it that I don't know.

void I2C_Setup(void)
{
  Wire.begin();
}

// Add the retries ?
uint8_t I2C_Write(uint16_t ui16RegisterAddress, uint8_t *pData, uint8_t ui8NoOfBytes)
{
  Wire.beginTransmission( ... );
  for(int i=0; i<ui8NoOfBytes; i++)
    Wire.write(pData[i]);
  int error = Wire.endTransmission();

  if(error == 0)
    return(true);
  else
   return(false);
}

// Add the retries ?
uint8_t I2C_Read(uint16_t ui16RegisterAddress, uint8_t *pData, uint8_t ui8NoOfBytes)
{
  int n = Wire.requestFrom( ... , ui8NoOfBytes);
  if(n == ui8NoOfBytes)
  {
    Wire.readBytes(pData, ui8NoOfBytes);
    return(true);
  }
  else
  {
    return(false);
  }
}

I don't know what to do with the retries, the "Close_Comms()", the "I2C_Reset()" and other things.

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