Morphing Digital Clock

24,109

334

232

Introduction: Morphing Digital Clock

A quick video about this project. I have since implemented a way to set timezone.

Thanks to the work of the Arduino and ESP8266 community, this cool clock is a surprisingly easy to build!

  1. Just two main components: Display (obviously) and a WiFi MicroController
  2. No soldering required
  3. No programming skill required, code is provided!

Let's get started!

Step 1: Parts List

Although I've included links to where I bought my parts, these parts can be easily purchased from other vendors all around the world.

  • P3 64x32 RGB LED Matrix $20
  • NodeMCU 32MB ESP8266 WiFi Microcontroller module $4.95
  • Female to Female 20cm Dupont jumper wires $0.85
  • Micro USB Data/Sync cable and 5V phone charger wall adapter (I had these and didn't have to buy it)
  • 5V 2A MINIMUM Power Supply (I had this and didn't have to buy it) $7.95
  • Solderless Female barrel connector to connect the Power Supply to the display power cable.

IMPORTANT:

  • Some USB cables are designed just for power delivery (charging) -- these are ok to power the finished clock, but to upload code to the ESP we will need a data/sync USB cable.
  • The P3 RGB Matrix has over 6000 LEDs. For this clock, we will never turn all of them at once, so 2 Amp is more than sufficient. However, if you plan on doing more with the display and have all LEDs set to white, the recommended power supply is 8 Amp minimum.

Step 2: Wiring Summary

There are a lot of wires, but don't worry. All we're doing is connecting one pin to another.

Just take your time. Double check each connection before and after you plug it in.

Make sure the wires are fully inserted so they would not accidentally come undone. They are quite snug when fully inserted.

Step 3: ESP Wiring

First, let's put jumper wires on the ESP. Don't worry if your wire colors are different than mine. Which pair of pins are connected by each wire is what is important.

Do NOT connect the ESP to your PC YET. We need to complete all wiring before we power anything up.

We are using pins D0 through D8 and two GND.

We can skip the 3V pin because the ESP will be powered via the USB port.

We also skip the Transmit and Receive pins because we will communicate to the ESP via USB or WiFi.

Step 4: Matrix Wiring Part 1

Next, take the other end of the jumper wires we've just hooked up to the ESP and plug them into the matrix.

Again, the chart includes the colors of the wires that I used, but of course your colors might be different.

What is important is that you connect the ESP pins to the matrix as shown in the table.

The matrix is NOT symmetrical, there is a left/right, up/down. Please note the white arrows.

Connectors on my matrix are not labeled, so I've added a photo with labels. Your matrix might be slightly different. These resources discuss other board versions in great detail:

Step 5: Matrix Wiring Part 2

Second set of jumper wires connect the left connector to the right connector of the matrix.

Third photo shows the right side of the matrix.

Step 6: Power Wiring

The display power cable were designed for screw terminals.

You could cut off the solder lug and strip the wire, but I opted to bend the prongs and use additional heat shrink tubing to ensure that there are no exposed metal. Whatever you do, make sure the wires make good contact, securely attached and insulated.

Obviously Red wire should be connected to (+) and Black wire to (-)

Plug the other end to the display, again noting polarity: Red goes to VCC and Black goes to GND.

If your cable is designed to simultaneously power two displays, it does not matter which one you connect to your one display. It is however VERY IMPORTANT that you do not reverse the red(+) and black(-)

If you haven't already, now is a good time to double check to make sure all the jumper wires are are connected to the correct pins (before we apply power).

Check polarity of the power cable AGAIN, make sure that PLUS and MINUS are NOT REVERSED!

Hey, we're done with wiring! But don't plug it in YET!

Step 7: Install Arduino IDE

To upload the code to the ESP, you will need the Arduino software and a few libraries:

Follow installation instructions on the Arduino website.

Arduino has done so much for the maker community, so you should contribute to Arduino, but it is optional.

Click "Just download" to download without contributing.

Step 8: Install Libraries

Once installed, launch the Arduino IDE then:

  • Click the Sketch menu > Include Library > Manage Libraries...
  • Search and install the latest version of the following libraries:
    • AdaFruit Gfx library
    • PxMatrix by Dominic Buchstaller
    • ArduinoJSON version 5.13.2 by Benoit Blanchon
    • WiFiManager by Tzapu
    • DoubleResetDetector by Stephen Denne aka Datacute

IMPORTANT:
Notice that at the time of this writing, ArduinoJSON version 6.x beta does not work with Morph Clock. Doing so causes compile errors. Make sure you specify version 5.13.2 when you install/update ArduinoJSON.
Thanks to user lmirel for noticing this.

Step 9: Install ESP8266 Support

We also need ESP8266 support

  • Close Manage Libraries, but stay in Arduino IDE
  • Go to File > Preferences
  • Click the icon to the right of Additional Board Manager URLs
  • Paste this URL on a separate line (sequence does not matter).
    • http://arduino.esp8266.com/stable/package_esp8266com_index.json
  • Click Ok to get out of Preferences
  • Navigate to: Tools > Board xyz > Board Manager...
  • Search for 8266
  • Install esp8266 by ESP8266 Community.

Step 10: Install CH340 Driver

The last thing to install is the device driver so our PC can talk to the ESP.

Download and install the driver for your computer from the bottom of the manufacturer's driver page.

If you need help, there is a nice tutorial on how to install Arduino Nano CH340 by samuel123abc. The same CH340/CH341 that is on the NodeMCU ESP is on the Arduino Nano clone.

Step 11: Upload the Code

We're almost there...

  1. Download and unzip the latest Morphing Clock code.
    • (see picture above if you're unfamiliar with github)
    • Unzip the downloaded zip file then double-click MorphingClock.ino
  2. Compile and Upload
    • Before we plug in the NodeMCU to your PC via the Micro USB cable, have you double-checked your wiring? :-)
    • Make sure that the pins of the NodeMCU are not being shorted by any metal objects on your desk while the NodeMCU is on.
    • When you plug in USB, you should hear the usual "ding" as Windows recognize a USB device being plugged in.
    • Setup the options in Arduino IDE > Tools as pictured
      • Your COM port might be different.
      • I had to change Flash Size to 4M(1M SPIFFS) your ESP might be different.
    • Click the Upload button as pictured. This will take some time (about a 30 seconds), and there will be warnings, but it will eventually upload to the NodeMCU.

Troubleshooting:

  • If the upload fails because it could not connect, make sure you choose the port where the ESP is plugged into under Tools > Port.
  • If there is no enabled option under Tools > Port
    • Make sure you've installed CH340 driver (see previous step)
    • Make sure you are using a data/sync cable. Test it by connecting your phone and PC with that cable. If you could see files on the phone from the PC, then you have a good data cable.
  • If the compile fails before it tries to upload, scroll up in the black background window and then slowly scroll down and note the first error it reports. If you cannot figure out what it's saying, post that first error and I will try to help. There will be some warnings - those are OK, they do not stop the compile.
  • if you get a JSON-related error when compiling, use JSON library version 5.13.2 instead of the latest version (6-beta) -- Thanks lmirel !

  • If the compile succeeded, upload succeeded but the clock does not work, open serial monitor in Arduino IDE, press reset on the ESP. If the errors are a bunch of hex numbers, try changing the Flash Size to 4M(1M SPIFFS) and reupload.
  • If the error is in English, it should tell you what it's having trouble with. Post what it says if you need help deciphering what it's trying to say :-)
  • Matrix works, but the ESP never shows up as an access point. I've seen this happen on the smaller NodeMCU that is based ESP-12E and 1M SPIFF and use this ESP-12E version of MorphClk.
    Unfortunately, I've only been able to work around the problem by decreasing the refresh rate of the display, so the display is not as bright compared to the original version.

Step 12: Configuration

Once the upload is completed, you should see the word: "Connecting" on the display.

The ESP is trying to connect to your WiFi to fetch the current time. However, it doesn't know the password to your WiFi Access Point (AP) yet.

  • Press the reset (RST) button on the ESP twice in a row about one second apart.
  • The display will show you AP: MorphClk,Pwd: HariFun, and 192.168.4.1.
  • At this time, the ESP is acting as WiFi access point named MorphClk with password HariFun.
  • Go to your computer/phone to change your WiFi connection from your normal WiFi to MorphClk.
  • To switch WiFi, on Windows, the icon is on bottom right corner, on a Mac it's on top right.
  • You might see a warning saying that your phone cannot find the Internet. It's OK. Your phone is now connected JUST to the ESP and the ESP is not connected to the Internet (yet).
  • Using a web browser on your computer/phone, visit 192.168.4.1, this is a website being served by the ESP.
  • Tap "Configure WiFi" and select YOUR WiFi access point and enter your WiFi password. It will then save that information in permanent storage so you will never to enter it again.
  • This is also where you choose timezone
    Use this website to find the TimeZone offset for your location. Don't forget to enter the minus sign.
  • Enter Y in the 24Hr field to show hours in military format, or enter N if you prefer to 12 hour format. I do not yet have an AM/PM indicator. Maybe you could add that feature and share how you did it?
  • Don't forget to switch your computer/phone back to your normal WiFi access point or you will not have internet access.

Step 13: All Done!

Well, that's it!

All that's left is to make a pretty case for it.

You no longer need the computer/phone. You can use any phone charger to power the ESP.

Please let me know if you see anything that I could improve on this instructable. I will do my best to answer questions too.

If you build this, please click the "I Made It" button and show off your version. Have fun making!

Step 14: Contributed Code

The wonderful people of the Internet have improved this project! Let me know if you've made improvements you'd like to share here. Thank you everyone!

Morphing Clock Remix by lmirel

https://github.com/lmirel/MorphingClockRemix

Date, Temperature, Relative Humidify by VincentD6714

https://drive.google.com/file/d/1TG8Y1IjAQaV7qGPWL...

Clocks Contest

Runner Up in the
Clocks Contest

7 People Made This Project!

Recommendations

  • Tiny Home Contest

    Tiny Home Contest
  • Metalworking Contest

    Metalworking Contest
  • Fix It! Contest

    Fix It! Contest

232 Discussions

First, congratulations to those of you who recently posted your success!
Second, just FYI, I am currently on a business trip and will not be able to respond to Instructable posts as quick as I normally could. I will be back in a week and will try to catch up. Sorry...

Thanks to SteveR254, I've been able to duplicate the issue that some of you were having with some NodeMCU versions. This is the narrower version that appears to be based on ESP-12E rather than ESP-12. I had to set the board to NodeMCU 1.0 (ESP-12E Module) otherwise although the upload would succeed, serial monitor would show garbage even at the correct baud rate.

I was not successful in figuring out why this ESP is having WiFi issues, out of desperation, I started commenting out the matrix code and lo and behold it started working! Eventually, I deduced that the interrupt routine that is updating the matrix is interfering with WiFi.

I decreased the refresh rate of the matrix (so it is less frequent), therefore giving more time for WiFi. That made the WiFi work (both as client and AP), but the display became very dim.

So, I increased the length of time the display is enabled. That broke the WiFi again!
So I had to decrease that parameter. Eventually, I found a decent balance.

If you want to try it it is in this branch:

https://github.com/hwiguna/HariFun_166_Morphing_Cl...

10 replies

Hari,

I really thought I had this thing beat. My Wifi connects every time now, and the brightness is fine, but now I note that both units I built appear to lose exactly an hour, when the time is read again, although I really believe it happens at the top of the hour, but that might just be a coincidence. I noted a couple others have that experience as well. Any thoughts? I have tried both google and NIST timeservers (I'm in the States) but no change.

Mark

Yes, unfortunately, it appears that you are still not getting reliable wifi connection. The MorphClk syncs with time server every hour. I thought I've fixed the issue with it using the wrong time offset when it cannot connect, but it appears to be still a problem. Unfortunately, I won't be able to look into this until I return from my business trip. If you're impatient, you can see the github branches and history to see how I tried to fix it in NTPClient.cpp. Sorry...

Hari,

The branch with the decreased refresh rate appears to work for my ESP-12E, although it has a slight flicker and a bit dimmer. Can you point me to where in the code I can adjust the refresh rate to see if I can go just a bit higher? Thanks again for your project, help and patience.

Mark

refreshRate is how often the matrix would be refreshed. The number is in seconds, that's why it is such a small number.
This is how often an interrupt is fired. I suspect if the interrupt fires too often the WiFi routines get confused.
Faster refresh (smaller number) of course is better, but doing it too often is what appears to break WiFi on some boards.

persistenceMicroSeconds is how long a pattern is held still before we replace it with another. If this number is low, then the display would be very dim because as we decrease the refreshRate above, the matrix will be "on" less and less.
So, I increased persistenceMicroSeconds so eventhough we do not update it very frequently, each time it does, we hold the pattern for longer period of time.

Again, if we hold it too long, then we'll end up taking too much of the ESP's time to draw the matrix and the WiFi got sad :-(

I don't know why this only seem to be a problem with some ESP. TrungH32 said that he/she was able to make it brighter by playing with the param. Hopefullly he/she will share the magic numbers.

Hari,

Thanks for the explanation. I was able to make the display suitably bright without having any WiFi issues using a refreshRate of 0.010. I did not alter the persistence at all - just the refresh. I may work with the rate and persistence a bit more, but for now it is connecting and displaying a time consistently, and the brightness is good enough to be seen in a brightly lit room, so I'm happy. Again, I appreciate your efforts and those of the other builders to share the pieces of the puzzle that let some of us fix our various issues. It's all about the learning experience.

Mark

kd6not, thanks for sharing that parameter. It'd be useful for others to know that at least it worked for one ESP board out there. :-)
My theory is that when the ESP is setup as an access point (during setup), it requires more WiFi processing, so I had to set refresh pretty infrequently (larger value of 0.025). But once it is setup and the ESP only has to connect to home wifi, it has more time to update the matrix so your value of 0.010 works.

Just a theory. Glad you got yours working and brighter. Thanks for sharing your success.

Hari,

I thought I had this all figured out, but now it appears that when first powered up, the unit connects and grabs the time with no problem. (I can disconnect power, and it comes right back up and connects with power restored.) However, although I cant say exactly when, the time becomes exactly one hour off. Right now, I don't have the time offset hard coded (I use the WiFi link to set the parameters), but will try that next. I don't think the WiFi refreshRate could affect the time in that way (exactly 1 hour shift all at once), so I'm hoping that will solve the remaining issue. I'll let you know. I see the time is updated once an hour, so perhaps that is the clue.

Mark

Hari,

I posted just before I started to look through the code. I see the commented section for the refresh, and found the post where you explain it (I think.) I'm assuming there is some timing relationship between the refresh rate and the persistence?

Mark

Hari,

I tried the later branch for the ESP-12E version (which I have) and also tried the version where I manually fill in my Wi-Fi information. However, each time, after a reboot and connection (it tells me it is connected and shows the offset and 24 hr choice), all I get is the two colons, and no time. Unlike others, I can reset 10 or 15 times, each time it says connected, but never see the time.

Any thoughts?

Thanks,

Mark

Tried the latest code and I can verify it working on the esp-12E module.

However, it flickers too much and is very dim.

I am okay with using my other boards that work and maybe you might not want to spend a whole lot of time on it.

Next step for me is making a nice oak cabinet.

I will post a pic when done.

Thank you for the project.

0
None
gur001

2 days ago

hi i am getting error

MorphingClockRemix:843: error: 'TF_COLS' was not declared in this scope

int xo = 4*TF_COLS;

^

C:\Users\Gurjinder\Desktop\HariFun_166_Morphing_Clock-Shared\MorphingClockRemix-master\MorphingClockRemix\MorphingClockRemix.ino: In function 'void loop()':

MorphingClockRemix:902: error: 'class NTPClient' has no member named 'getHour'

hh = NTP.getHour ();

^

MorphingClockRemix:903: error: 'class NTPClient' has no member named 'getMinute'

mm = NTP.getMinute ();

^

MorphingClockRemix:904: error: 'class NTPClient' has no member named 'getSecond'

ss = NTP.getSecond ();

^

exit status 1

'TF_COLS' was not declared in this scope

1 reply

Hi All,

Unfortunate i get desame error status at this moment.

The first sketch from MorphingClockRemix (about 14 days ago went ok, so could it something has to do with some upgrades or revisions ?

Please advice what to do or test.

Regards Tobo.

Fantastic, thanks for sharing, want to make something more permanent...have ordered some!

CharlyBoy, that's great!
Thank you for doing that and sharing!

Noticed an issue with the Timezone, I leave the clock running (obviously!) and seems after a period (not got specifics - can be 1 - 3 days) it drops back an hour. when I reset the ESP and it gets current time again it corrects itself. Not had a change to do any debugging, just wondered if anyone else had seen this?

https://imgur.com/Gfps3fu

2 more answers

I have the same issue - did you find a fix? I have tried various power supplies (although did not think that would help, but thought maybe it was corrupting the time update somehow), and am now going to change the wi-fi update rate.

Mark