Community project

MediNow

Photo of MediNow
Generated with AI

Ahren Arcangel

Published November 23, 2026

MediNow is an automated medication dispensing system built around an ESP32-S3 with a 7-inch touchscreen interface. The system uses stepper motors controlled via WiFi to dispense medications on schedule, with environmental monitoring via DHT22 temperature/humidity sensor, RFID card reader for user authentication, and infrared break-beam sensors to detect dispensing completion.

This guide provides a complete wiring diagram, parts list, and step-by-step assembly instructions for building the MediNow dispenser. The firmware enables WiFi-based motor control, touchscreen interaction for scheduling and status display, and sensor integration for reliable operation. Assembly focuses on properly wiring the eight stepper motors, configuring the fan cooling system, and testing all sensors before mechanical integration.

Wiring diagram

Loading diagram…

Gather all the parts

QtyComponent
1

Waveshare ESP32-S3-Touch-LCD-7B

USB-powered touch panel; communicates with the motor board over Wi-Fi.

1

ULN2003 Stepper Motor Driver Module

OpenCircuit item 10033 ULN2003AN driver module. IN1–IN4 are four digital control inputs; + and - accept a 5–12 VDC motor supply; the five-position motor connector is treated as one connector because the official source does not establish individual contact order.

1

28BYJ-48 Stepper Motor

SparkFun ROB-19515 is a four-phase 5 V 28BYJ-48 geared stepper motor with a 1/64 speed ratio and a five-wire JST XHP-5 harness. The motor is modelled separately from its driver board.

1

12V Barrel-Jack Adapter

12 V / 2 A wall adapter with a 5.5 mm / 2.1 mm barrel jack. Used to power motor drivers, LED strips, or boards that need a higher rail.

1

DHT22

Digital temperature and humidity sensor

1

MFRC522 RFID Module

13.56 MHz RFID reader/writer module based on the NXP MFRC522 IC. Communicates over SPI and is commonly sold as an RC522 breakout with an onboard antenna.

1

AO3400A

30V 5.7A N-channel enhancement-mode logic-level MOSFET in SOT-23-3L. Vgs(th) typically ~0.7V (max 1.45V at Id=250 uA), fully enhanced at Vgs=2.5V-4.5V. RDS(on) ~26 mOhm at Vgs=4.5V, ~38 mOhm at Vgs=2.5V. Driven directly by 3.3V or 5V microcontroller GPIO/PWM as a low-side switch for loads up to its Id and VDS limits. No firmware library required.

1

1N4007 Diode

General-purpose silicon rectifier diode in DO-204AL (DO-41) axial through-hole package. Rated 1A average forward current and 1000V peak reverse voltage (VRRM). Forward voltage drop ~0.7V at typical load (up to 1.1V at full 1A). Used here in series with LM7805 Vout for reverse polarity protection: anode to LM7805 output, cathode to 5V rail, resulting in ~4.3V on the output rail. Not suitable for high-frequency switching (reverse recovery ~2µs–30µs); intended for DC or 50/60Hz rectification only.

1

12 V two-wire DC exhaust fan

External module with the interface specified in its name.

1

3.3 V IR break-beam pair with open-collector receiver

External module with the interface specified in its name.

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

4.7 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

100 Ω

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Regulated 5 V 4 A enclosed DC adapter

Separate motor supply; use a rated fused distribution harness.

1

28BYJ-48 Stepper Motor

SparkFun ROB-19515 is a four-phase 5 V 28BYJ-48 geared stepper motor with a 1/64 speed ratio and a five-wire JST XHP-5 harness. The motor is modelled separately from its driver board.

1

ULN2003 Stepper Motor Driver Module

OpenCircuit item 10033 ULN2003AN driver module. IN1–IN4 are four digital control inputs; + and - accept a 5–12 VDC motor supply; the five-position motor connector is treated as one connector because the official source does not establish individual contact order.

1

28BYJ-48 Stepper Motor

SparkFun ROB-19515 is a four-phase 5 V 28BYJ-48 geared stepper motor with a 1/64 speed ratio and a five-wire JST XHP-5 harness. The motor is modelled separately from its driver board.

1

ULN2003 Stepper Motor Driver Module

OpenCircuit item 10033 ULN2003AN driver module. IN1–IN4 are four digital control inputs; + and - accept a 5–12 VDC motor supply; the five-position motor connector is treated as one connector because the official source does not establish individual contact order.

1

28BYJ-48 Stepper Motor

SparkFun ROB-19515 is a four-phase 5 V 28BYJ-48 geared stepper motor with a 1/64 speed ratio and a five-wire JST XHP-5 harness. The motor is modelled separately from its driver board.

1

ULN2003 Stepper Motor Driver Module

