Converting from ESP8266 to ESP32

Hi everyone! I’m totally new to ESPHome and circuit boards in general, but I’m doing my best to read through and understand what I’m working with.

I’m trying to implement the following project:

Of course, when I was going to purchase an ESP, I read that the ESP32 was the newer version than the ESP8266 that was used in the project - so I decided to purchase that instead. Totally not realizing that with a new board came new pinouts…

I’ve been researching this and trying to take a crash course in arduino/ESP, and I think I might be close? I’m still waiting for my duponts to arrive to confirm it. From my research, the ESP8266 uses certain pins for certain functions. The four we need to map from the github project are:

GND - Ground
D5 - GPIO14 / SCLK (Slave Clock - but we have this mapped to TX for transmit.
D6 - GPIO12 - MISO (Master in, slave out - which I read as communication from the slave device to the ESP, we have this mapped to RX for Receive, so I think we’re good here.)
D2 - GPIO4 - SDA (Serial Data Pin, where communication is sent back and forth between the devices)

** using this reference: ESP8266 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

From my research, you can set (certain) GPIO pins to be whatever you want. I think I need to add the following to my yaml file for ESPHome to match the original ESP8226 config?

spi:
  clk_pin: GPIO14
  mosi_pin: GPIO13
  miso_pin: GPIO12

uart:
  id: desk_uart
  baud_rate: 9600
  tx_pin: GPIO14 
  rx_pin: GPIO12

And then I need to set an SDA pin.

i2c:
  sda: 21
  scl: 22
  scan: True
  id: bus_a

This should set the sda to GPIO21. I’d then replace this in the LoctekMotion_IoT/packages/esphome/flexispot_ek5.yaml at 953168b81d6fbc4c019025d930b0a8374f511b17 · iMicknl/LoctekMotion_IoT · GitHub where D2 is listed.

...
switch:
  - platform: gpio
    name: "Virtual Screen"
    pin:
      number: GPIO21
      i2c_id: bus_a # Don't know if I need to define this here...
      mode: OUTPUT
    restore_mode: ALWAYS_OFF
    internal: true
...

Could I get some feedback if I’m on the right track? Should I be using GPIO18 and GPIO19 instead of setting up an spi?

Thanks in advance!

1 Like

There is a similar reference for esp32s ESP32 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

Yes, that and some videos are what I used to figure out the above mapping. :slight_smile: Gonna give it a shot tonight and will report back.