ESP32 Pico V3 I/O expander

Jinu Vijayan
Posts: 3
Joined: Mon Jun 20, 2022 5:08 am

ESP32 Pico V3 I/O expander

Postby Jinu Vijayan » Mon Jun 20, 2022 5:20 am

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 "

rpiloverbd
Posts: 101
Joined: Tue Mar 22, 2022 5:23 am

Re: ESP32 Pico V3 I/O expander

Postby rpiloverbd » Tue Jun 21, 2022 7:47 am

Here are some info about this error message: https://github.com/espressif/arduino-esp32/issues/834

lbernstone
Posts: 1131
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32 Pico V3 I/O expander

Postby lbernstone » Tue Jun 21, 2022 8:20 am

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.

Jinu Vijayan
Posts: 3
Joined: Mon Jun 20, 2022 5:08 am

Re: ESP32 Pico V3 I/O expander

Postby Jinu Vijayan » Tue Jun 21, 2022 9:12 am

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.

Sprite
Espressif staff
Espressif staff
Posts: 10593
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 Pico V3 I/O expander

Postby Sprite » Tue Jun 21, 2022 9:45 am

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.

Jinu Vijayan
Posts: 3
Joined: Mon Jun 20, 2022 5:08 am

Re: ESP32 Pico V3 I/O expander

Postby Jinu Vijayan » Thu Jun 23, 2022 6:12 am

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.

Who is online

Users browsing this forum: No registered users and 1 guest