I am designing a controller and driver for 4 greenhouse vents. There will be 4 controllers and drivers so that operation is completely independent. I plan to use an ESP32 for each controller. The drive will be a reversible 12 VDC motor driving a scissor stand. I will use a mechanical DPDT relay to control polarity to the motor for direction control. These are fairly large vents so the motor will probably be >2 A and maybe 5 A. There will also be 2 logic MOSFETs and 2 limit switches. My DPDT relays have 12 VDC coils, so I assume that 10-15 mA at 3.3v from the ESP32 GPIO won’t be enough to energize the coil, but should verify that. The problem that I have is I want to connect the limit switches to ESP32 GPIO input ports to signal when to cut power when the vent is fully open or fully closed. In my current design, the limit switches will carry 12 VDC and a lot of current which will fry the ESP32. So I need something to protect the input GPIO ports. I am looking for high level direction, not detail design.
I have attached a picture of my current schematic. Sorry, but I am a newbie.
Here is the process to open a vent.
- Disable GPIO 1 to insure that power to the motor is OFF.
- Disable GPIO 2 to set the OPEN polarity on the relay. Wait 100 msec.
- Disable GPIO 4
- Enable GPIO 3 to listen for connection.
- Enable GPIO 1 to turn on power to the motor.
- When the vent is fully open the OPEN limit switch should connect to trigger GPIO 3. Disable GPIO 1 to kill power to the motor.
Here are the steps to close the vent.
- Disable GPIO 1 to insure power to the motor is off.
- Enable GPIO 2 to set the CLOSE polarity on the relay. It uses a logic MOSFET to step the 3.3 v to 12v on the relay coil. Wait 100 msec for switch.
- Disable GPIO 3
- Enable GPIO 4 to listen for connection.
- Enable GPIO 1 to turn on power to motor.
- When the vent has closed, the CLOSE limit switch will connect and GPIO 4 should be signaled. Disable GPIO 1 to cut power to the motor.
I will also add some timeout and other error functions.
Since the limit switches are fed directly from the motor lines, they will switch 12 VDC. Should I add some kind of resistor to the limit switches because they will be a dead short on the 12 VDC line? How do I protect GPIO 3/4 from the 12 VDC and high current? Would a voltage regulator be enough? Maybe another MOSFET using the 12 VDC to switch 3.3v supplied by another power supply, not the ESP32? I need a 3.3v power supply for the ESP32 anyway. Or could I use 3.3v from the ESP32? Can I get a logic MOSFET that switches on 10 or 15 mA from an ESP32 GPIO? I need 2 GPIOs high at the same time to close the vent.
TIA!
