Porting basic code to ESP32

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

Porting basic code to ESP32

Postby TCC-ESP32 » Thu May 21, 2020 11:45 am

I have a small sketch I would like to port to the ESP32, but I can't get it to work.
The Arduino sketch and partially modified ESP32 sketch are here: https://github.com/Account-Git/Arduino-to-ESP32
Please, can anyone help?

Something so simple shouldn't be this difficult. :(

rin67630
Posts: 75
Joined: Sun Mar 11, 2018 5:13 pm

Re: Porting basic code to ESP32

Postby rin67630 » Fri May 22, 2020 9:36 am

My glass ball needs a repair.

Please define "can't get it to work".
What did you do?
What did you expect?
What did you get instead?

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

Re: Porting basic code to ESP32

Postby TCC-ESP32 » Fri May 22, 2020 11:07 am

Sorry, yes I should have made myself more clear.

First, I took my original, working, Arduino sketch (as shown on GitHub).
Then, I changed the pin numbers to match the GPIO pins on the ESP32. I also changed the baud rate for the Serial monitor.
And that's all I did.

I was hoping (expecting) to get the same results as I did with the Arduino.
i.e. When one of the inputs on the 74HC165 goes high the microcontroller receives a 1 on that bit, or a 0 if it goes low.

What I got instead was either one 0 instead of eight bits, or eight 1s, and sometimes just a load of rubbish (2 bits, 4bits, 5bits, etc).

It seems that the SPI setup is way off somewhere, but I am new to ESP32 and don't know how to set it up for this type of application despite it appearing very simple at the outset.

mrburnette
Posts: 7
Joined: Mon Feb 12, 2018 6:50 pm

Re: Porting basic code to ESP32

Postby mrburnette » Sat May 23, 2020 10:32 pm

TCC-ESP32 wrote:
Thu May 21, 2020 11:45 am
...
Something so simple shouldn't be this difficult. :(
I have not examined your code, but generally the biggest porting issue from Arduino (UNO, Mega, Nano, Micro) and ESP32 is that AVR 8-bit uC has int defined as 16-bits and int on ESP32 is 32-bit.

Good luck.

Ray

Who is online

Users browsing this forum: Bing [Bot] and 7 guests