I love the remix of the Arduino clock but am not a fan of the wires coming out of it, so I designed this battery powered clock. To save power, which is essential for batteries, this version utilizes ESP32 deep sleep mode & an external RTC module to keep the timer correct.
Get a 4-batteries shield if you can. I recommend this diymore brand, it has a usb port for ESP32 & multiple 5v output for the motor, making the whole process easier.
Using battery to power the clock is easy, the hard part is making the battery last a long time before needing to recharge by saving as much power as possible. To do that, we will not using WIFI & utilize deep sleep mode when the clock not running and only wake up periodically (60 sec) to turn the stepper motor. The downside is of course you have to turn the motor by hand to set the time at the beginning.
DS3231 module: you can use GPIO pin to wake up the board periodically, but the onboard RTC (real time clock) is not very accurate in deep sleep, that's why we'll be using an external RTC module to do the timing.
FQP30N06L mosfet: the battery shield that I linked have a switch to change between always-on / saving power mode and a button press to turn on the psu. Saving power mode will auto turn off the power supply after idle time about 40s, which we cannot use as is because we want our clock to keep running after deep sleep. However, always-on mode will consume a constant 90mA to keep the psu on, which is quite bad if we want to save power. That's why we will make a simple circuit using this mosfet as a switch connected to the button to emulate a press every 30s to keep the power on in saving-power mode. With this approach the power consumption is much lower (~2mA). You can use any logic level N channel mosfet that can be turn on with 3.3v, this particular model is tested and can do the job.
Assuming you already printed all the parts & finish assembly the clock from the original design. This part will focus on the wiring and soldering of the battery circuit. If you're not using the battery shield, you can skip Step 1 & 2.
Step 1: Modify battery shield
- Solder 2 male headers on 1 of the 5v output. - Crimp 2 wires (15cm) for this output. - Solder 2 wires (10cm) onto button pins, those are 2 pins on the left & right that are closest to the button, pay attention to the polarity. Crimp the other ends with Dupont connector. - Dab some hot glue on the button solder joints. - Optional: you can desolder those battery status leds to save even more power, I chose to leave them on.
Step 2: Solder battery circuit
Solder like this drawing below, after that carefully bend the mosfet 90 degree to save space.
The other side:
Step 3: Prepare the mount
- There're 2 versions, with & without heat insert. Put BatteryMount & PCBMount in the position like this picture, then dab some hot glue on 4 corners of each mount. - WallBalancer is glue on the other side of those components to prevent the clock from wobbling when mounting on the wall. - WallMount has an extruded part that goes under the rim of the clock's back side to prevent it from falling off.
Step 4: Final assembly & wiring - Open your computer, flash the sketch to ESP32. - Screw PCBs and battery shield onto the mounts. - Plug ESP32 into battery shield using USB cable. - Put CR2032 battery into DS3231. - Remember all those male headers on Ground (yellow) from Step 2? Connect 1 pin to ESP32 GND. Every GND referred below is connected to remaining pins.
Depend on the position of your mounts that you need to cut the wire length accordingly, use different colors for easier assembly. Here's the wiring:
ULN2003 Motor Driver
ESP32
Battery shield
IN1
GPIO19
IN2
GPIO18
IN3
GPIO17
IN4
GPIO16
+
5v +
-
GND
5v -
DS3231
ESP32
VCC
3v3
GND
GND
SDA
GPIO21 (SDA)
SCL
GPIO22 (SCL)
SQW
GPIO33
Battery circuit (refer to Step 2)
ESP32
Battery shield
Pin 4
Button +
Pin 5
GND
Button -
Pin 3
GPIO32
- Manually turn the ClockMovementGearStepper to set to the current time. Put on the glass cover. - Put 18650 batteries into your battery shield, please note that polarity is extremelyIMPORTANT! As far as I know these shields doesn't have reverse polarity protection so it will smoking & permanently damage the board if you put in the wrong battery polarity. - Remember to switch battery shield to saving power mode. After that, press the button on battery shield once to turn on the clock. Double pressed if you want to turn it off.