Thanks. Sir. Unfortunately, these 45 Digital Outputs are to provide access to critical devices. They are entrance keys for each of multi-Unit Apartment room. Correct me if I am wrong, my understanding is Hardwired I/O is much more reliable as compared to Software I/O i.e. I2C, SPI, etc.
I don't think any human would notice the difference if you have something running on i2c or direct hardwired io, for entrance control by relay the i2c expansion will be fast enough.
Thanks Sir... It is not about speed that I am concerned, but the reliability. I just refer to my own experience when I was doing control system for power plant. It is a must that all CRITICAL I/O must be hardwires interface, while non-CRITICAL i.e. monitoring purpose only, can use software interface i.e. modbus, gsm, etc.
If you design a pcb with the esp and some IO expanders on it that's as hard-wired as you're ever going to get.
GSM is clearly a different story since it's over radio and subject to interference.
In any case the actuators in the system, the door locks, are always going to be physically distant / on a wire from the controller
You can use strapping pins just fine as long as you ensure their states are correct at boot. Also, you don't even need multiple ESP32's, since you can just use GPIO expanders connected via SPI or I2C, like e.g. the MCP23017 is a pretty popular one.
Btw, 34-39 can be used as input -- digital or analog, not just analog.
Thanks. Sir. I will look into the use of strapping pins then.
Unfortunately, these 45 Digital Outputs are to provide access to critical devices. They are entrance keys for each of multi-Unit Apartment room. Correct me if I am wrong, my understanding is Hardwired I/O is much more reliable as compared to Software I/O i.e. I2C, SPI, etc.
>Correct me if I am wrong, my understanding is Hardwired I/O is much more reliable as compared to Software I/O i.e. I2C, SPI, etc.
Uh, no. As long as you set everything up correctly and you size your wiring correctly, there is no reason why it'd be any more or less reliable.
Agreed. AND since each gpio is internally remappable to other specialized uses within the ESP chip, using a multiplex on the same pcb is possibly MORE reliable than trusting an Arduino library or HAL to organize 35 pins and map them in the ESP with internal registers that may constantly shift for reassignment based on someone's kludge code to expand versatility.
You can use strapping pins for other purposes. You need to make sure the input level is correct on reset, after that you can do whatever you like with them.
Are you using a 32kHz crystal? This is an unusual requirement, and the WROOM module doesn't include it. 32 and 33 are available otherwise.
34-39 would be good candidates for your 4 digital inputs.
Still, even if you use everything optimally, you won't have 45 GPIOs for those relays. Use a IO expander for them.
Thanks Sir.. I am not sure if mine is having that 32Khz crytal. I thought mine have it because based on the datasheet below on section 2.2 Pin Description. Correct me if I am wrong please.
As for IO expander, I am not sure if it is suitable for this project. I am doing Automatic key box, so i would need the most reliable digital output, which i think it should be hardwired I/O.
There's no reason why I2C should be unreliable in this environment, and an automatic key box isn't a life-threatening application. You're overthinking it. But if you're set on direct MCU GPIO connections then ESP32 is not an option for you.
Personally instead of using all of these GPIO for relay control, I would suggest just using a few shift registers. You only use 3 pins and use SPI to control it. Look into using 74hc595’s and you just daisy chain them together. I’ve used this method to control up to 90 relays with no problem.
Shift register is preferable to i2c “port expander” which is slower, vastly more expensive, and much more bug prone with the i2c peripheral programming.
Why not use an Arduino mega/giga with ethernet/WiFi?
https://store-usa.arduino.cc/products/giga-r1-wifi?gad_source=1&gclid=Cj0KCQjwsuSzBhCLARIsAIcdLm55j16hcSn100KeW5Un9Px1fLVaSHNLlM_O9uCqMiOZTTHXRIqAHLAaAnHVEALw_wcB
look into I2C I/O expanders like the MCP23017. Each of these can provide 16 additional GPIO pins, and you can chain multiple on the same I2C bus.
Thanks. Sir. Unfortunately, these 45 Digital Outputs are to provide access to critical devices. They are entrance keys for each of multi-Unit Apartment room. Correct me if I am wrong, my understanding is Hardwired I/O is much more reliable as compared to Software I/O i.e. I2C, SPI, etc.
I2C is not less reliable than a GPIO.
I don't think any human would notice the difference if you have something running on i2c or direct hardwired io, for entrance control by relay the i2c expansion will be fast enough.
Thanks Sir... It is not about speed that I am concerned, but the reliability. I just refer to my own experience when I was doing control system for power plant. It is a must that all CRITICAL I/O must be hardwires interface, while non-CRITICAL i.e. monitoring purpose only, can use software interface i.e. modbus, gsm, etc.
If you design a pcb with the esp and some IO expanders on it that's as hard-wired as you're ever going to get. GSM is clearly a different story since it's over radio and subject to interference. In any case the actuators in the system, the door locks, are always going to be physically distant / on a wire from the controller
Thanks Sir
Not a sir....
oh...:)
She’s a tortoise, obviously
You can use strapping pins just fine as long as you ensure their states are correct at boot. Also, you don't even need multiple ESP32's, since you can just use GPIO expanders connected via SPI or I2C, like e.g. the MCP23017 is a pretty popular one. Btw, 34-39 can be used as input -- digital or analog, not just analog.
Thanks. Sir. I will look into the use of strapping pins then. Unfortunately, these 45 Digital Outputs are to provide access to critical devices. They are entrance keys for each of multi-Unit Apartment room. Correct me if I am wrong, my understanding is Hardwired I/O is much more reliable as compared to Software I/O i.e. I2C, SPI, etc.
>Correct me if I am wrong, my understanding is Hardwired I/O is much more reliable as compared to Software I/O i.e. I2C, SPI, etc. Uh, no. As long as you set everything up correctly and you size your wiring correctly, there is no reason why it'd be any more or less reliable.
Thanks WereCatf
Agreed. AND since each gpio is internally remappable to other specialized uses within the ESP chip, using a multiplex on the same pcb is possibly MORE reliable than trusting an Arduino library or HAL to organize 35 pins and map them in the ESP with internal registers that may constantly shift for reassignment based on someone's kludge code to expand versatility.
I2C is hardwired. You don’t want to have long i2c or SPI traces but using an output expander basically gives you output pins
Thanks [thisdude415](https://www.reddit.com/user/thisdude415/)
You can use strapping pins for other purposes. You need to make sure the input level is correct on reset, after that you can do whatever you like with them. Are you using a 32kHz crystal? This is an unusual requirement, and the WROOM module doesn't include it. 32 and 33 are available otherwise. 34-39 would be good candidates for your 4 digital inputs. Still, even if you use everything optimally, you won't have 45 GPIOs for those relays. Use a IO expander for them.
Thanks Sir.. I am not sure if mine is having that 32Khz crytal. I thought mine have it because based on the datasheet below on section 2.2 Pin Description. Correct me if I am wrong please. As for IO expander, I am not sure if it is suitable for this project. I am doing Automatic key box, so i would need the most reliable digital output, which i think it should be hardwired I/O.
There's no reason why I2C should be unreliable in this environment, and an automatic key box isn't a life-threatening application. You're overthinking it. But if you're set on direct MCU GPIO connections then ESP32 is not an option for you.
Personally instead of using all of these GPIO for relay control, I would suggest just using a few shift registers. You only use 3 pins and use SPI to control it. Look into using 74hc595’s and you just daisy chain them together. I’ve used this method to control up to 90 relays with no problem.
Shift register is preferable to i2c “port expander” which is slower, vastly more expensive, and much more bug prone with the i2c peripheral programming.
Yep. Way cheaper and more reliable, as well as scalable. Used this method a number of times on commercial products.
Thanks [soopadickman](https://www.reddit.com/user/soopadickman/). I will look into Shift register option then.
Of you need critical control, use a PLC
Why not use an Arduino mega/giga with ethernet/WiFi? https://store-usa.arduino.cc/products/giga-r1-wifi?gad_source=1&gclid=Cj0KCQjwsuSzBhCLARIsAIcdLm55j16hcSn100KeW5Un9Px1fLVaSHNLlM_O9uCqMiOZTTHXRIqAHLAaAnHVEALw_wcB