OpenCircuit item 10033 ULN2003AN driver module. IN1–IN4 are four digital control inputs; + and - accept a 5–12 VDC motor supply; the five-position motor connector is treated as one connector because the official source does not establish individual contact order.

1

28BYJ-48 Stepper Motor

SparkFun ROB-19515 is a four-phase 5 V 28BYJ-48 geared stepper motor with a 1/64 speed ratio and a five-wire JST XHP-5 harness. The motor is modelled separately from its driver board.

1

ULN2003 Stepper Motor Driver Module

OpenCircuit item 10033 ULN2003AN driver module. IN1–IN4 are four digital control inputs; + and - accept a 5–12 VDC motor supply; the five-position motor connector is treated as one connector because the official source does not establish individual contact order.

1

28BYJ-48 Stepper Motor

SparkFun ROB-19515 is a four-phase 5 V 28BYJ-48 geared stepper motor with a 1/64 speed ratio and a five-wire JST XHP-5 harness. The motor is modelled separately from its driver board.

1

ULN2003 Stepper Motor Driver Module

OpenCircuit item 10033 ULN2003AN driver module. IN1–IN4 are four digital control inputs; + and - accept a 5–12 VDC motor supply; the five-position motor connector is treated as one connector because the official source does not establish individual contact order.

1

28BYJ-48 Stepper Motor

SparkFun ROB-19515 is a four-phase 5 V 28BYJ-48 geared stepper motor with a 1/64 speed ratio and a five-wire JST XHP-5 harness. The motor is modelled separately from its driver board.

1

ULN2003 Stepper Motor Driver Module

OpenCircuit item 10033 ULN2003AN driver module. IN1–IN4 are four digital control inputs; + and - accept a 5–12 VDC motor supply; the five-position motor connector is treated as one connector because the official source does not establish individual contact order.

1

28BYJ-48 Stepper Motor

SparkFun ROB-19515 is a four-phase 5 V 28BYJ-48 geared stepper motor with a 1/64 speed ratio and a five-wire JST XHP-5 harness. The motor is modelled separately from its driver board.

1

ULN2003 Stepper Motor Driver Module

OpenCircuit item 10033 ULN2003AN driver module. IN1–IN4 are four digital control inputs; + and - accept a 5–12 VDC motor supply; the five-position motor connector is treated as one connector because the official source does not establish individual contact order.

1

AO3400A

30V 5.7A N-channel enhancement-mode logic-level MOSFET in SOT-23-3L. Vgs(th) typically ~0.7V (max 1.45V at Id=250 uA), fully enhanced at Vgs=2.5V-4.5V. RDS(on) ~26 mOhm at Vgs=4.5V, ~38 mOhm at Vgs=2.5V. Driven directly by 3.3V or 5V microcontroller GPIO/PWM as a low-side switch for loads up to its Id and VDS limits. No firmware library required.

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

100 Ω

Through-hole resistor (current-limiting in series with an LED)

1

TI SN74HCT595N

5 V shift register with TTL input thresholds; do not substitute 74HC595.

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Ceramic Capacitor

100 nF

Through-hole ceramic capacitor bought by value, such as 22 pF, 10 nF or 100 nF (0.1 µF). It is non-polarised, so either lead can go to either net. Its most common job is decoupling: a 100 nF capacitor between an IC's supply pin and ground, placed as close to the chip as possible.

1

TI SN74HCT595N

5 V shift register with TTL input thresholds; do not substitute 74HC595.

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Ceramic Capacitor

100 nF

Through-hole ceramic capacitor bought by value, such as 22 pF, 10 nF or 100 nF (0.1 µF). It is non-polarised, so either lead can go to either net. Its most common job is decoupling: a 100 nF capacitor between an IC's supply pin and ground, placed as close to the chip as possible.

1

TI SN74HCT595N

5 V shift register with TTL input thresholds; do not substitute 74HC595.

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Ceramic Capacitor

100 nF

Through-hole ceramic capacitor bought by value, such as 22 pF, 10 nF or 100 nF (0.1 µF). It is non-polarised, so either lead can go to either net. Its most common job is decoupling: a 100 nF capacitor between an IC's supply pin and ground, placed as close to the chip as possible.

1

TI SN74HCT595N

5 V shift register with TTL input thresholds; do not substitute 74HC595.

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

47 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Ceramic Capacitor

100 nF

Through-hole ceramic capacitor bought by value, such as 22 pF, 10 nF or 100 nF (0.1 µF). It is non-polarised, so either lead can go to either net. Its most common job is decoupling: a 100 nF capacitor between an IC's supply pin and ground, placed as close to the chip as possible.

Assemble it in 3 steps

1. Wire the eight motors with power off

