Skip to content

Micropython code to run a clock with 28BYJ-48 stepper on ESP32/arduino

Notifications You must be signed in to change notification settings

ppamment/esp-clock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MicroPython Clock Project with 28BYJ-48 Stepper and ULN2003

This project involves implementing a clock using a 28BYJ-48 stepper motor driven by a ULN2003 or equivalent (e.g., 4 logic level MOSFETs). It's designed for enthusiasts looking for a straightforward setup with a casual tone.

Setup Instructions

Flashing the MicroPython Firmware

  1. Flash the MicroPython firmware onto your ESP32. Follow the steps outlined in the official documentation: MicroPython ESP32 Tutorial

Alternatively, you can use the Thonny IDE, which streamlines the process by handling firmware flashing, file transfer, and connecting to the REPL via USB and Wi-Fi. For details, visit: Thonny IDE, specifically the Run -> Configure Interpreter section.

Establishing Connections

  1. Establish a serial connection using your preferred method.
  2. Connect your ESP32 to Wi-Fi for time synchronization (as covered in the MicroPython documentation).
  3. Configure WebREPL for Wi-Fi access. Execute the following in your REPL: import webrepl_setup
  4. Add WLAN_SSID and WLAN_PASS to webrepl_cfg as ESP32 does not implement wifi credentials persistence.
  • If you don't want to do this, comment lines 6-11 in boot.py

Uploading Files

  1. Clone or download this repository.
  2. Upload all files to the filesystem root of your ESP32.
  3. Perform a soft reset with the following commands: import machine machine.soft_reset()

Running the Clock

  • After the reset, the clock should start running.
  • Access the board over USB or Wi-Fi via WebREPL using Thonny or the WebREPL web client.
  • Calibrate the clock hands if needed: Use my_clock.calibrate_hands(hour, minute) replacing 'hour' (0-11) and 'minute' (0-59) with the current positions.
  • At the next minute, the clock will automatically adjust the hands to the correct time.
  • The clock hands' positions are saved in nonvolatile storage (or a file, if NV storage is unavailable) each time they move, allowing the clock to remember their positions even after a power loss.

Additional Configuration

  • If your motor has a different step count, modify the step count in boot.py.
  • PWM-based microstepping is implemented for quieter motor operation.
  • If needed you can also adjust the PWM frequency and number of microsteps in boot.py.

Note: This project is intended for hobbyists and DIY enthusiasts. It assumes a basic understanding of MicroPython, ESP32, and stepper motor operation.

About

Micropython code to run a clock with 28BYJ-48 stepper on ESP32/arduino

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages