What is the maximum number of relays you could control using a NodeMCU ESP8266 running ESPHome?

I’m very new to using arduino, and I’ve only just started tinkering with ESPhome. I’m looking to use a NodeMCU running ESPHome to control the many things I have on my desk like monitor, audio, lights, etc.

So if I may just get to my question, how many relays could I control using one NodeMCU ESP8266 board? I count a total of 9 “D” pins (from D0-D8), so is it correct for me to assume that I can control up to 9 relays?

Also, on the ESPhome website I read that you can use A0 as an output pin, so does that mean I could also use it to control a relay for a total of 10 relays on a single NodeMCU board?

No. Check the pinout table and use caveats on this page:

No that is incorrect.

If you want more I/O use an ESP32. They are not much more expensive and are available in the same size as the Wemos D1 mini

https://www.aliexpress.com/item/32819907815.html

Reference for the ESP32 gpio:

1 Like

Or you could use I2C controlled relays. Surely there are cheaper ones available since this one is stupidly expensive

Cheaper option using a standard relay board and a I2C controller:
https://www.iascaled.com/store/I2C-RELAY16

Those were just random searches, best to look for something better / cheaper etc.

If you are using ESPhome, go to the ESPHome web site and look in Misc Components for supported I/O expanders.

Thanks everyone for the suggestions! Since I’m planning to control relays and the NodeMCU practically only has GPIO4 and GPIO5 to control relays with, I’m going to be using I2C GPIO expanders like the PCF857x or MCP230xx.

Good choice but this is not true:

The ESP8266 has 5 outputs you can use unreservedly. The ESP32 has 14.