Shift Registers and...
 
Notifications
Clear all

Shift Registers and ESP32  

  RSS

KeithL
(@keith)
Active Member
Joined: 3 months ago
Posts: 8
2020-05-17 3:10 pm  

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.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE0);
  SPI.setClockDivider(SPI_CLOCK_DIV128);
  SPI.begin();   pinMode(SftLoadPin, OUTPUT);
  digitalWrite(SftLoadPin, HIGH); } void loop(){   digitalWrite(SftLoadPin, LOW);
  delay(5);
  digitalWrite(SftLoadPin, HIGH);
  SftRegisters = SPI.transfer(0x00); }

Quote
triform
(@triform)
Reputable Member
Joined: 11 months ago
Posts: 296
2020-05-18 3:54 am  

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. 


ReplyQuote
KeithL
(@keith)
Active Member
Joined: 3 months ago
Posts: 8
2020-05-25 4:27 pm  

@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.


ReplyQuote