ESP32

Smart Watch for Couple using ESP32-C3, SquareLine Studio, & LVGL

Smart Watch for Couple:

Smart Watch for Couple using ESP32-C3, SquareLine Studio, & LVGL- This is my 6th article in the smart watch programming series using the CrowPanel ESP32-C3 1.28-inch IPS Capacitive Touch Display. And let me tell you, this project is being made especially because of a request from someone in love.

esp32-c3 Smart Watch for Couple

If you have read the last 5 articles, I am sure you will have no trouble following this one. That’s because today, we will be using this smart watch with the Blynk application. It’s something totally new and hasn’t been done before. So, before reading this article, make sure you have read the previous 5 articles. The information I am sharing in this article cannot be found anywhere else.

allpcb circuit

There is a guy who wants to gift his girlfriend a smart watch, and he wants to add features of his choice. He has the same display as this one and is following my videos and articles to create the smart watch for his girlfriend. He has already covered everything I explained in the last 5 articles.

Now, let me tell you about the changes and new features he requested.




Counter Modification:

He asked me to work on improving the counter feature of the smart watch. Now, let me tell you, the counter itself works perfectly. When you press the + button, it increases the value, and when you press the Reset button, it instantly sets the value back to zero.

digital tasibh and Smart Watch for Couple

Simple, right? But there is one problem: the counter value gets completely wiped out if the smart watch is turned off or reset. Imagine spending all that time keeping track of a count, only to lose it when the watch powers off. That’s frustrating!

So, to fix this, he requested that I save the counter value in the EEPROM. This is a type of memory that doesn’t lose data even when the device is turned off. With this upgrade, the counter value will stay safe and sound, no matter what happens.

Now here’s the sweet part of the story: his girlfriend is a little religious, and she plans to use this counter as a digital tasbih—or prayer beads. How thoughtful is that? To make things even better, he also asked me to send the counter value to the Blynk application so he can monitor it remotely. Whether it’s for motivation or just staying connected in a unique way, this feature makes the smart watch even more personal and meaningful.

Pretty cool, right? And this is just the first feature he wanted me to work on. Let’s move on to the next one!



Adding a Keyboard:

He came up with an interesting idea: adding a keyboard Widget to the smart watch. This would allow his girlfriend to connect the smart watch to any WiFi network she wants. Imagine how handy that would be! She could just type in the WiFi name and password directly on the watch.

add a keyboard on Smart Watch for Couple

But that’s not all. He also asked me to make sure the WiFi details she enters are saved in the EEPROM. So that even if the watch gets turned off or restarted, the WiFi settings remain intact. This way, she won’t have to re-enter the credentials every single time.

This feature will make the smart watch much more user-friendly and practical, giving her the freedom to stay connected anytime, anywhere. And honestly, I think it’s a great idea for any smartwatch!



Vibration Motor Control:

This was the feature he emphasized the most- controlling the vibration motor through the Blynk application. He explained why this is so important: whenever he messages or calls his girlfriend, she is often unavailable. Maybe her phone is on silent, or it’s charging, or she’s spending time with her family and isn’t using her phone much.

control Smart Watch for Couple using iot

In situations like these, he wants a discreet way to get her attention. With this feature, he can secretly turn the smart watch’s vibration motor on or off using the Blynk application. It’s like a private little signal just for the two of them!

smart bracelet and Smart Watch for Couple

Interestingly, this idea came to him after seeing a bracelet designed for long-distance couple. That bracelet vibrates to notify your partner, but it’s expensive and lacks additional features. So, he thought, why not include something similar in the smart watch for couple? This way, he gets the same functionality, plus a lot more, in one device and that too for a few bucks.



Feedback Feature:

He also had a unique idea for a feedback feature. He wants the smart watch to work with the Blynk application in a fun and meaningful way. Here is how it will work: whenever his girlfriend presses the screen of the smart watch, the LED widget in the Blynk application will start blinking.

