Page 1 of 1

ESP32 Pico V3 I/O expander

Posted: Mon Jun 20, 2022 5:20 am
by Jinu Vijayan
Hello, I am a student and I am trying to use tca6424a with a ESP32 PICO V3. When I upload the code for the interface and the code gets executed up to the test connection command after that it is not working the code I am using is attached below. I wrote the code in vscode using platformio.

Code: Untitled.cpp Select all


#include "TCA6424A.h"
#include <Arduino.h>

#define SDA 5
#define SCL 0
#define RESET_PIN 2

TwoWire twi(1);
// TCA6424A expander1(&twi);
TCA6424A expander2(&twi);

void setup()
{
Serial.begin(115200);
twi.setPins(SDA, SCL);
// expander1.begin(TCA6424A_ADDRESS_ADDR_LOW);
expander2.begin(TCA6424A_ADDRESS_ADDR_HIGH);
}

void loop()
{
// Serial.print("expander1: ");
// Serial.println(expander1.testConnection() ? "true" : "false");
Serial.print("expander2: ");
Serial.println(expander2.testConnection() ? "true" : "false");
delay(1000);
}
The message it is showing in the serial monitor is as folows
" expander2: [ 15][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock "

Re: ESP32 Pico V3 I/O expander

Posted: Tue Jun 21, 2022 7:47 am
by rpiloverbd
Here are some info about this error message: https://github.com/espressif/arduino-esp32/issues/834

Re: ESP32 Pico V3 I/O expander

Posted: Tue Jun 21, 2022 8:20 am
by lbernstone
If the WireScan example https://github.com/espressif/arduino-es ... s/WireScan doesn't show you an address, then you have an electrical problem. I don't have time to explain how I2C works, but I'll bet google does. You probably need some pullup resistors.

Re: ESP32 Pico V3 I/O expander

Posted: Tue Jun 21, 2022 9:12 am
by Jinu Vijayan
If the WireScan example https://github.com/espressif/arduino-es ... s/WireScan doesn't show you an address, then you have an electrical problem. I don't have time to explain how I2C works, but I'll bet google does. You probably need some pullup resistors.
I used an I2C scanner program and it sows the address of the I/O expanders and the pull up for the SDA and SCL pins are done inside the library for I2C.

Re: ESP32 Pico V3 I/O expander

Posted: Tue Jun 21, 2022 9:45 am
by Sprite
Those internal pull-ups are 50K or so, which is way too high for I2C. Suggest you add external pull-ups; something like 2K7 should work.

Re: ESP32 Pico V3 I/O expander

Posted: Thu Jun 23, 2022 6:12 am
by Jinu Vijayan
Those internal pull-ups are 50K or so, which is way too high for I2C. Suggest you add external pull-ups; something like 2K7 should work.
I did that but the problem still persists.