The pictured breakout is optional and only repeats the ESP32 pins. Leave its barrel jack unused. Use four SN74HCT595N chips and eight ULN2003 modules. In DIP pin order, QB through QH are pins 1–7, GND is 8, QHprime is 9, SRCLR is 10, SRCLK is 11, RCLK is 12, OE is 13, SER is 14, QA is 15, and VCC is 16. Match the wiring view, including every pull-down and the 100 nF capacitor next to each chip. With power off, connect the separate 5 V adapter to the drivers and registers using rated fused distribution wiring. Tie both adapter negatives and ESP32 ground together. Do not route motor power through the breakout or ESP32.

2. Wire the fan switch and sensors

Use a two-wire 12 V DC fan. Connect fan positive to 12 V and negative to the MOSFET drain. Install the diode across the fan with its striped end at 12 V. Use a mounted AO3400A and verify the fan startup current is within the supply and switch ratings. Use only a 3.3 V open-collector beam receiver with this wiring. RC522 SDA is the SPI select pin, not I2C data. Follow the wiring view for all connections.

3. Test without a mechanical load

Use USB for both ESP32 boards. Deploy motor firmware to the N16R8 and display firmware to the 7B using include/role.h. After USB firmware starts, turn on motor power. Tap A–H to select motors 1–8 and hold JOG to test each uncoupled motor separately. Open the motor board serial monitor at 115200 to check sensor readings, drops and card IDs.

  • On-screen STOP is not an emergency stop. There are no travel limits, and motor holding torque is released on stop.

Review all connections

1. Connections between "motor" and "ESP32"

FunctionmotorESP32
connectorMOTOR_PLUG → ULN2003 Stepper Motor Driver Module Motor connectorEXT

2. Connections between "supply" and "ESP32"

FunctionsupplyESP32
power+12V12V
groundGNDGND

3. Connections between "driver" and "ESP32"

FunctiondriverESP32
power+5V
ground-GND

4. Connections between "fan" and "ESP32"

FunctionfanESP32
powerPLUS12V
powerMINUS → AO3400A Drain (D)EXT

5. Connections between "diode" and "ESP32"

FunctiondiodeESP32
powerCathode12V
powerAnode → AO3400A Drain (D)EXT

6. Connections between "fet" and "ESP32"

FunctionfetESP32
groundSource (S)GND

7. Connections between "dht" and "ESP32"

FunctiondhtESP32
dataDATAGPIO 9
powerVCC3V3
groundGNDGND

8. Connections between "beam" and "ESP32"

FunctionbeamESP32
digitalOUTGPIO 10
powerTX_VCC3V3
powerRX_VCC3V3
groundTX_GNDGND
groundRX_GNDGND

9. Connections between "bias1" and "ESP32"

Functionbias1ESP32
groundP2GND
digitalP1 → TI SN74HCT595N SEREXT
groundP2GND

10. Connections between "bias2" and "ESP32"

Functionbias2ESP32
groundP2GND
digitalP1 → TI SN74HCT595N SRCLKEXT
groundP2GND

11. Connections between "bias3" and "ESP32"

Functionbias3ESP32
groundP2GND
digitalP1 → TI SN74HCT595N RCLKEXT
groundP2GND

12. Connections between "rfid" and "ESP32"

FunctionrfidESP32
powerVCC3V3
groundGNDGND
spiSCKGPIO 12
spiMOSIGPIO 11
spiMISOGPIO 13
spiSDAGPIO 14
digitalRSTGPIO 15

13. Connections between "dhtpull" and "ESP32"

FunctiondhtpullESP32
digitalP1 → DHT22 DATAEXT
powerP23V3

14. Connections between "beampull" and "ESP32"

FunctionbeampullESP32
digitalP1 → 3.3 V IR break-beam pair with open-collector receiver OUTEXT
powerP23V3

15. Connections between "gate" and "ESP32"

FunctiongateESP32
digitalP1GPIO 16
digitalP2 → AO3400A Gate (G)EXT

16. Connections between "gateoff" and "ESP32"

FunctiongateoffESP32
digitalP1 → AO3400A Gate (G)EXT
groundP2GND

17. Connections between "motorSupply" and "ESP32"

FunctionmotorSupplyESP32
power+5V5V
groundGNDGND

18. Connections between "motor2" and "ESP32"

Functionmotor2ESP32
connectorMOTOR_PLUG → ULN2003 Stepper Motor Driver Module Motor connectorEXT

19. Connections between "driver2" and "ESP32"

Functiondriver2ESP32
power+5V
ground-GND

20. Connections between "motor3" and "ESP32"

Functionmotor3ESP32
connectorMOTOR_PLUG → ULN2003 Stepper Motor Driver Module Motor connectorEXT

21. Connections between "driver3" and "ESP32"

Functiondriver3ESP32
power+5V
ground-GND

22. Connections between "motor4" and "ESP32"

Functionmotor4ESP32
connectorMOTOR_PLUG → ULN2003 Stepper Motor Driver Module Motor connectorEXT