It’s a simple yet thoughtful way to add a connection between the watch and the application. Imagine her pressing the screen and instantly seeing a blinking light in the application-it’s like a little signal saying, “Hey, I am here!” This adds a playful and personal touch to the smart watch, making it even more special for the two of them and obviously for the long-distance lovers.

Let’s go ahead modify the counter, and add all the features he requested for. From today’s article, you are going to learn a lot of exciting things!

So, without any further delay let’s get started!

Blynk IoT Cloud setup:

Log in to your Blynk account and create a simple dashboard like this. Add a button, LED, and gauge from the Widget Box.

Smart Watch for Couple blynk dashboard

Then go to Datastreams and create three datastreams: V0, V1, and V2.

Assign them to the Button, LED, and Gauge, respectively. If you have never used Blynk before, I highly recommend reading my getting-started article on Blynk and ESP32.

Next, open the program, and paste the BLYNK_TEMPLATE_ID, BLYNK_TEMPLATE_NAME, and BLYNK_AUTH_TOKEN at the top of the program.




Then open the Blynk IoT application on your smart phone and set it up exactly the same way.

blynk iot mobile application Smart Watch for Couple

We will use this button to control the vibration motor on the Smart Watch. The LED widget is for the feedback, and the Gauge is for displaying the counter value. Now, let’s open the SquareLine Studio.



SquareLine Studio:

designing gui for Smart Watch for Couple in squareline studio

In the last 5 videos and articles, we have covered a lot of things. In Part 2, I made a counter. In Part 3, I created a digital watch. In Part 4, I made an analog watch. And in Part 5, I added dropdown menus to set the time.

So, make sure you read those 5 articles or watch those 5 videos first. Alright, let’s continue working on the same project!

On widgets tab, scroll down and click on Screen.

adding screen and images in squareline studio for Smart Watch for Couple

You can see Screen4 has been added. Next, we need to import an image to use it as the background. For this, click the ADD FILE INTO ASSETS and select the png image.

add background image in squareline studio for Smart Watch for Couple

You can see the image has been added in the Assests. While Screen4 is selected go to the Background; set the background Radius and color. Next, scroll down, click on the Background and select the image to set it as the background.

Next, scroll down and set the border color and width.



Then click on the Outline and set the color and width of the Outline.

border and outline in squareline studio Smart Watch for Couple

I think it looks good, the choice of colors is totally up to you; just go ahead and try different colors. You can also spend some time on styling to make it look more attractive. Anyway, while the Screen4 is still selected; click on the ADD EVEN button.

Set the Trigger type to LONG_PRESSED.

Set action type to CALL FUNCTION.

Then click on the ADD button, check the “Do not export function”, and write the function name.

add event in squareline for Smart Watch for Couple

We are done with the Screen4.



Keyboard Widget:

Now, for entering the WiFi Credentials; let’s go ahead and add a 5th screen. And then;

On the Widgets tab, click on the Textarea to add a Placeholder for entering the SSID.

textarea in squareline Smart Watch for Couple

Enter the default text.

Activate the One line mode.

Next, name the textarea so that we can easily find it in the variables list on the Arduino side.

Now, let’s add another Textarea for entering the Password. For this, simply duplicate the existing textarea.

Set its position.

Write the name.

And then you can write the default text. Why not to write the actual SSID and password to quickly connect it to the cellphone WiFi Hotspot.

keyboard and textarea in Smart Watch for Couple

For the password, make sure to check the Password mode.




Next, let’s add a keyboard for entering the WiFi credentials.

Smart Watch for Couple button storing wifi credentials in squareline studio

This Keyboard really looks cool. Let’s say we enter the SSID and Password using this keyboard. Now, how to save these WiFi credentials in the EEPROM? Well for this we can add a button.

Select the button and on the inspector tab scroll down and click the ADD EVENT button.

Set the trigger type to RELEASED.

Set action type to CALL FUNCTION.

Click the ADD button, check the box, and write the function name.

Next, select the Textarea, and on the inspector tab click the ADD EVENT button.

connect keyboard with textarea in squareline studio for Smart Watch for Couple

Set the Trigger type to CLICKED.

Set the action type to KEYBOARD SET TARGET.

