My entry to the circuit sculpture contest - A digital Clock which pulls its time from the Global Positioning System
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
ESP32_GPS_Clock.inoFinal arduino code for the clock!ino - 8.48 kB - 09/03/2020 at 03:45 |
|
When starting this project, I didn't know too much about making this style of circuit, it's difficult to get bends right. I have learned one thing through this project, thinner gauge wire is significantly easier to bend but much more difficult to keep straight.
First thing is that I replaced the two power wires coming off the seven segment that go straight down to the power supply lines. The direct path these took kind of stood out as something odd in the sculpture which was less than ideal (see the fix below).
Originally, I used thinner gauge copper-colored wire for providing a connection to the LEDs, this was not the right choice. The thinner wire is very flexible and it's difficult to get the wires to run parallel in a nice way. Since those wires running to the LEDs are a significant element of the overall aesthetic it just made things look kind of sloppy. I desoldered them and used them as a reference to bend some new wires out of the thicker gauge brass wire that was used for power connections:
With the thicker wire these came out a lot better, If I were to do this project over again, I'd probably stick exclusively to the thicker wire. The margin for error is a lot lower since fixing a bend is more-or-less out of the question once it's done but the result is worth it. In total I replaced all 6 of the wires running from the ESP32 to the anodes of the LEDs. The new wires are a night and day difference in my opinion, the lighter color also makes them stand out a bit more against the base.
Finally the rear stand on the display was removed. with the two mounting screws present it's not really needed, the circuit alone is enough to support the display.
I put the finishing touches on the project today, with classes starting soon I don't really want to drag this project into the school year when I've got other's like the smartwatch still going. I'm going to split up the final updates into code and changes to the sculpture. For anyone interested the code is available on this project page for download, everything's done in the Arduino IDE.
The code's simple overall and I explained everything important about how the time is obtained from the GPS module, this code is all about ascetics and ease of use.
The LEDs now operate as intended and transition smoothly in a fade sequence, nothing too crazy but it's a nice affect when looking at the clock.
I also finally got around to adding the photo resistor into the circuit right between the ESP32 and the GPS module. Which the firmware reads and automatically adjusts the brightness of the display and LEDs. This just prevents the clock from flooding the room with red light when there aren't any lights on in the room.
The final addition to the code was to do with timekeeping, the clock should now automatically adjust to daylights savings on its own. Since the GPS module automatically obtains date information anyway it's just a matter of taking that date and determining whether it's in a specific range. It's worth noting though that I only implemented this feature with the dates for 2020 daylights savings, so in the future it will have a few days where the time is wrong but ultimately 99% accuracy is good enough here.
That's everything in terms of software features, onto the final touches to the sculpture.
Got a new GPS module! It's always amazing how consistent Digikey is when it comes to shipping orders, I ordered the new module on Sunday night and it came in today (Wednesday). With the new module the project is back on track. It only took about 15 minutes to swap out the modules, before doing that I verified the module worked just by hijacking the serial pins of an Arduino Mega:
And it spits out the correct data which is what the project uses to tell time. For those who are interested the GPS module itself just communicates over UART at 9600 baud. The data it transmits is formatted in NMEA sentences, it transmits the GGA, GSA, RMC, and VTG formatted sentences. Different sentences have different data contained in them and in different formats (if you want to know more a great reference can be found here https://www.gpsinformation.org/dale/nmea.htm). In the case of time keeping the most useful sentence is the GPRMC sentence just because it contains both current time (UTC) and date. Here's an example of the raw output from the module:
There's not a lot of work involved interfacing this module with a micro-controller, it doesn't require any configuration commands to operate, the above screenshot is just it's default output. If I wanted to the module could be configured to output different sentences with different information (such as the ZDA sentence which is exclusively time and date) but ultimately there's no additional benefit to doing so.
Getting time out of the RMC string is simple, all we need to do is store the UART data that's received and parse the time out. All the values in the NMEA sentence are comma separated so finding the data we want is just a matter of splitting the string up. Once the time is parsed out it's just a matter of converting to whatever time zone and switching over to a 12-hour format if preferred.
Once the data's parsed out it's just a matter of updating the seven-segment display.
And that's all it really takes to get a functioning GPS clock. I'll release the code in one of next few logs, there's still a few things to add, but the core functionality is there.
Thanks for reading, see you in the next log!
Last night I began working on the code for the clock. The code doesn't need to do much normally, just parse the time out of the NMEA sentences of the GPS module, convert to your time zone of choice, and update the seven-segment display. Unfortunately, It's looking like the GPS module is dead. When the module works properly it constantly sends out data over UART, when the current module is powered on it does not output anything. My pocket oscilloscope doesn't show any output at all on the TX line of the module and there is no short between any other wires. I'm not sure what caused the module to fail, I also didn't test it before putting it into the circuit so I can't be sure that it didn't get damaged from sitting at the bottom of a box for the last few months (although that seems unlikely). Either way, I've ordered a new GPS module to replace the current one and it should arrive sometime this week. Luckily with the ESP32 I can get the time from a WiFi connection and complete all the other code before the module arrives.
With all that said I still put a little more work into the ascetics of the project and built a base for the clock. I have a lot of 3/4 maple plywood sitting around from a desk I built awhile back so I decided to use some here. I just cut out a piece that's roughly the size of the clock and beveled the edges with a file. I then added a coat of wood stain and a few layers of polyurethane. Overall, I think it came out alright.
The small hole is for a wide-headed screw to hold the sculpture down by one of its wires.
I'm not too sure about the color at the moment, it's a bit too similar to the wire color so I may have to go with something lighter or darker.
Well we now have RGB LEDs in the mix, to add another splash of color to the design. For the most part the addition of the LEDs was to add more complexity to the wiring and make the entire build feel more complete. In total the LEDs constitute another 8 wires that needed to be run. I ended up breaking from the original schematic just because there were other pins that were more available than the ones I originally picked. In its current state the project is taking shape:
the RGB LEDs are tucked up under the seven segment and just point up to give some diffuse underlighting, the backside isn't nearly as pretty but nobody really needs to see it. I ended up neglecting the 220-ohm resistors, mostly because I don't have any resistors that that have structurally strong leads. This project falls firmly under the "for the fun of it" category so I'm not going to stress the details too much.
I also reworked the structure a bit so that the seven seg is supported by some wire. Either way here's the clock in its current state with some simple test code:
Unfortunately, I didn't make it to the point of being able to put in the photoresistor or the buttons (might skip the buttons and just put everything in firmware).
There's been a lot of wire bending and quite a few learning curves to overcome. First thing worthy of note is that originally I put way too much faith in the strength of the solder pads, they're good for wires but in this kind of project they're far too weak. After soldering the first bit of the project together I found that the pads were becoming loose, eventually even the througholes gave out. I ended up loosing the ground, VIN, and 3.3V pads:
The result of this is that I needed to replace the ESP32 board with another one, this time i'm using the headers as solder points. I probably should have done this from the start, but I don't think the board looks nearly as good with the headers on it floating in space.
The first parts soldered up were the ESP32 and the GPS module, since there's only 4 connections going between them:
(You'll also notice I'm using this piece of plywood as a solder mat, there's a good reason for this)
By far the most difficult component to assemble was the 7-seg. Given it's shear size and mass it's difficult to position correctly to solder. Unfortunately I don't have any in progress images for soldering the display, There are a total of 4 connections to the display, the 5V power for the display is used essentially as a stand for the entire project. 3.3V and the ground connection come off of the power buss connecting the ESP32 and the GPS Module.
All said and done it came together pretty well:
Using the plywood has been great. at the moment that screw in the center is the only thing that holds this project up, without it the display tips the entire project backwards.
Even better it works!
I still need to put in the buttons and the RGB LEDs so this is by no means complete but the core is there!
I went to my local craft store and found some nice jewlery wire for this project. I got 3 lengths of wire in different gauges and colors. At the moment I'm planning on going with the more copper colored wire for signals and the brass colored wire for power. Of course there will be exceptions, I mostly want to mix things up to give a bit of extra color. Here's what I've got to work with in terms of materialsand parts:
So far I've planned the layout a bit, I think this configuration will work the best:
Now it's time to start bending some wire!
I'm not planning on making this a huge project, This will most likely just be a weekend project.
Create an account to leave a comment. Already have an account? Log In.
Great looking clock! I have code that determines DST for any date if you want it...
I'd be super keen and appreciative to receive this same sketch with DST dates (please)
Awesome project! Looks like a naked semi-futuristic steampunk clock.
I would have thought decorative wire like that would have a clear lacquer coating or something to prevent tarnishing -- and soldering. Guess not, though - I'll have to keep that in mind for future circuit sculpture projects. Nice job!
Thank you! Actually the wire does seem to have some kind of clear coat on it. Initially it made the soldering difficult but I've found that flux eats it away pretty quickly.
Looks fantastic! Don't forget to officially submit it to the contest with the "Submit project to..." button on the side panel, under the gallery.
Become a member to follow this project and never miss any updates
Assuming the lower case days are sunday = 0 and the months are january = 0, this routine will tell you if the RTC date, day of week and time are DST or not:
bool DSTInEffect(){ // returns true if DST in effect
DateTime now = rtc.now(); // load with current RTC time
int m = now.month();
int d = now.day();
int h = now.hour();
int mm = now.minute();
int dow = now.dayOfTheWeek();
int hhmm = (100*h)+mm; // to check for change to/from DST (makes testing quicker)
switch (m){
case april: // April thru October, we are in DST if its used
case may:
case june:
case july:
case august:
case september:
case october:
return true;
case december: // December thru February always NOT in DST if used
case january:
case february:
return false;
case march: // in March, we ARE in DST on 2nd Sunday
if (d < 8) {return false;} // days 1 thru 7 can't be 2nd sunday
if (d >14){return true;} // days 14 and beyond always WILL be DST
if (dow == sunday){if (hhmm >= DSTEvent) {return true;} else return false; } else //Sunday AND after 2:05am then adjust
{if (d >= (8+dow)) {return true;} else {return false;}}
case november: // in November, switch off of DST on first Sunday
if (d > 7) {return false;} // Days 8 through end of month have to be non-DST
if (dow == sunday){if (hhmm < DSTEvent) {return true;} else return false; } else //Sunday AND after 2:05am then adjust
{if (d >= (1+dow)) {return false;} else {return true;}}
} // end of case on month
} // end of DSTInEffect