Drinking enough water is very important for our health. Drinking more water can lead to clearer skin, better overall health, improved productivity and brain function, increased energy levels, and even weight loss.
In our busy lives, it is really hard to remember to drink enough water. And most of the time we forget to drink enough water whether we are in the home, office or on-the-go. Around 75% of Americans are chronically dehydrated all the time.
So, in order to build a healthy water drinking habit, it’s important to track your water intake every day.
To track my water intake I made my water bottle smart using Arduino. It can:
1. Track my daily water intake
2. Track my weekly average water intake
3. Remind me to take water
4. Track last intake time
5. Run more than one month in a single charge.
Making RTC ModuleTo log or track water intake information, it requires current time and date information to be stored along with the accumulated data. A Real-Time Clock (RTC) chip such as DS1307 with a suitable back-up battery can be used to supply the required information. The programming process of the RTC chip (in software) is also very simple and is supported in the majority of programming environments.
Here is the design of a compact RTC module, based on the popular RTC IC DS1307, for your everyday microcontroller projects. The DS1307 serial real-time clock (RTC) is a low power, full binary coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I2C, bidirectional bus. The 24-hour/12-hour format clock/calendar provides seconds, minutes, hours, day, date, month, and year information, including corrections for leap year.
Let's make the real time clock module according to the attached schematic. DS1307 RTC requires an external crystal to operate correctly. Two pull-up resistors are required for SCL & SDA pin of the IC. The value of the resistor may be around 2k to 10k. I used 4.7k. During soldering I tried to keep the module as small as possible because space is limited for my circuit. You can use DS3231 instead of DS1307 and the IC has an internal crystal oscillator. So, you need not to add any external crystal. You may also buy a ready-made tiny RTC module if you don't like to make it own. As the complete system will be operate from battery, for that reason I connected VBAT pin of the RTC to ground without using coin cell.
Important Pins of DS1307:
- 5V Pin: When this pin is high, then the ds1307 sends the data, and when it is low, it runs on the backup button cell.
- GND: This is the ground pin for the module. Both the ground of the battery and the power supply are tied together.
- SCL: It is the I2C clock pin - which communicates with the microcontroller. Should connect with Arduino SCL pin.
- SDA: It is the I2C data pin - which communicates with the microcontroller. Should connect with Arduino SDA pin.
- VBAT: Battery input for any standard 3V lithium cell or other energy source. Must be grounded if not used.
For the display module here I used a self-contained, compact common-cathode module containing four 7-segment LED numeric displays good for displaying numerical data with some simple character.
Each segment in the display module is multiplexed, meaning it shares the same anode connection points. And each of the four digits in the module have their own common cathode connection point. This allows each digit to be turned on or off independently. Also, this multiplexing technique turns the massive amount of microcontroller pins necessary to control a display into just eleven or twelve (in place of thirty-two)!
The LED segments of the display require current-limiting resistors when powered from a 5 V logic pin. The value of the resistor is typically between 330 and 470 ohms for 5 V. For Li-ion battery operation it may be 220 ohms. And, driver transistors are recommended to provide additional driving current to the LED segments, because each pin of a microcontroller can source or sink near 40 mA of current only. When all (seven) segments of the display turned on at once (the numeral 8), the current demand will exceed this 40 mA limit. The image shown below indicates the basic wiring diagram of the current limiting resistors and driver transistors.
This 4 -digit 7-segment display section is wired around four common-cathode 7-segment LED displays, and four 2N2222 NPN transistors. The 1K resistors are used for base current limiting, and the 220R resistors limits the operating current of the LED display segments.
In the Arduino board, digital outputs from D10 to D17 are used to drive segments (a to g & dp), and digital outputs D6 to D9 are used for the digits (D0-D3) of the 4×7 LED display.
A button switch is added with the display module to access different options. It will also used to wake up the Arduino from sleep mode using external hardware interrupt. so, button is connected to Arduino digital pin #2 (INT0).
Connecting Display Board with Arduino Mini ProAccording to the schematic provided before solder all the segments pin to the Arduino mini pin. Then solder 4 common pin to the collector pin of the transistor. Transistor's bases are connected to Arduino pin. After connecting the display connect the button switch with the Arduino digital pin 2 (INT 0). Be sure you connected button to Arduino pin 2 because we will implement external hardware interrupt to wake up Arduino from sleep mode using this button.
Now, connect the RTC module you made earlier to the Arduino board. SDA pin of the module must be connected to SDA (A4) pin of the Arduino pin and SCL pin of the module must be connected to SCL (A5) pin of the Arduino. Then connect the buzzer to the Arduino board.
Connections:
RTC ------> Arduino Mini Pro
- SDA ------> A4
- SCL ------> A5
- Buzzer ------> D3
Make a hole into the bottle cap as shown in the image. Bring out four wires of the ultrasonic sensor through the hole and fixed the ultrasonic sensor at the middle of the bottle cap. Sensor must be attached in the inner side of the bottle cap and it should be place at the center position.
Connections:
Ultrasonic Sensor ------> Arduino Mini Pro
- VCC ------> VCC
- GND ------> GND
- Trigger ------> D4
- Echo ------> D5
After completing all the connection it is the right time for uploading program to Arduino board and testing the functionality. You will be required several library for the program to work correctly. For button interfacing you need to add OneButton library. As the device will operate from battery, power consumption is an important issue. I implemented sleep mode to my Arduino sketch. Watchdog timer and external hardware interrupt was used to wake up the Arduino from sleep mode. Arduino takes sensor reading for three times, average it and calculate the necessary information and display information for 10 seconds and then go to the sleep mode for 1 minutes. It wake up any time on button pressed connected to INT0 (digital pin 2). So, if you want to see the information about your water intake just press the option button any time. It will wake up for you. Without any button press it will take reading every 1 minutes. For implementing sleep mode I used Arduino Low-Power library. For reading time from DS1307 RTC module I used DS1307RTC library. So, for compiling the attached program add all the library to your environment.
I will explain here only the calculation algorithm in brief. See the attached fill for complete sketch. Calculation is done from the average of five sensor readings to make it accurate enough. Daily reading is reset at 24 hours and prepared for new reading for new day.
Average water intake is prepared from the average of previous seven day's daily intake. You 2 hours passed without intake of any water it will alert the user with double beep in every 15 minutes and stops for next 2 hours after taking in water.
Download the attached code and upload it to your Arduino Mini Pro. Connect all the module and power it up to test either all components is working correctly or not. If the display shows some result, then congratulations! You've already done the hard things.
Fixing Arduino with Bottle CapUsing hot glue attache Arduino mini to the upper side of the bottle cap. Keep in mind that you have to fix all the component into the bottle cap. Add enough glue so that it tightly attached to the bottle cap.
Now, fix the Li-ion battery in the top of the Arduino. Be careful about shorting the battery with any open pin. Then connect the charger module with the cap. Keep the USB port easy accessible from the outer side so that it can be connect easily to the charger.
After connecting all the components and module it it the right time to make our device completely water proof. It is very important because it is water bottle and any time water can be drop to the circuit and may damaged the circuit. To make it completely waterproof add enough glue in every outer part of the circuits without the USB port. You can make the cap nice using glue to make it round at original cap.
Don't sink the bottle cap in the water.
Enjoy It
Comments