Then click the ADD button and select the Keyboard and textarea.

Now, follow the same setups for the other Textarea.



enter wifi credentials in Smart Watch for Couple

Now, the keyboard is ready. Now, we don’t need a Bluetooth application or a webserver for entering the WiFi Credentials. We can type-in the SSID and Password using this keyboard.

For the Screen1, 2, and 3; I have already added the Screen change events; let’s also do the same for Screen4 and Screen5. I have already explained this in the previous tutorials.



Generate UI Files:

Our setup is completed and now let’s save the project and export the UI files. Then go to the UI files folder, copy all the files, and then paste them in the Arduino project folder. After pasting all the files then go ahead and open the Arduino file. These are the steps, I have already explained in my previous tutorials.

In Part 2 and part 3, I already explained where to find the screen properties, how to enable support for large fonts, and how to locate all the variables. I recommend watching Part 2 and 3 to learn how to avoid errors.

lv color 16 swap lvgl Smart Watch for Couple

There is just one thing you need to do every time you generate new UI files: change LV_COLOR_16_SWAP from 0 to 1.

Now, let’s go to the main Arduino file.




Complete Code:



Code Explanation:

This library allows you to manage and monitor the watchdog timer for tasks running on the ESP32, helping to prevent the system from hanging due to stuck or unresponsive tasks.

This line sets the timeout period for a Watchdog Timer in seconds.

This line stores the Blynk authentication token (BLYNK_AUTH_TOKEN) as a character array.

The BLYNK_AUTH_TOKEN is a unique identifier provided by the Blynk platform for your project, allowing your device to connect to the Blynk server.

This variable is intended to store the SSID (network name) of the Wi-Fi you want the Smartwatch to connect to.

This variable holds the password for the Wi-Fi network.

This line initializes a wificounter to track Wi-Fi connection attempts and sets up a timer (lastReconnectAttempt) for managing reconnect attempts every 5 seconds (reconnectInterval).

The Ticker checkwificonnectivity is used to periodically check the Wi-Fi status and execute actions if disconnected. This setup helps ensure reliable Wi-Fi connectivity by attempting reconnections when needed.

The line; creates an instance of the Preferences class, which is part of the ESP32’s Preferences.h library. Including #include <Preferences.h> allows you to use the Preferences library, which provides a simpler and more robust way to store and retrieve key-value pairs in the ESP32’s non-volatile storage (NVS). Unlike EEPROM, Preferences handles wear leveling automatically, is optimized for frequent writes, and supports namespacing for organizing data. It is preferred over EEPROM because it is less prone to memory corruption, easier to use with string-based keys, and more reliable for modern applications. Now, let’s go to the setup() function.

This part of the code initializes the Preferences library with the namespace “wifi-creds” in read-write mode (false). It then retrieves stored Wi-Fi credentials and a counter from non-volatile storage using the keys “ssid”, “password”, and “counter”.

This part of the code checks if myssid and mypassword are empty. If they are, it stores default Wi-Fi credentials (“Engr Fahad” and ” electroniclinic”) in Preferences. Otherwise, it retrieves the stored SSID and password and assigns them to ssid and password. Finally, preferences.end() closes the namespace to free resources.

This part of the code attempts to connect the ESP32 to a Wi-Fi network using the provided ssid and password via WiFi.begin(ssid, password). It enters a loop, checking the connection status (WiFi.status() != WL_CONNECTED) and printing a dot every 500ms until it is connected. If the connection fails after 10 attempts (wificounter >= 10), it stores default Wi-Fi credentials (“Engr Fahad” and “electroniclinic”) in Preferences and retrieves them for use. The wificounter is reset, and the Preferences namespace is closed with preferences.end() to release resources. Once connected, it prints “WiFi connected!”.

If you need the full source code of the project, you can download it from my Patreon page. Anyway, I have already uploaded the code, so let’s go ahead and watch this in action.



Practical Demonstration:

Right now, both the smart watch and my phone are connected to my home’s main Wi-Fi router, and everything is set up perfectly. Let’s dive into the counter functionality and see how it works!

