T O P

  • By -

wtfsheep

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.


joey_speedy

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.


CheddaSon

I2C is not less reliable than a GPIO.


HamwiseTheOrange

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.


joey_speedy

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.


MissTortoise

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


joey_speedy

Thanks Sir


MissTortoise

Not a sir....


joey_speedy

oh...:)


ErgonomicZero

She’s a tortoise, obviously


WereCatf

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.


joey_speedy

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.


WereCatf

>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.


joey_speedy

Thanks WereCatf


wires_and_code

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.


thisdude415

I2C is hardwired. You don’t want to have long i2c or SPI traces but using an output expander basically gives you output pins


joey_speedy

Thanks [thisdude415](https://www.reddit.com/user/thisdude415/)


LegitimateNebula5991

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.


joey_speedy

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.


LegitimateNebula5991

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. 


soopadickman

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.


marchingbandd

Shift register is preferable to i2c “port expander” which is slower, vastly more expensive, and much more bug prone with the i2c peripheral programming.


soopadickman

Yep. Way cheaper and more reliable, as well as scalable. Used this method a number of times on commercial products.


joey_speedy

Thanks [soopadickman](https://www.reddit.com/user/soopadickman/). I will look into Shift register option then.


evillarreal86

Of you need critical control, use a PLC


bcell4u

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