the thinker
Hardware- 5 Devlogs
- 10 Total hours
alarm clock using esp32 with keyswitches/rotary encoder and display.
alarm clock using esp32 with keyswitches/rotary encoder and display.
after letting my breadboard project sit on my desk for the past week or so i decided to try and finish up the project because all i had to do was finish up the firmware. to write the firmware what i did was figure out how to handle multiple buttons, then with those buttons i used an enum to be able to check or change what the alarm’s state was from set time, set alarm, ringing or normal. something i thought was going to be challenging was handling multiple buttons but it ended up being sort of similar to one button except now it just had an index to check for in the buttonstate and button pin.
now for next time i will will need to work on the display code once i actually get my hands on the components since all i had was my 3 pushbuttons, rotary encoder and buzzer to test with my arduino mega. i cannot wait to see how my pcb will look like irl!
today the only time i had to code was when i got home at around 10 but now I am here and I decided to get on my computer to work on the firmware for my alarm clock. since i don’t have an esp32 yet or the actual display, i decided to go with good ol serial print and use my arduino mega to debug the components i had at hand.
i wired a rotary encoder to the arduino mega and had to lookup the pinout for it but it was sort of similar to the one i had in my PCB schematic. it was pretty fun once i uploaded the code because i was able to see the values go crazy in the serial monitor. then i i figured out a basic way to make the current time comparing millis to the last millis and then adding a second and boom we have time which i will use to compare to the alarm time. the position in the rotary encoder will be used to add/subtract when setting alarm/current time. i am very glad i got this out of the way!
Locked in and finished up the cad in Onshape. First I made sure to fix up the extrudes/sketches since they looked off and intersected with each other which made me think it was not ok so I fixed that up, then I added the holes and some fillets as well as changing the color up. This took me more like 30ish minutes to do as I would repeat something twice before I actually got it to work. I’m really starting to get the hang of sketching something then extruding it to add shapes to my design.
I spent a lot of time yesterday trying to design the rough draft of my case in Onshape. It was really difficult at first to figure out some of the tools but then I got the hang of it like the sketching corner rectangles and center circles. The dimension tool made it really easy though to make sure things were the right tolerance etc. I think I will take some more time to finish up the design since it still some work.
I also spent some time adding a rotary encoder to the pcb because I think it would be easier to use a knob to set the clock time than spamming the keyswitch 😄 Adding the rotary encoder was fairly easy as it only uses 3 pins from what I remember and I used labels to make a cleaner schematic
I routed my alarm clock components in KiCad which was pretty easy to to do and I fixed up the 3D models that didn’t show up at first in the 3D viewer such as the ESP32 and the keyswitches. I really enjoyed organizing the things because it made me think about how they should all connect and it helped me understand how it’ll work. I think next time I will edit the pcb a little bit more actually to have round corners.