blynk iot platform digital tasibh or counter and Smart Watch for Couple

Using the plus button on the smart watch, I can easily increase the counter value step by step. What’s even cooler is that this value updates in real time, not only on the smart watch’s display but also on the Blynk application. Whether you are in another room or halfway across the globe, as long as there’s a Wi-Fi network, you can monitor the counter in real time. Pretty awesome, right?

Now, imagine this; when his girlfriend uses the counter for tasbih, he can feel connected to her, no matter where he is in the world. That’s a unique way to stay close to someone, isn’t it? And here’s the best part: he specifically requested that this counter value should be saved even if the smart watch restarts or turns off. I tested it by turning the display OFF and I then restarted it, and the value didn’t lost. You can practically see it in action in the video given at the end of this article.

For demonstration purposes, I have set the counter’s maximum range to 100, but don’t worry-you can easily customize it to any range you prefer.

Now, let’s talk about the reset button. She can use this button anytime to reset the counter back to zero. But here’s the smart part: I have configured the reset button’s trigger type to LONG_PRESSED. This means that even if she accidentally touches the reset button, the counter value won’t reset to 0 unless she presses and holds the button for a longer duration. This feature is a great way to prevent accidental resets.

Now, if I swipe my finger to the left, Screen2 will appear, showing a digital watch with a custom watch face designed in Figma.

adding dropdown Smart Watch for Couple

There are also two dropdown menus for setting the minutes and hours in just a few seconds. If you are curious about how these dropdown menus work or want to create something similar, be sure to check out Part 5, where I go into all the details. Trust me, it’s worth it!



If I swipe my finger to the left again, Screen3 will appear, featuring our stunning analog watch.

analog watch and Smart Watch for Couple in squareline studio

The animations and details really bring it to life! If you’re interested in learning how to animate PNG images, you should definitely check out Part 4. Not only will it help you create amazing analog watches, but it will also give you insights into designing custom gauges for your projects.

Now, if I swipe my finger to the left one more time, Screen4 appears, and this one is really special!

Smart Watch for Couple

I put a lot of effort into it because it’s designed to connect long-distance couples in a meaningful way. This screen allows two-way communication through the Blynk application, and it’s honestly one of my favorite features.

Here’s how it works: when the boy presses a button in the Blynk application, the smartwatch’s vibration motor starts to turn on and off, instantly letting the girl know that her boyfriend or husband is thinking about her.

smart bracelet and Smart Watch for Couple

And to make it even more exciting, I have added a background color toggle for a visual effect. Instead of just changing the background color, you could even add cool animations to surprise your partner. Just imagine—one button press, and your loved one feels connected to you no matter the distance!




But wait—it gets even better. This communication works both ways.

Bracelet and Smart Watch for Couple

When the girl touches the screen on the smart watch, an LED in the Blynk application starts blinking, sending a feedback notification that she is also thinking about him or is available to chat. You can even create your own secret codes for some playful and fun interaction!

What’s even better is that the notification works no matter which screen the girl is on. When the boy presses the button in the application, the smartwatch will automatically switch to Screen4, ensuring she doesn’t miss the love signal.

Compared to smart bracelets, this idea is on another level. Smart bracelets are expensive, lack customization, and don’t let you add fun features like these. With this smart watch, you have full control; change the design, check the time, and add anything you can imagine!

Lastly, let’s connect this smart watch to another WiFi network. If you remember, in SquareLine Studio, I already entered the credentials for a mobile hotspot.

Smart Watch for Couple squareline studio lvgl

Currently, the smart watch is not connected to the phone’s hotspot. So, let’s click the Apply button to save these new Wi-Fi credentials to the ESP32’s non-volatile memory.

Amazing! It worked perfectly; the smart watch connected to my phone’s hotspot without any issues.

smart bracelet and Smart Watch for Couple

Let me know in the comments what you think of this idea, and share your thoughts on what features I should add next. I would love to hear your suggestions!

So, that’s all for now!



Watch Video Tutorial:

 

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button