Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEN0359 interface with esp32 #5

Open
nikitanagar62 opened this issue Jan 30, 2024 · 18 comments
Open

SEN0359 interface with esp32 #5

nikitanagar62 opened this issue Jan 30, 2024 · 18 comments

Comments

@nikitanagar62
Copy link

I am working on SEN0359 with esp32 Devkit. I used the fingerprintResitration example but there is an error that is :

In file included from c:\Users\Adevair Technologies\Documents\Arduino\libraries\DFRobot_ID809_I2C/DFRobot_ID809_I2C.h:22, from c:\Users\Adevair Technologies\Documents\Arduino\libraries\DFRobot_ID809_I2C\DFRobot_ID809_I2C.cpp:12: C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h: In member function 'virtual void DFRobot_ID809_I2C::sendPacket(pCmdPacketHeader_t)': C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:127:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)' uint8_t requestFrom(int address, int size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:125:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)' uint8_t requestFrom(uint8_t address, uint8_t size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:127:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)' uint8_t requestFrom(int address, int size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:125:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)' uint8_t requestFrom(uint8_t address, uint8_t size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:127:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)' uint8_t requestFrom(int address, int size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:125:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)' uint8_t requestFrom(uint8_t address, uint8_t size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:127:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)' uint8_t requestFrom(int address, int size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:125:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)' uint8_t requestFrom(uint8_t address, uint8_t size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h: In member function 'virtual size_t DFRobot_ID809_I2C::readN(void*, size_t)': C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:127:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)' uint8_t requestFrom(int address, int size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:125:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)' uint8_t requestFrom(uint8_t address, uint8_t size);

I changed the wire.h library in DFRobot_ID809_I2C.h from <wire.h> to "wire.h" then it is not showing any error but output is not appearing.

Can anyone tell that what is the issue and how to solve it ?
Thank you
Nikita

@dylanwe
Copy link

dylanwe commented Mar 8, 2024

I'm having the same issue.
I tried downgrading to 1.0.1, showing me that my connection failed but didn't give any extra info on why.

It is able to find the i2c device with this scanner:

I2C scanner. Scanning ...
Found address: 31 (0x1F)
Found 1 device(s).

Looking into the code I found that getDeviceInfo() returns nothing:

bool DFRobot_ID809_I2C::begin()
{
...
  String str = getDeviceInfo(); // <- this returns an empty string
...
}

Going a bit deeper I found:

String DFRobot_ID809::getDeviceInfo()
{
...
  result = responsePayload(buf); // <- This is 255 which is a error
...
}
uint8_t DFRobot_ID809::responsePayload(void* buf)
{
...
  if (ret != ERR_SUCCESS) {
    ret = ERR_ID809; // <- Throws this error
  } else if (dataLen != dataCount) {
...
}

It seems to me that the readN method of DFRobot_ID809_I2C is failing to read the SDA & SCL of the ESP32.

I've tested this on:

The wiring:
IMG_3343
IMG_3344

The error of Nikita is caused by an ambiguous call of requestFrom which has been fixed in the master but isn't present in the library when downloading from ArduinoIDE. Even with this fix the fingerprint still doesn't work.

@qsjhyy
Copy link
Contributor

qsjhyy commented Mar 11, 2024

I am working on SEN0359 with esp32 Devkit. I used the fingerprintResitration example but there is an error that is :

In file included from c:\Users\Adevair Technologies\Documents\Arduino\libraries\DFRobot_ID809_I2C/DFRobot_ID809_I2C.h:22, from c:\Users\Adevair Technologies\Documents\Arduino\libraries\DFRobot_ID809_I2C\DFRobot_ID809_I2C.cpp:12: C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h: In member function 'virtual void DFRobot_ID809_I2C::sendPacket(pCmdPacketHeader_t)': C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:127:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)' uint8_t requestFrom(int address, int size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:125:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)' uint8_t requestFrom(uint8_t address, uint8_t size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:127:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)' uint8_t requestFrom(int address, int size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:125:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)' uint8_t requestFrom(uint8_t address, uint8_t size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:127:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)' uint8_t requestFrom(int address, int size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:125:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)' uint8_t requestFrom(uint8_t address, uint8_t size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:127:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)' uint8_t requestFrom(int address, int size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:125:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)' uint8_t requestFrom(uint8_t address, uint8_t size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h: In member function 'virtual size_t DFRobot_ID809_I2C::readN(void*, size_t)': C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:127:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)' uint8_t requestFrom(int address, int size); ^~~~~~~~~~~ C:\Users\Adevair Technologies\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\libraries\Wire\src/Wire.h:125:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)' uint8_t requestFrom(uint8_t address, uint8_t size);

I changed the wire.h library in DFRobot_ID809_I2C.h from <wire.h> to "wire.h" then it is not showing any error but output is not appearing.

Can anyone tell that what is the issue and how to solve it ? Thank you Nikita

This should be the problem of inconsistent wire standards. I have fixed it before, but because of the version number, you could not download that version. Now the problem has been solved.

@qsjhyy
Copy link
Contributor

qsjhyy commented Mar 11, 2024

I'm having the same issue. I tried downgrading to 1.0.1, showing me that my connection failed but didn't give any extra info on why.

It is able to find the i2c device with this scanner:

I2C scanner. Scanning ...
Found address: 31 (0x1F)
Found 1 device(s).

Looking into the code I found that getDeviceInfo() returns nothing:

bool DFRobot_ID809_I2C::begin()
{
...
  String str = getDeviceInfo(); // <- this returns an empty string
...
}

Going a bit deeper I found:

String DFRobot_ID809::getDeviceInfo()
{
...
  result = responsePayload(buf); // <- This is 255 which is a error
...
}
uint8_t DFRobot_ID809::responsePayload(void* buf)
{
...
  if (ret != ERR_SUCCESS) {
    ret = ERR_ID809; // <- Throws this error
  } else if (dataLen != dataCount) {
...
}

It seems to me that the readN method of DFRobot_ID809_I2C is failing to read the SDA & SCL of the ESP32.

I've tested this on:

The wiring: IMG_3343 IMG_3344

The error of Nikita is caused by an ambiguous call of requestFrom which has been fixed in the master but isn't present in the library when downloading from ArduinoIDE. Even with this fix the fingerprint still doesn't work.

I did not find this problem when I tested it. Could you please use the latest updated version library for testing feedback? Thank you.

@dylanwe
Copy link

dylanwe commented Mar 11, 2024

What ESP32 did you use to check this with? Could you confirm that it works on this ESP32

This is the result of me trying it with the new 1.1.1 version that was made today. The baud rate is 9600
image

I've also tried this on my Arduino Uno which with the latest version(1.1.1) also doesn't seem to work.:
image

I thought that my jumper wires might be the issue but using the same wires and switching back to 1.1.0 still works on the Arduino Uno. Running version 1.1.0 on the ESP32 however, doesn't work.

device version status
ESP32 v1.1.1 not working
ESP32 v1.1.0 not working
Arduino Uno v1.1.1 not working
Arduino Uno v1.1.0 working

@qsjhyy
Copy link
Contributor

qsjhyy commented Mar 12, 2024

image
image

@qsjhyy
Copy link
Contributor

qsjhyy commented Mar 12, 2024

As shown in the figure, everything in my test is normal, uno or esp32 are fine. Have you ever tried resetting uno or esp32 after burning the sample code? I don't have enough information to find the cause of the problem.

@dylanwe
Copy link

dylanwe commented Mar 12, 2024

Strange, what specific ESP32 did you use and do you have an example of how to connect the fingerprint I2C to the esp32?

@qsjhyy
Copy link
Contributor

qsjhyy commented Mar 12, 2024

The examples in the library are used, with no additional changes.
image

@dylanwe
Copy link

dylanwe commented Mar 12, 2024

How did you wire the fingerprint to your esp32? Do you maybe have a diagram or picture? And you used this https://www.dfrobot.com/product-2195.html esp32?

@Karl-Gilmartin
Copy link

I am facing the same issue also. I am using an Arduino Nano ESP32 and the SEN0359. I followed the wiring of the pin layout of the board for the SDA and SCL, but I still can't get a connection, getting Communication with device failed, please check connection. The SEN0359 connected to my UNO R4 WiFi perfectly tho.

@qsjhyy
Copy link
Contributor

qsjhyy commented Mar 13, 2024

Considering the similar situation of both of you, it may also be a power supply related problem. For example, the esp32 is 3.3V, the uno is 5V; And the pin current is also different, which may be related to the current provided by the computer usb port. I wonder if you can provide extra power to the esp32.

@qsjhyy
Copy link
Contributor

qsjhyy commented Mar 13, 2024

How did you wire the fingerprint to your esp32? Do you maybe have a diagram or picture? And you used this https://www.dfrobot.com/product-2195.html esp32?

When I was in the test using this model esp32:https://www.dfrobot.com/product-1590.html.

@dylanwe
Copy link

dylanwe commented Mar 13, 2024

If it is a power supply issue than it should've worked on my Arduino Uno R3 but it doesn't with version 1.1.1 the Uno does work with version 1.1.0

@dylanwe
Copy link

dylanwe commented Mar 13, 2024

It's not the power supply, the code just doesn't work for our ESP32's. I've modified readN and it now works on my ESP32.
I've created a pull request with the fixed code https://github.com/DFRobot/DFRobot_ID809_I2C/pull/6/files.

dylanwe added a commit to dylanwe/DFRobot_ID809_I2C that referenced this issue Mar 13, 2024
@qsjhyy
Copy link
Contributor

qsjhyy commented Mar 13, 2024

@dylanwe I don't think this is correct. requestFrom has complete start and stop bits, so adding beginTransmission and endTransmission before and after it is an incorrect operation. Moreover, multiple bytes should not be read one by one, as this will introduce many unnecessary start and stop bits, which is also the reason why I modified the code earlier. You can test the operation of the following two code segments to determine if the problem lies here. I have attached the I2C communication waveform scanned by the logic analyzer respectively.

size_t DFRobot_ID809_I2C::readN(void* pBuf, size_t size)
{
  uint8_t count = 0;
  if (pBuf == NULL) {
    LDBG("pBuf ERROR!! : null pointer");
  }
  uint8_t* _pBuf = (uint8_t*)pBuf;

  while (size > count) {
    _pWire->requestFrom(_deviceAddr, (uint8_t)1);
    while (_pWire->available()) {
      _pBuf[count] = _pWire->read();   // Use read() to receive and put into buf
      count++;
    }
  }

  return count;
}

image

size_t DFRobot_ID809_I2C::readN(void* pBuf, size_t size)
{
  uint8_t count = 0;
  if (pBuf == NULL) {
    LDBG("pBuf ERROR!! : null pointer");
  }
  uint8_t* _pBuf = (uint8_t*)pBuf;

  while (size > count) {
    _pWire->requestFrom(_deviceAddr, (uint8_t)(((size - count) > 32) ? 32 : (size - count)));
    delay(1);
    while (_pWire->available()) {
      _pBuf[count] = _pWire->read();   // Use read() to receive and put into buf
      count++;
    }
  }

  return count;
}

image

@dylanwe
Copy link

dylanwe commented Mar 13, 2024

The begin and ending of a transmission is indeed not needed. The First sample you gave where you do requestfrom with 1 instead of 2 does work for me. In the second sample where you get 32 it stops working and gives me:

Communication with device failed, please check connection

@qsjhyy
Copy link
Contributor

qsjhyy commented Mar 13, 2024

So, it seems that there might be compatibility issues with the Wire library in the SDK, and there is nothing wrong with the library code itself. You can thoroughly test your SDK to see if it cannot read 32 bytes at a time (this standard is also set according to the Uno; the Uno default maximum communication size is 32 bytes). I am using the official Espressif SDK, and it runs very well.
image

@dylanwe
Copy link

dylanwe commented Mar 13, 2024

Thank you for the help, I'll just copy the library and change it to pull 1 byte for now. If I have more time I'll look more into why my ESP32 can only get 1 byte.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants