ESP-12 + Relay board - can I flash it to ESPHome?

I don’t have one, I asked the seller on eBay about it but they don’t have one either. Sorry, should have made that clear.

I posted a picture of the PCB on the bottom of my post, but I’m having a hard time tracing the connections.

Use continuity tester and check if GPIO4 and GPIO5 beeps at contacts SDA and SCL. It shouldn’t be that hard… you don’t really need schematic for this since you only need to find those two pins, correct?

When you find those two connections it shouldn’t be any problem running with esphome. I didn’t explore much but it could be that you’ll have to define addresses, since you have two chips on board, if i see correct.

1 Like

Good point to check for continuity. But is it really necessary if I am only flashing the ESP-12 and then soldering it back in its original position? The connections from ESP to i/o expander remain the same, SDA and SCL from i/o should go to GPIO 5 and GPIO 4 of ESP, then I just define the connection in ESPHome, right? I see no other way of connecting it.

The other chip on the back of the board is a voltage regulator.

I just wanted to make sure I’m not missing anything before I start to take apart and potentially ruining a working product.

I would socket it. But why unsolder it at all? Just solder some small wires to the back side of the board to connect to an FTDI.

1 Like

Ok, i asked because there are two 18-pin chips on board, at least on one from your link…

You don’t need to remove nothing - continuity test can be done with all chips and modules inserted, you won’t destroy anything.

1 Like

I am not sure why you assume gpio 4 & 5 are for i2c. Sure that is common, but not necessary. See ESP8266 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

The ESP8266 doens’t have hardware I2C pins, but it can be implemented in software. So you can use any GPIOs as I2C. Usually, the following GPIOs are used as I2C pins:

  • GPIO5: SCL
  • GPIO4: SDA

Are you sure your board uses PCF8575 expanders ??

The only reference I can find on a board that looks the same uses ULN2803 relay drivers though none of the images I have seen are clear enough to read the chip ID.

OK, found an image of the real (?) Sainsmart board and it has relay drivers.

Aha… those two chips i asked about are ULN drivers… ok, in this case PCF is probably at the bottom of PCB

1 Like

I was wondering if that was possible, didn’t want to risk anything and thought it would be the safer option to take out the board before anything. But thanks so much! That makes it a lot easier.

I can’t find my FTDI converter and I tried flashing it with a nodemcu, but I can’t get it to work. I followed "Brian Lough"s video on youtube with both 100uF and 10uF capacitors but the led on the ESP12 doesn’t blink. So I will be waiting for the new FTDI converter.

Did you remove esp board and checked that chip at the bottom side is indeed pcf8575? Just to be sure…

I see that on esp module there are pins 3V3, G, T, R, 0 and 2. It’s all you need for flashing. Solder wires to pins G, T, R and 0. Connect: pin G to FTDI ground, pin T to pin Rx and pin R to pin Tx of FTDI. Hold pin 0 to GND while powering the board (use power supply 12V or 5V on blue connector). That way you’ll enter programming mode.
If you didn’t find sda/scl pins with beeper then some trial/error will be needed… you can’t burn anything by trying… but i’d still rather find them. Scl pins on PCF8575 is pin 22 and sda is pin 23 (on ssop casing). You can find esp01 pinout on google to see where gpio4 and 5 are. Then just “beep” them to check out.

1 Like

It was not necessary to remove the ESP12, the pcb module had two sides it was on the opposite side of the ESP. I got the FTDI converter now, but I must have ruined the ESP12 module while trying to flash it with the nodemcu because the it won’t flash and the led on it is dead.

Luckily I ordered a PCF8575TS module at the same time. I hooked the relay board up to 5V 2a power supply, and powered the nodemcu and pcf module off the relay board.
1 issue I’m having is that the i2c address of the pcf module keeps changing, I thought it was supposed to be 0x20 but I’m getting 0x21-0x25. There are solder pads under the pcf module (a0-a1-a2) but I’m not sure what the address should be set to? I can change state of individual relays for a minute before the address of the pcf changes.
2 issue is that after connecting more than 10 relays it seems to stop connecting all together, I can’t switch state on any relay suddenly, this seems like a power supply issue to me but shouldn’t 2a be enough for this application?

