Shift Registers and...
Clear all

Shift Registers and ESP32

3 Posts
2 Users
0 Reactions
Joined: 4 years ago
Posts: 10
Topic starter  

Does anyone know how to get shift registers working with an ESP32?

I am trying to upgrade my project from an Arduino Pro Mini to an ESP32 but can't get the shift registers to work.

On the Arduino, I was using SPI to connect the 74HC165, but on the ESP32 I can't get that to work.

I then decided to have a go at connecting the shift registers to the ESP through regular GPIO pins, as in the Shift Register video and article on the DBW. However, I can't get that method to work on the ESP32 either.

I'm sure it shouldn't be this difficult, but I have trawled the Internet and tried a few examples relating to SPI and couldn't get any of them to work.

This is my original Arduino code (that works fine)

#include <SPI.h>
const int SftLoadPin = 5;
byte SftRegisters;
void setup(){
  SPI.begin();   pinMode(SftLoadPin, OUTPUT);
  digitalWrite(SftLoadPin, HIGH); } void loop(){   digitalWrite(SftLoadPin, LOW);
  digitalWrite(SftLoadPin, HIGH);
  SftRegisters = SPI.transfer(0x00); }

Joined: 5 years ago
Posts: 324

I know on the ESP I have issues with some devices especially if the device is being clocked or PWMed.  I know the mx1508 motor driver does not respond to the ESP signals (PWM or HI/LOW), but the L9110 driver works fine with it.  I know on some relays, I have had to use a transistor or logic converter, but in these cases that would no work.  You could try a 595 and add code for the latch, but I would suspect the same issue.  You may want to try a newer i2c I/O expander like the PCF8575.  That one is fairly easy to work without extra bloat libraries. 

Joined: 4 years ago
Posts: 10
Topic starter  

@triform, thanks for the info.

That may be worth considering in the future, but for this project, the hardware is already in place and can't readily be modified so I really need to get the shift registers working.

I can see this being a problem for many people in the future, people who have made projects with shift registers to expand I/O and who want to upgrade to the ESP32, probably for memory reasons like I have.