23. Connections between "driver4" and "ESP32"

Functiondriver4ESP32
power+5V
ground-GND

24. Connections between "motor5" and "ESP32"

Functionmotor5ESP32
connectorMOTOR_PLUG → ULN2003 Stepper Motor Driver Module Motor connectorEXT

25. Connections between "driver5" and "ESP32"

Functiondriver5ESP32
power+5V
ground-GND

26. Connections between "motor6" and "ESP32"

Functionmotor6ESP32
connectorMOTOR_PLUG → ULN2003 Stepper Motor Driver Module Motor connectorEXT

27. Connections between "driver6" and "ESP32"

Functiondriver6ESP32
power+5V
ground-GND

28. Connections between "motor7" and "ESP32"

Functionmotor7ESP32
connectorMOTOR_PLUG → ULN2003 Stepper Motor Driver Module Motor connectorEXT

29. Connections between "driver7" and "ESP32"

Functiondriver7ESP32
power+5V
ground-GND

30. Connections between "motor8" and "ESP32"

Functionmotor8ESP32
connectorMOTOR_PLUG → ULN2003 Stepper Motor Driver Module Motor connectorEXT

31. Connections between "driver8" and "ESP32"

Functiondriver8ESP32
power+5V
ground-GND

32. Connections between "enableFet" and "ESP32"

FunctionenableFetESP32
groundSource (S)GND

33. Connections between "enableUp" and "ESP32"

FunctionenableUpESP32
powerP15V
digitalP2 → AO3400A Drain (D)EXT

34. Connections between "enableDown" and "ESP32"

FunctionenableDownESP32
digitalP1 → AO3400A Gate (G)EXT
groundP2GND

35. Connections between "enableGate" and "ESP32"

FunctionenableGateESP32
digitalP1GPIO 8
digitalP2 → AO3400A Gate (G)EXT

36. Connections between "shift1" and "ESP32"

Functionshift1ESP32
powerVCC5V
groundGNDGND
digitalSERGPIO 5
digitalSRCLKGPIO 6
digitalRCLKGPIO 7
digitalOE → AO3400A Drain (D)EXT
powerSRCLR5V
digitalQA → ULN2003 Stepper Motor Driver Module IN1EXT
digitalQB → ULN2003 Stepper Motor Driver Module IN2EXT
digitalQC → ULN2003 Stepper Motor Driver Module IN3EXT
digitalQD → ULN2003 Stepper Motor Driver Module IN4EXT
digitalQE → ULN2003 Stepper Motor Driver Module IN1EXT
digitalQF → ULN2003 Stepper Motor Driver Module IN2EXT
digitalQG → ULN2003 Stepper Motor Driver Module IN3EXT
digitalQH → ULN2003 Stepper Motor Driver Module IN4EXT

37. Connections between "inputDown1A" and "ESP32"

FunctioninputDown1AESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN1EXT
groundP2GND

38. Connections between "inputDown1B" and "ESP32"

FunctioninputDown1BESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN2EXT
groundP2GND

39. Connections between "inputDown1C" and "ESP32"

FunctioninputDown1CESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN3EXT
groundP2GND

40. Connections between "inputDown1D" and "ESP32"

FunctioninputDown1DESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN4EXT
groundP2GND

41. Connections between "inputDown1E" and "ESP32"

FunctioninputDown1EESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN1EXT
groundP2GND

42. Connections between "inputDown1F" and "ESP32"

FunctioninputDown1FESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN2EXT
groundP2GND

43. Connections between "inputDown1G" and "ESP32"

FunctioninputDown1GESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN3EXT
groundP2GND

44. Connections between "inputDown1H" and "ESP32"

FunctioninputDown1HESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN4EXT
groundP2GND

45. Connections between "bypass1" and "ESP32"

Functionbypass1ESP32
power15V
ground2GND

46. Connections between "shift2" and "ESP32"

Functionshift2ESP32
powerVCC5V
groundGNDGND
digitalSER → TI SN74HCT595N QHprimeEXT
digitalSRCLK → TI SN74HCT595N SRCLKEXT
digitalRCLK → TI SN74HCT595N RCLKEXT
digitalOE → AO3400A Drain (D)EXT
powerSRCLR5V
digitalQA → ULN2003 Stepper Motor Driver Module IN1EXT
digitalQB → ULN2003 Stepper Motor Driver Module IN2EXT
digitalQC → ULN2003 Stepper Motor Driver Module IN3EXT
digitalQD → ULN2003 Stepper Motor Driver Module IN4EXT
digitalQE → ULN2003 Stepper Motor Driver Module IN1EXT
digitalQF → ULN2003 Stepper Motor Driver Module IN2EXT
digitalQG → ULN2003 Stepper Motor Driver Module IN3EXT
digitalQH → ULN2003 Stepper Motor Driver Module IN4EXT

