Smart Glass Counter - a Step-by-Step Arduino Hydration Tracking Project
by rohanbarnwal in Circuits > Arduino
267 Views, 4 Favorites, 0 Comments
Smart Glass Counter - a Step-by-Step Arduino Hydration Tracking Project

.jpeg)


We all know water is essential for our health — but in the middle of busy day, it's easy to forget to drink enough. The Smart Glass Counter is my solution to this problem. It uses sensors to detect when you have taken a glass of water, keeps count, and even reminds you with sound signals if you're falling behind.
The project is powered by the Arduino UNO R4 Wi-Fi, an IR sensor, and an XKC-Y26-V contactless water level sensor, along with a buzzer for sound notifications. Once you've reached 6 glasses in a day, it plays a victory tone — motivating you to keep up the habit.
Why This Project?
- Encourages Healthy Hydration: Drinking enough water daily supports digestion, energy levels, and skin health
- Automatic Tracking: No need to manually log your intake - the system does it for you.
- Reminders You Can't Ignore: A buzzer makes sure you get up and drink water.
- Motivational Goal: Reaching 6 glasses triggers a celebration sound, giving you a small dopamine boost.
Why 6 Glasses of Water
While exact hydration needs vary from person to person, 6 glasses (~1.5 liters) is often considered a minimum daily goal for most adults. According to health experts:
- It helps maintain body temperature
- Aids digestion and nutrient absorption
- Improves skin health
- Keeps joints lubricated.
- Reduced fatigue and headaches caused by dehydration.
This project can be adapted for 8-10 glasses depending on your hydration goal.
What This Project Taught Me
Building the Smart Glass Counter was more than just connecting wires and uploading code - it was a hands-on lesson in problem-solving, sensor calibration, and designing technology that's both functional and impactful.
- Sensor Synergy Matters - Using both the IR sensor and the XKC-Y26-V contactless liquid level sensor showed me how combining different types of sensors can give more reliable results than using just one.
- Debouncing Isn't Just for Buttons - I discovered that even with sensors, you sometimes need a "setting time" to avoid false triggers - hence the 1 second wait after detecting a glass.
- User Feedback Is Everything - Adding reminder tones, count sounds, and victory tunes made the project feel more interactive and kept me motivated to actually use it.
- Design Aesthetics Count - Thanks to JUSTWAY's multicolor printing, I learned how much a clean enclosure and branding can make a DIY project feel like a professional product.
- Health Meets Tech - Most importantly, I realized how electronics can directly improve daily habits - this builds actually helped me drink more water and feel better throughout the day.
Social Impact
While the Smart Glass Counter is great for personal use, it also has potential to make a difference in communities:
- Elderly Care: Many seniors forget to drink enough water. This device could serve as a gentle, automated reminder to prevent dehydration.
- Office Wellness Programs: In workplaces, this can encourage employees to maintain hydration, improving productivity and reducing fatigue.
- Schools & Children: Teaching kids about hydration in a fun, interactive way can help build lifelong healthy habits.
- Medical Recovery Support: For patients recovering from illnesses or surgeries, staying hydrated is crucial - this device could help them keep on track.
By blending technology with wellness, this project has the power to promote healthier lifestyle at both an individual and community level.
Supplies
.jpeg)

.jpeg)
.jpeg)
.jpeg)
Here's what I used to build my Smart Glass Counter:
- Arduino UNO R4 Wi-Fi x1: Main microcontroller board to process sensor data and control buzzer.
- XKC-Y26-V Contactless Liquid Level Sensor x1: Detects the presence of water in the glass without physical contact.
- IR Sensor Module x1: Detects whether a glass is placed in the designated spot
- Buzzer x1: Produces reminder tones, count confirmation sounds, and victory tones.
- Jumper Wires (As Needed): For making connections between components
How It Works - Step-by-Step
Here's the full breakdown of the logic:
System Startup

When powered on the Arduino plays a Power-On Tone to confirm it's working
Reminder Mode Activated

The buzzer beeps every 3 seconds to remind you to place a glass on the spot.
This mode continues until the IR Sensor detects a glass.
Glass Detection

IR Sensor: Checks if a glass is present
If detected, the reminder stops temporarily.
Stability Check (1 Second)
After detecting a glass, the system waits 1 second to avoid false triggers from hand movement.
Water Check (3 Seconds)
XKC-Y26-V Sensor: Checks if water is present.
If no water is detected for 3 continuous seconds, it counts as one glass consumed.
Count & Feedback

Count Tone: Plays a short beep sequence when a glass is counted
The glassCount variable increases by 1
If water is still missing. reminder mode resumes.
Victory Condition

Once you reach 6 glasses the system plays a Victory Tone and resets the counter 0
Reset Logic
If the glass is removed or water is detected, the alreadyCounted flag resets, allowing for the next count cycle.
Circuit Diagram

IR Sensor To Arduino Board
- VCC to 3v3
- GND to GND
- OUT to D3
XKC-Y26_V Sensor To Arduino Board
- Blue Wire To GND
- Brown Wire To 5v
- Yellow To D2
Buzzer To Arduino
- -ve Pin to GND
- +ve Pin to D8
Making It Look Professional - JUSTWAY to the Rescue
.png)
Most DIY electronics project look messy - but for me presentation matters. I wanted my Smart Glass Counter to look like a finished product.
That's why I used JUSTWAY's custom manufacturing services to design and print a compact enclosure for my project.
Why JUSTWAY?
- Instant Quotes: Upload CAD files and get pricing instantly.
- 3D Live Model Preview: Rotate, zoom, inspect every detail before production.
- Material Variety: SLA resin, Nylon PA-12, CNC aluminum, and more.
- Industrial-Level Finish: Smooth, precise, perfect fit.
- Expert Support: Engineers review your designs before production.
NEW for 2025 - Transparent 3D printing & Multicolor Printing
Transparent 3D Printing Materials it's great for showcasing internal electronics)
- High-clarity resins for seeing sensors, LEDs or inner mechanisms.
- Perfect for educational builds or prototypes where visibility matters.
Multicolor 3D Printing (Used for my black Arduino logo)
- Prints multiple colors in one part - no painting required.
- Adds branding, labels, or style directly into the enclosure.
- My enclosure features a crisp black Arduino logo for a polished, branded look.
JUSTWAY 15% Summer Cashback
Campaign Period: June 1 - August 31, 2025 (UTC)
Get 15% cashback on all qualifying orders.
- After order completion, email marketing03@justway.com with your order number.
- Cashback is credited to your JUSTWAY account for future orders.
How I Ordered My Custom 3D Printed Model from JUSTWAY
Upload Design

Go to the JUSTWAY site, upload STL/CAD files
Select Material & Finish

Chose sturdy plastic with black color logo
Preview Live Model

Verified fit an logo placement before production.
Place Order

Confirm knowing the part would look exactly designed
💡 Pro Tip: If you want your Arduino projects to look market-ready and branded, JUSTWAY’s multicolor printing is the way to go — and if you ever want to show off your electronics inside, their transparent printing is perfect.
Code
This Arduino code controls a hydration reminder and tracking system using an IR sensor, a water sensor, and a buzzer. It plays periodic reminder beeps if no glass or water is detected, checks for an empty glass placed in position, and counts it as a “glass consumed” after a short verification period. The buzzer provides audio feedback for startup, reminders, counts, and milestones, resetting after six glasses.