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.
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.
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):
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.