Thanks for the help guys! I didn’t want to start a new thread as it’s kind of the same subject but someone let me know if I’m wrong

It doesn’t really matter which address you have set if you have only one module. The main point is that A0-A1-A2 must be polarized: either tied to GND or to +Vcc, so make sure you have that - either directly or via resistor.
2A should be more than enough for more than 10 relays, i agree. Try to measure voltage when energizing relays to see if it drops…that should indicate….bad supply…?

1 Like

I tried soldering A1-A2 pads first and now A0-A1-A3 but the voltage regulator on the PCF8575 module is burning up now. Which pads am I supposed to solder exactly?

Here is a look on the back of the PCF8575 module.

Edit: Also I forgot to mention about 2 seconds after power up all leds on relay dim and the relay board starts making a constant low volume buzzing noise.

From pics i see that neither of address pins are connected to anything, that’s why address floats. For each address pin: solder either left and center, or right and center pad. Left pads are +Vcc, right pads are GND, center pads are chip inputs. Just don’t connect all three together!

1 Like

Thanks so much for the great help Pavel! My bad I rushed it a bit, now I connected the center and right pads and got 0x20 address and its not floating anymore.

1 Like

hey did you ever got it working with original esp module ? got the same board and struggling to get esp working with relays :frowning:

No, because I think the original esp module that came with the board was defective.
Instead I connected to the board with an Esp8266 and i/o expander. It’s the same concept if you get to flash the original module.
Check out documentation for PCF8574 on esphome.io

Hope that helps :slight_smile:

thanks for your anwser, yeah i can flash original module no problem,
tried :slight_smile:

i2c:

- id: i2c_1

  scan: true

  scl: GPIO5

  sda: GPIO4

pcf8574:

- address: '0x21'

  id: pcf8575_1

  pcf8575: true

switch:

  - platform: gpio

    name: "relay 1"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 0

      number: 0

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 2"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 1

      number: 1

      mode:

        output: true

      inverted: false

but still no luck, any chance you can review above and let me knowq what i am doing wrong ?:slight_smile:

Please read the instructions for posting at the top of each forum and edit your post to correctly display the code. The forum editor doesn’t keep the sketch formatting without code tags which makes it unreadable. If you post your code in code tags, more forum members will read it.

managed to get it working, leaving the config in case anyone ever stumbles across this page facing the same issue:

esphome:
  name: relay-x16

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxx"

ota:
  password: "xxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Relay-X16 Fallback Hotspot"
    password: "xxx"

captive_portal:

web_server:
  port: 80

i2c:

- id: i2c_1

  scan: true

  scl: GPIO5

  sda: GPIO4

pcf8574:

- address: '0x27'

  id: pcf8575_1

  pcf8575: true

switch:

  - platform: gpio

    name: "relay 1"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 0

      number: 0

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 2"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 1

      number: 1

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 3"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 2

      number: 2

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 4"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 3

      number: 3

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 5"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 4

      number: 4

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 6"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 5

      number: 5

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 7"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 6

      number: 6

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 8"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 7

      number: 7

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 9"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 8

      number: 8

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 10"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 9

      number: 9

      mode:

        output: true

      inverted: false


  - platform: gpio

    name: "relay 11"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 10

      number: 10

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 12"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 11

      number: 11

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 13"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 12

      number: 12

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 14"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 13

      number: 13

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 15"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 14

      number: 14

      mode:

        output: true

      inverted: false

  - platform: gpio

    name: "relay 16"

    pin:

      pcf8574: pcf8575_1

      # Use pin number 15

      number: 15

      mode:

        output: true

      inverted: false
1 Like