47. Connections between "inputDown2A" and "ESP32"

FunctioninputDown2AESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN1EXT
groundP2GND

48. Connections between "inputDown2B" and "ESP32"

FunctioninputDown2BESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN2EXT
groundP2GND

49. Connections between "inputDown2C" and "ESP32"

FunctioninputDown2CESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN3EXT
groundP2GND

50. Connections between "inputDown2D" and "ESP32"

FunctioninputDown2DESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN4EXT
groundP2GND

51. Connections between "inputDown2E" and "ESP32"

FunctioninputDown2EESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN1EXT
groundP2GND

52. Connections between "inputDown2F" and "ESP32"

FunctioninputDown2FESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN2EXT
groundP2GND

53. Connections between "inputDown2G" and "ESP32"

FunctioninputDown2GESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN3EXT
groundP2GND

54. Connections between "inputDown2H" and "ESP32"

FunctioninputDown2HESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN4EXT
groundP2GND

55. Connections between "bypass2" and "ESP32"

Functionbypass2ESP32
power15V
ground2GND

56. Connections between "shift3" and "ESP32"

Functionshift3ESP32
powerVCC5V
groundGNDGND
digitalSER → TI SN74HCT595N QHprimeEXT
digitalSRCLK → TI SN74HCT595N SRCLKEXT
digitalRCLK → TI SN74HCT595N RCLKEXT
digitalOE → AO3400A Drain (D)EXT
powerSRCLR5V
digitalQA → ULN2003 Stepper Motor Driver Module IN1EXT
digitalQB → ULN2003 Stepper Motor Driver Module IN2EXT
digitalQC → ULN2003 Stepper Motor Driver Module IN3EXT
digitalQD → ULN2003 Stepper Motor Driver Module IN4EXT
digitalQE → ULN2003 Stepper Motor Driver Module IN1EXT
digitalQF → ULN2003 Stepper Motor Driver Module IN2EXT
digitalQG → ULN2003 Stepper Motor Driver Module IN3EXT
digitalQH → ULN2003 Stepper Motor Driver Module IN4EXT

57. Connections between "inputDown3A" and "ESP32"

FunctioninputDown3AESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN1EXT
groundP2GND

58. Connections between "inputDown3B" and "ESP32"

FunctioninputDown3BESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN2EXT
groundP2GND

59. Connections between "inputDown3C" and "ESP32"

FunctioninputDown3CESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN3EXT
groundP2GND

60. Connections between "inputDown3D" and "ESP32"

FunctioninputDown3DESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN4EXT
groundP2GND

61. Connections between "inputDown3E" and "ESP32"

FunctioninputDown3EESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN1EXT
groundP2GND

62. Connections between "inputDown3F" and "ESP32"

FunctioninputDown3FESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN2EXT
groundP2GND

63. Connections between "inputDown3G" and "ESP32"

FunctioninputDown3GESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN3EXT
groundP2GND

64. Connections between "inputDown3H" and "ESP32"

FunctioninputDown3HESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN4EXT
groundP2GND

65. Connections between "bypass3" and "ESP32"

Functionbypass3ESP32
power15V
ground2GND

66. Connections between "shift4" and "ESP32"

Functionshift4ESP32
powerVCC5V
groundGNDGND
digitalSER → TI SN74HCT595N QHprimeEXT
digitalSRCLK → TI SN74HCT595N SRCLKEXT
digitalRCLK → TI SN74HCT595N RCLKEXT
digitalOE → AO3400A Drain (D)EXT
powerSRCLR5V
digitalQA → ULN2003 Stepper Motor Driver Module IN1EXT
digitalQB → ULN2003 Stepper Motor Driver Module IN2EXT
digitalQC → ULN2003 Stepper Motor Driver Module IN3EXT
digitalQD → ULN2003 Stepper Motor Driver Module IN4EXT
digitalQE → ULN2003 Stepper Motor Driver Module IN1EXT
digitalQF → ULN2003 Stepper Motor Driver Module IN2EXT
digitalQG → ULN2003 Stepper Motor Driver Module IN3EXT
digitalQH → ULN2003 Stepper Motor Driver Module IN4EXT

67. Connections between "inputDown4A" and "ESP32"

FunctioninputDown4AESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN1EXT
groundP2GND

68. Connections between "inputDown4B" and "ESP32"

FunctioninputDown4BESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN2EXT
groundP2GND

69. Connections between "inputDown4C" and "ESP32"

FunctioninputDown4CESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN3EXT
groundP2GND

70. Connections between "inputDown4D" and "ESP32"

FunctioninputDown4DESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN4EXT
groundP2GND

71. Connections between "inputDown4E" and "ESP32"

FunctioninputDown4EESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN1EXT
groundP2GND

72. Connections between "inputDown4F" and "ESP32"

