0

Okay, I'm using u8g2 library for my OLED display. After calling SD.begin(4) function, I cannot display anything on my OLED.

I'm using U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); constructor from u8g2 library since I'm using I²C for the display and SPI for microSD reader. I removed the CS Pin 4 from SD.begin() and I can now display something on the OLED.

How did supplying CS Pin parameter to SD.begin() function affected the I²C OLED display?

1 Answer 1

1

Pins 4 and 5 are the I2C pins that belong to the built in I2C peripheral on the Arduino. You have to put your CS line for the SPI SD card on a different pin.

EDIT: The answer above is relevant to the Arduino ATMega328-based board, not ESP8266-based NodeMCU board. This answer is not relevant to ESP8266 or NodeMCU with regard to hardware I2C, as the ESP8266 does not have a dedicated hardware I2C peripheral.

2
  • I'm using ESP8266 (NodeMCU v3) and pin numbers for I2C is D1 & D2 (printed on the board). Man, this caused confusion to me. Thanks for the explanation.
    – JFetz2191
    Commented Feb 6, 2018 at 11:38
  • The NodeMCU docs say to use Pin 8 for SPI (SD Card) slave-select. Commented Feb 6, 2018 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.