NodeMCU based ESP8266 has Hardware SPI with four pins (D5 ~ D8 in the red square below) available for SPI communication. With this SPI interface, we can connect any SPI enabled device with NodeMCU and make communication possible with it.
ESP8266 has SPI pins (SD1, CMD, SD0, CLK) which are exclusively used for Quad-SPI communication with flash memory on ESP-12E, hence, they can’t be used for SPI applications (the pins in the blue square). We can use Hardware SPI interface for user end applications.
Below figure shows Quad SPI interface pins that are internally used for flash. It consists quad i/o (4-bit data bus) i.e. four (SDIO_DATA0 – SDIO_DATA3) bidirectional (i/p and o/p) data signals with synchronize clock (SDIO_CLK) and chip select pin (SDIO_CMD). It is mostly used to get more bandwidth/throughput than dual i/o (2-bit data bus) interface.
When connecting NodeMCU to other SPI devices, always use the hardware SPI pins (D5 ~ D8) and pay attention to the chip select pin used in the library.
Connect NodeMCU to Arduino Uno according to the pic below. Be sure to connect the GND.
Sketch for NodeMCU (Master)
Sketch for Arduino Uno (Slave)
Compile and upload the sketches to NodeMCU and Arduino Uno.
The output from Arduino Uno.
The output from NodeMCU.
NodeMCU SPI with Arduino IDE