-
Notifications
You must be signed in to change notification settings - Fork 7.6k
analogRead on certain pins breaks u8g2 library in 3.0.0 alpha dev (mysterious) #9040
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
Comments
UPDATE Of course it had nothing to do with the function. analogRead on pin 5 works great, on 9 it breaks the screen. void loop(void) {
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_ncenB08_tr);
char buff[100];
int val = analogRead(5); // WORKS, 9 DOES NOT WORK!!!
sprintf(buff, "val: %d\n", val);
u8g2.drawStr(0, 10, buff);
u8g2.sendBuffer();
} Updated the original issue. |
UPDATE void setup(void) {
pinMode(3, INPUT);
pinMode(5, INPUT);
pinMode(9, INPUT);
u8g2.begin();
} The above code works (with analogRead on pin 5) It seems like the error is with configuring the analog pin for input. |
I found a workaround for my project by using pins 3 and 5 for my joystick. |
@ForrestFire0 - I just checked the ESP32-S2 Lolin Mini board about its pin definition. arduino-esp32/variants/lolin_s2_mini/pins_arduino.h Lines 31 to 34 in ab6a25e
|
Mysterious solved! Have fun with your project! |
Wonderful. Purely for my own understanding, why would configuring the pin with pin mode cause the SPI to break? Does it disable the SPI interface? |
In Arduino 3.0.0 there is a new feature called Peripheral Manager. I think that your example brings a good questioning because most displays will only care about using MOSI and not MISO. Therefore, I would say that we may review it in order to allow using SPI pins partly. |
I’m happy to close this issue, it seems like at the moment this is an intended (maybe undocumented?) feature. Thanks to everyone doing all this great work, I have been an ESP-Arduino appreciator for a few years now. |
Board
LOLIN S2 Mini (ESP32 S2)
Device Description
Hardware is esp32 lolin s2 mini board attached to a cheap typical joystick module and to a oled screen. The pinout is in the code. The individual components work separately (and worked together on previous versions of arduino-esp32 framework) to I don't think it's the wiring, happy to share.
Hardware Configuration
used for u8g2 SPI connection
#define SPI_CS 35
#define SPI_DC 37
#define SPI_RST 33
The joystick axis X (pin 5) and Y (pin 9) is hooked up to the ESP32 S2.
Version
3.0.0 alpha 3
IDE Name
Arduino IDE
Operating System
Windows 11 home
Flash frequency
40 MHz
PSRAM enabled
yes
Upload speed
921600
Description
I am trying to connect my joystick (analogRead single shot) to my u8g2 screen.
Both components work independently.
See the sketch. When pin 5 is read, all good, when pin 9 is read, nothing is printed to the screen.
Sketch
Debug Message
Other Steps to Reproduce
Was working on the stable version of arduino-esp32, however I need esp idf 5.1 functionality so need to use the dev version. I don't see any of my needed functionality as stuff that is being messed with.
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: