Convert Arduino SPI to ESP32
Posted: Wed May 13, 2020 1:03 pm
I have an Arduino project that I am trying to convert to run on an ESP32.
My project receives data from a 74HC165 shift register via SPI.
I have purchased a NodeMCU-32S board and connected my project as follows:
GPIO Pin 19 - Connects to Pin 9 (QH) of the shift register
GPIO Pin 18 - Connects to Pin 2 (CE [Clock Enable]) of the shift register
GPIO Pin 5 - Connects to Pin 1 (PL [Parallel Load]) of the shift register
This is the SPI code I am using:
I have not modified this code from the Arduino project. I have only changed the pin numbers.
The code is receiving data from the shift register, just not correctly.
I know that this code needs to be converted to run on the ESP32, I just don't know where to start.
Any help would be appreciated.
My project receives data from a 74HC165 shift register via SPI.
I have purchased a NodeMCU-32S board and connected my project as follows:
GPIO Pin 19 - Connects to Pin 9 (QH) of the shift register
GPIO Pin 18 - Connects to Pin 2 (CE [Clock Enable]) of the shift register
GPIO Pin 5 - Connects to Pin 1 (PL [Parallel Load]) of the shift register
This is the SPI code I am using:
Code: Select all
#include <SPI.h>
const int SftLoadPin = 5;
//setup
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
SPI.setClockDivider(SPI_CLOCK_DIV128);
SPI.begin();
pinMode(SftLoadPin, OUTPUT);
digitalWrite(SftLoadPin, HIGH);
//loop
digitalWrite(SftLoadPin, LOW);
delay(5);
digitalWrite(SftLoadPin, HIGH);
The code is receiving data from the shift register, just not correctly.
I know that this code needs to be converted to run on the ESP32, I just don't know where to start.
Any help would be appreciated.