Convert Arduino SPI to ESP32

TCC-ESP32
Posts: 9
Joined: Wed May 13, 2020 12:32 pm

Convert Arduino SPI to ESP32

Postby TCC-ESP32 » 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:

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

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: Convert Arduino SPI to ESP32

Postby ESP_Sprite » Thu May 14, 2020 7:44 am

Moving to the Arduino subforum

Who is online

Users browsing this forum: No registered users and 67 guests