FunctioninputDown4FESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN2EXT
groundP2GND

73. Connections between "inputDown4G" and "ESP32"

FunctioninputDown4GESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN3EXT
groundP2GND

74. Connections between "inputDown4H" and "ESP32"

FunctioninputDown4HESP32
digitalP1 → ULN2003 Stepper Motor Driver Module IN4EXT
groundP2GND

75. Connections between "bypass4" and "ESP32"

Functionbypass4ESP32
power15V
ground2GND

Deploy the firmware

#include <Arduino.h>
#include <WiFi.h>
#include <WiFiUdp.h>
#include "role.h"

static const char *network = "Jog-7B-Panel";
static const char *password = "jog-7B-lime-43-frost";
static const IPAddress motorIP(192,168,4,1);
static constexpr uint16_t port = 29741;
static WiFiUDP udp;
static constexpr uint32_t magic = 0x37424A32;
struct Packet { uint32_t tag, seq; int32_t direction; uint32_t axis; };
static void sendPacket(IPAddress ip, uint16_t p, const Packet &msg) {
  if (udp.beginPacket(ip, p)) {
    udp.write(reinterpret_cast<const uint8_t *>(&msg), sizeof msg);
    udp.endPacket();
  }
}

#if DISPLAY_ROLE
#include <Wire.h>
#include <esp_lcd_panel_rgb.h>
#include <esp_lcd_panel_ops.h>
#include <esp_heap_caps.h>
static esp_lcd_panel_handle_t panel;
static constexpr int W = 1024, H = 600;
static constexpr int TOUCH_INT = 4;
static uint16_t *pixels;
static bool touchOK, ready;
static bool writeReg(uint8_t addr, uint16_t reg, uint8_t data) {
  Wire.beginTransmission(addr);
  if (addr == 0x5d) Wire.write(reg >> 8);
  Wire.write(reg & 255); Wire.write(data);
  return Wire.endTransmission() == 0;
}
static bool touchRead(uint16_t reg, uint8_t *data, size_t size) {
  Wire.beginTransmission(0x5d);
  Wire.write(reg >> 8); Wire.write(reg & 255);
  if (Wire.endTransmission(false) || Wire.requestFrom(uint8_t(0x5d), size) != size) return false;
  while (size--) *data++ = Wire.read();
  return true;
}
static bool startPanel() {
  Wire.begin(8, 9, 400000);
  Wire.setTimeOut(15);
  if (!writeReg(0x24, 2, 255)) return false;
  delay(10);
  // Waveshare 08_TOUCH: EXIO1 reset low, INT low, then release reset.
  // EXIO6 remains high (panel supply); EXIO2 stays off until RGB starts.
  pinMode(TOUCH_INT, OUTPUT);
  if (!writeReg(0x24, 3, 0xd9)) return false;
  delay(100); digitalWrite(TOUCH_INT, LOW); delay(100);
  if (!writeReg(0x24, 3, 0xdb)) return false;
  delay(200); pinMode(TOUCH_INT, INPUT);
  uint8_t id[4]; touchOK = touchRead(0x8140, id, sizeof id) && !memcmp(id,"911",3);
  esp_lcd_rgb_panel_config_t c{};
  c.clk_src = LCD_CLK_SRC_DEFAULT;
  c.timings.pclk_hz = 30000000;
  c.timings.h_res = W; c.timings.v_res = H;
  c.timings.hsync_pulse_width = 162; c.timings.hsync_back_porch = 152; c.timings.hsync_front_porch = 48;
  c.timings.vsync_pulse_width = 45; c.timings.vsync_back_porch = 13; c.timings.vsync_front_porch = 3;
  c.timings.flags.pclk_active_neg = 1;
  c.data_width = 16; c.bits_per_pixel = 16; c.num_fbs = 2;
  c.bounce_buffer_size_px = W * 10;
  c.flags.fb_in_psram = 1;
  c.hsync_gpio_num = 46; c.vsync_gpio_num = 3; c.de_gpio_num = 5; c.pclk_gpio_num = 7; c.disp_gpio_num = -1;
  const int pins[] = {14,38,18,17,10,39,0,45,48,47,21,1,2,42,41,40};
  memcpy(c.data_gpio_nums, pins, sizeof pins);
  void *buffer = nullptr;
  if (esp_lcd_new_rgb_panel(&c, &panel) != ESP_OK || esp_lcd_panel_init(panel) != ESP_OK ||
      esp_lcd_rgb_panel_get_frame_buffer(panel, 1, &buffer) != ESP_OK) return false;
  pixels = static_cast<uint16_t *>(buffer);
  return writeReg(0x24, 3, 0xdf);
}
static void box(int x, int y, int w, int h, uint16_t color) {
  for (int j=y; j<y+h; ++j) for (int i=x; i<x+w; ++i) pixels[j*W+i]=color;
}
// 5x7 uppercase bitmap glyphs, stored as seven five-bit rows.
static const uint8_t glyph[][7] = {
 {14,17,17,31,17,17,17},{30,17,17,30,17,17,30},{14,17,16,16,16,17,14},{30,17,17,17,17,17,30},
 {31,16,16,30,16,16,31},{31,16,16,30,16,16,16},{14,17,16,23,17,17,15},{17,17,17,31,17,17,17},
 {14,4,4,4,4,4,14},{7,2,2,2,18,18,12},{17,18,20,24,20,18,17},{16,16,16,16,16,16,31},
 {17,27,21,21,17,17,17},{17,25,21,19,17,17,17},{14,17,17,17,17,17,14},{30,17,17,30,16,16,16},
 {14,17,17,17,21,18,13},{30,17,17,30,20,18,17},{15,16,16,14,1,1,30},{31,4,4,4,4,4,4},
 {17,17,17,17,17,17,14},{17,17,17,17,17,10,4},{17,17,17,21,21,21,10},{17,17,10,4,10,17,17},
 {17,17,10,4,4,4,4},{31,1,2,4,8,16,31},{0,4,4,31,4,4,0},{0,0,0,31,0,0,0}
};
static void label(int center, int y, const char *txt, int s) {
  int x=center-(strlen(txt)*6*s-s)/2;
  for (; *txt; ++txt,x+=6*s) {
    int g= *txt=='+' ? 26 : *txt=='-' ? 27 : *txt-'A';
    if (g<0 || g>=28) continue;
    for(int r=0;r<7;r++) for(int c=0;c<5;c++) if(glyph[g][r] & (16>>c)) box(x+c*s,y+r*s,s,s,0xffff);
  }
}
static unsigned axis, drawnAxis;
static void draw(bool link, int motion) {
  box(0,0,W,H,0x10a4);
  label(512,46,"MANUAL JOG",8);
  label(512,138,!touchOK ? "TOUCH ERROR" : link ? "HOLD TO JOG" : "WAITING FOR MOTOR BOARD",4);
  box(48,205,444,180,motion<0 ? 0x056b : 0x1b0f);
  box(532,205,444,180,motion>0 ? 0x056b : 0x1b0f);
  label(270,265,"JOG -",8); label(754,265,"JOG +",8);
  for(unsigned i=0;i<8;i++) {
    int x=48+i*116;
    box(x,395,108,65,i==axis ? 0x056b : 0x1b0f);
    char name[]={char('A'+i),0}; label(x+54,410,name,5);
  }
  box(48,475,928,80,0x9800); label(512,490,"STOP",7);
  esp_lcd_panel_draw_bitmap(panel,0,0,W,H,pixels);
  void *a=nullptr,*b=nullptr;
  if (esp_lcd_rgb_panel_get_frame_buffer(panel,2,&a,&b)==ESP_OK)
    pixels=static_cast<uint16_t *>(pixels==a ? b : a);
}
static uint32_t seq, lastSend, lastAck, lastPoll, lastTouch;
static bool acked, armed, linkWas;
static int command, shown=2;
void setup() {
  Serial.begin(115200);
  ready=startPanel();
  if (!ready) { Serial.println("7B display initialization failed"); return; }
  draw(false,0);
  WiFi.mode(WIFI_STA); WiFi.setSleep(false); WiFi.begin(network,password);
  udp.begin(port);
}
void loop() {
  if (!ready) { delay(100); return; }
  uint32_t now=millis();
  while (udp.parsePacket()) {
    Packet a{};
    if (udp.remoteIP()==motorIP && udp.read(reinterpret_cast<uint8_t *>(&a),sizeof a)==sizeof a &&
        a.tag==magic && uint32_t(seq-a.seq)<5) { acked=true; lastAck=now; }
  }
  bool link=WiFi.status()==WL_CONNECTED && acked && now-lastAck<220;
  if (!link) { armed=false; command=0; }
  if (touchOK && now-lastPoll>=16) {
    lastPoll=now;
    uint8_t state=0;
    if (!touchRead(0x814e,&state,1)) { command=0; armed=false; }
    else if (state&0x80) {
      uint8_t pt[5]{}; int count=state&15;
      bool valid=count!=1 || touchRead(0x814f,pt,sizeof pt);
      valid=writeReg(0x5d,0x814e,0) && valid;
      if (valid) lastTouch=now;
      if (valid && count==0) { armed=link; command=0; }
      else {
        int x=pt[1]+256*pt[2],y=pt[3]+256*pt[4];
        if(valid && count==1 && !command && armed && y>=395 && y<460 && x>=48 && x<976) {
          axis=(x-48)/116; armed=false;
        }
        int target=0;
        if(valid && count==1 && y>=205 && y<385) {
          if(x>=48 && x<492) target=-1;
          if(x>=532 && x<976) target=1;
        }
        if (!target || !link || (command && command!=target)) { armed=false; command=0; }
        else if (armed) command=target;
      }
    }
  }
  if(now-lastTouch>110 && command) { command=0; armed=false; }
  if (WiFi.status()==WL_CONNECTED && (now-lastSend>=35 || command!=shown)) {
    lastSend=now; sendPacket(motorIP,port,{magic,++seq,command,axis});
  }
  if (link!=linkWas || command!=shown || axis!=drawnAxis) { drawnAxis=axis; draw(link,command); linkWas=link; shown=command; }
  delay(1);
}
#else
#include <DHT.h>
#include <SPI.h>
#include <MFRC522.h>
static constexpr int dataPin=5, clockPin=6, latchPin=7, enablePin=8;
static void outputs(uint32_t bits) {
  digitalWrite(latchPin,LOW);
  for(int i=24;i>=0;i-=8) shiftOut(dataPin,clockPin,MSBFIRST,uint8_t(bits>>i));
  digitalWrite(latchPin,HIGH);
}
static constexpr int fan=16, beam=10;
static DHT climate(9,DHT22);
static MFRC522 reader(14,15);
static uint32_t lastRun,lastStep,lastSense,drops,beamChanged;
static int motion;
static unsigned activeAxis;
static uint8_t phase[8];
static bool neutral,fanOn,blocked,rawBlocked;
static void stopMotor() { if(motion) outputs(0); motion=0; }
static void sensors(uint32_t now) {
  bool raw=digitalRead(beam)==HIGH;
  if(raw!=rawBlocked) { rawBlocked=raw; beamChanged=now; }
  if(raw!=blocked && now-beamChanged>=10) {
    blocked=raw;
    if(blocked) Serial.printf("Drop %lu\n",(unsigned long)++drops);
  }
  if(motion) return;
  if(now-lastSense>=2500) {
    lastSense=now;
    float h=climate.readHumidity(), t=climate.readTemperature();
    if(isnan(t)||isnan(h)) { fanOn=true; Serial.println("DHT22 read failed; fan on"); }
    else {
      if(t>=30) fanOn=true;
      else if(t<=28) fanOn=false;
      Serial.printf("%.1f C, %.1f %% RH, fan %s\n",t,h,fanOn?"ON":"OFF");
    }
    digitalWrite(fan,fanOn);
  }
  if(reader.PICC_IsNewCardPresent() && reader.PICC_ReadCardSerial()) {
    Serial.print("Card UID:");
    for(byte i=0;i<reader.uid.size;i++) Serial.printf(" %02X",reader.uid.uidByte[i]);
    Serial.println(); reader.PICC_HaltA();
  }
}
void setup() {
  Serial.begin(115200);
  for(int pin:{enablePin,dataPin,clockPin,latchPin}) { digitalWrite(pin,LOW); pinMode(pin,OUTPUT); }
  outputs(0);
  digitalWrite(enablePin,HIGH);
  digitalWrite(fan,LOW); pinMode(fan,OUTPUT);
  pinMode(beam,INPUT); blocked=rawBlocked=digitalRead(beam)==HIGH;
  climate.begin(); SPI.begin(12,13,11,14); reader.PCD_Init();
  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(motorIP,motorIP,IPAddress(255,255,255,0));
  if (WiFi.softAP(network,password,6,1,1)) udp.begin(port);
}
void loop() {
  uint32_t now=millis();
  if (now-lastRun>=160 || WiFi.softAPgetStationNum()==0) { stopMotor(); neutral=false; }
  for(int n=0;n<8 && udp.parsePacket();++n) {
    Packet p{};
    if (udp.read(reinterpret_cast<uint8_t *>(&p),sizeof p)!=sizeof p || p.tag!=magic || p.direction < -1 || p.direction > 1 || p.axis>=8) continue;
    const auto ip=udp.remoteIP(); const auto remotePort=udp.remotePort();
    if (!p.direction) { stopMotor(); neutral=true; }
    else if (neutral && (!motion || (motion==p.direction && activeAxis==p.axis))) {
      if (!motion) { lastStep=micros(); }
      activeAxis=p.axis; motion=p.direction;
    } else { stopMotor(); neutral=false; }
    lastRun=millis();
    sendPacket(ip,remotePort,{magic,p.seq,motion,activeAxis});
  }
  if (motion && uint32_t(micros()-lastStep)>=4000) {
    lastStep=micros();
    static constexpr uint8_t masks[]={1,3,2,6,4,12,8,9};
    auto &step=phase[activeAxis];
    step=(step+motion+8)%8;
    outputs(uint32_t(masks[step])<<(4*activeAxis));
  }
  sensors(now);
  delay(1);
}
#endif

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik