How to get Pin Numbering by GPIO number (legacy) on ESP32-S3 boards?

Hello, I am using IDE 2.3.6.

When connected an Arduino Nano ESP32 to the IDE, there is an option “Pin Numbering: By GPIO number (legacy)”. However, when I connected ESP32-S3 boards such as those from Adafruit, there is no such option. Is there any way to enable it?

Hi @bbqq. That is the sole configuration of all the ESP32-based boards other than the Arduino Nano ESP32. It is only the Arduino Nano ESP32 board that has the alternative "By arduino pin" configuration.

So you don't need to take any action at all to get the configuration you desire when using boards other than the Arduino Nano ESP32.

1 Like

Thanks. I am having a strange issue here.

When I connected a Modulino Knob to an Adafruit ESP32-S3 Feather Reverse or an Adafruit ESP32-S3 Feather with 4MB Flash 2MB PSRAM- STEMMA QT via the included Qwiic cable, the Serial Monitor only kept printing “Current position is: 0” continuously. The green LED on the Modulino is On.

Unable to use Modulino Knob with Adafruit ESP32-S3 Feather Reverse - Official Hardware / Modulino - Arduino Forum

As a test, I swapped the Adafruit boards with an Arduino Nano ESP32. The sample program allso printed the same thing but it worked (printed the correct button and knob status) when I chose “By GPIO number (legacy)”. How come? So I thought if I could make the same GPIO setting on those Adafruit boards, they might work.

This is the code I used (copied and pasted from the official product page):

Getting Started with Modulino Knob | Arduino Documentation

#include <Modulino.h>

ModulinoKnob knob;

void setup() {
Serial.begin(9600);
Modulino.begin();
knob.begin();
}

void loop(){
int position = knob.get();
bool click = knob.isPressed();

Serial.print("Current position is: ");
Serial.println(position);

if(click){
Serial.println("Clicked!");
}
}

I saw this post:

Not working with Qwiic devices - UNO Family / UNO R4 WiFi - Arduino Forum

Based on the solution, I modified the setup() to:

void setup() {

   Wire1.begin();




   Serial.begin(9600);

   Modulino.begin(&Wire1);

   knob.begin(&Wire1);

}

However, during compilation, I got:

Compilation error: invalid user-defined conversion from 'TwoWire*' to 'TwoWire&' [-fpermissive]

Hi @bbqq.

I don't think it is relevant:

https://learn.adafruit.com/adafruit-esp32-s3-feather/i2c-scan-test#:~:text=The%20Feather%20ESP32-S3%20only%20has%20one%20I2C%20port%2C%20Wire%2C%20that%20is%20on%20pins%20SDA%20and%20SCL%20and%20shared%20with%20the%20STEMMA%20QT%20connector.

The Feather ESP32-S3 only has one I2C port, Wire , that is on pins SDA and SCL and shared with the STEMMA QT connector.

Unfortunately I don't own any of the Adafruit ESP32-S3 Feather boards, but I do have the somewhat similar Adafruit ESP32-S2 Feather. I was able to reproduce the 'only kept printing “Current position is: 0” continuously' problem you encountered when using the Modulino Knob with that board.

Investigating further, I found that there is a failure at this line:

We can improve the sketch in this respect by adding handling for the return value of the function:

  if (!knob.begin()) {
    while (!Serial) {}  // Wait for Serial Monitor to be opened.
    delay(500);  // Give a little time to make sure the serial port connection is initialized.
    Serial.println("knob.begin() failed!!!");
    while (true) {}  // No point in trying to continue.
  }

Background

We can see the source code of that function here:

You can see this is the code that allows the "Arduino_Modulino" library to automatically discover the Modulino Knob that is connected to the board, and this works perfectly when I connect the Modulino Knob to my Arduino Nano R4 board (I just grabbed that board randomly for a quick test). However, the discovery fails when it is connected to the ESP32-S2 Feather. I spent a bit of time investigating, but unfortunately didn't spot anything that should cause this.

Workaround

I did find I was able to work around the problem by explicitly configuring the hardware I2C address of the Modulino Knob via the ModulinoKnob constructor, which causes the discovery to be skipped. You can do that by changing the following line of your sketch:

to this:

// See: https://docs.arduino.cc/tutorials/modulino-knob/how-general/#node-addressing-reference
ModulinoKnob knob(0x3A);  // Adjust the argument if you configured the Modulino Knob to use a custom address.

then upload the modified sketch to the board. Hopefully it will work as expected now.

After I added 0X3A as the parameter for knob, it works immediately. Thank you very much.

I see you use 0X3A which is the Hardware I2C Address rather than 0X76 that is the Modulino I2C Address. How come?

In the future, do you expect that I have to do the same thing when connecting other I2C device(s) to the Feathers with ESP32-S3 or ESP32-S2?