Introduction: Arduino Shower Monitor 2
“Since this Lazy Old Geek (LOG) is getting Old, he(I) forget things. Now I like to take a shower every other day but can’t remember if it’s shower day or not. I could mark it on a calendar (paper or computer) or I could even have the calendar alarm me but for various reasons, sometimes I will want to shift my schedule. Well, my MD said my memory was okay for my age, so I decided to make a little Shower Monitor.”
So I built this:
This worked pretty well but lasted only about ten days. So I decided to make Shower Monitor 2.
Step 1: Design RTC
Real Time Clock
I didn’t like my first design as the batteries would only last about ten days, so I wanted a design that would last longer.
Technobabble: The reason batteries didn’t last long is that I had to keep power on the AtMega328 (Arduino) continuously to keep the software real time clock running. So I need to be able to put the AtMega328 to sleep or turn it off.
My friend sent me some of these RTC (Real Time Clock) modules:
These come with an RTC with battery backup and an EEPROM which is also helpful.
Problem: So I have a concern about these modules. Note that the battery is an LIR2032 which is a rechargeable battery. I suspect that it has a charging circuit. Well, I found a schematic and decided to draw my own (see picture). It does have a charging circuit and it would put an additional load on the 18650 battery.
Solution: So for this module, if you remove R5, D1, R4 and R6 and put a jumper across R6 and replace the battery with a CR2032, this will eliminate the battery charging. So that is what I did (see picture).
In this application, the CR2032 is supposed to last about ten years so I have no problem with that.
Warning: I was using an old library from AdaFruit for their datalogger called RTCLib. There was a sketch called DS1307.pde that would set the time. Now this worked fine the first time it was run but then it wouldn’t set the time. There is an updated version with an example that works better:
Download the zip, unzip it, rename it from rtclib-master to rtclib and copy it to your Arduino libraries directory.
TechnoSpeak I2C: Technically it should be I(squared) C or IIC which stands for Inter-Integrated Circuit. Basically it is a ‘standard’ serial interface requiring two signals SCL, SDA and ground. SDA is the data signal switching from 0V to 5V with the data going across in sequence (serially). Since there are only two levels and the speed isn’t determined, there is no way to determine where one bit of data ends and the next begins. That is where the SCL (clock) signal comes in. This tells the receiving device where one bit ends and the next begins.
One advantage to I2C is that several devices can be attached to the same two signals. In this case the DS1307 (RTC) and the 24C32 (EEPROM) are both attached to the SCL and SDA lines. In order to tell which device you are talking to each device type has a unique address.
The DS1307 address is 0x68. The 24C32 address is 0x50.
Arduino supports I2C with the ‘wire’ library.
By the way, what this means is that you can’t have more than one of the same device type on the same two lines. E.g., you can’t have two 24C32s.
Step 2: Design Solar Boost
Problem: So the RTC modules require 5Vdc and I want it to work with an 18650 battery that goes from 4.2Vdc down to about 2Vdc.
Solution: So there’s some little Solar Boost modules that fits the need:
I do not know why they call them Solar Boost. Basically, they take a DC voltage from 1-5Vdc and convert it to a 5Vdc voltage.
Now there are many versions available. I’m guessing most all should work for this application.
I unsoldered the USB connector as it’s not needed. (see picture). As labeled the two outer USB pins are ground and 5V.
Step 3: Design ShowerMonitor2 PCB
So naturally being a Geek, I decided to make my own ShowerMonitor2 PCB with an Arduino on it. (see picture) This PCB ties the Solar Boost and the Tiny RTC together and displays the Day of the Week and Shower status.
Problem: I wanted to turn on the power with a pushbutton, have the Arduino hold the power on until it displayed the day of the week and the shower status and also be able to toggle the shower status with another pushbutton. Then turn off the power to the PCB.
Solution: The next picture is a block diagram of the power circuitry.
TechoSpeak: The battery ground is connected to the PCB and to the ground on the Solar Boost (on this Solar Boost, the PS- and GND output are tied together so either one can be tied to the PCB).
To turn on the Arduino PCB, push the Start button. This passes the positive battery voltage to the Solar Boost which turns on and supplies 5Vdc to the PCB. The Arduino sketch pulls D3 high which turns on the BS170 FET. This allows current to flow applying most of the battery voltage to the Solar Boost. So the Start switch can be released.
After a short delay for the user to see the day and Shower status, the Arduino sets D3 low which turns off the FET and disconnects power to the Solar Boost which disconnects power to the PCB.
Power Summary: So most of the time, the Arduino is unpowered. The TinyRTC has it’s own battery to keep the correct time. The EEPROM stores some Shower information and doesn't need power. Most of the time there is negligible drain on the 18650 battery. When the Start button is pushed, the Solar Boost is powered by the 18650, the Arduino reads the RTC, lights the day of the week and the Shower LED if appropriate. After about five seconds, the Arduino disconnects the battery and shuts itself down.
TechnoSpeak: EEPROM stands for Electrically Erasable Programmable Read Only Memory. What that means is that we can store information in it. This information will stay there with or without power. So the next time we apply power we can read the information that was stored earlier. No battery is required.
Note: I added a two pin header labeled ‘Prog’. If a jumper is attached, this will continuously power the Arduino so the user can load a sketch to the Arduino and troubleshoot if needed.
Okay, so I made the PCB and stuffed it. I installed different colored LEDs for the days of the week so it’s a little easier to distinguish one day from another. (My eyesight isn’t the greatest)
Problem: For the TinyRTC library part, I outlined the physical dimensions of the board. Unfortunately, when I was trying to make the PCB smaller, I forgot this so the Start button was underneath the Tiny RTC board. This is what happens when I’m tired and didn’t check it thoroughly.
Problem2: Well the TinyRTC has the battery on the bottom side. With a female header, I thought it would clear the AtMega328 but it did not.
Solution: I had some long stemmed female headers from my friend (see picture). I bent the pins in an ‘S’ shape so the TinyRTC board was up higher and away from the Start button.
Problem3: Well this worked pretty good, but when I had this hanging on the wall, it’s hard to reach the Start button.
Solution2: If you look at the TinyRTC module, it has two connectors. One is seven pins and the other is five but the five signals are duplicated and in the same sequence. And I’m only using four of these anyway. Well I decided to remove the female header, install five pin male header on the other side and solder them in. It worked fine and it was easier to reach the Start button.
Eagle files are attached
1 Tiny RTC_DS1307 & AT24C32 module
1 Solar Boost 1-5Vdc to 5Vdc output
1 18650 Battery
1 18650 Battery holder
1 Shower Monitor2 PCB (Can be made with Eagle Cadsoft files)
1 ATmega328P microprocessor
1 28 pin IC socket
6 Male header pins
2 Tactile SPST switch
2 Capacitor 0.1uFd
2 Capacitor 22pFd
1 Cylindrical crystal 8MHz
8 LED 3MM (assorted colors)
1 BS170 FET
2 Resistor 10K
8 Resistor 1.5K
1 JST2.0 connector set (male/female)
Most parts are available from Digikey, ebay other electronics outlets.
Step 4: Arduino Software
Problem: The standard bootloaded AtMega328P will not work with an 8MHz crystal. A different bootloader is needed.
Solution: I basically used this procedure to load the correct bootloader:
Warning: When loading sketches under Tools>Board menu, you must select Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328
I put a label on my AtMega328 to help remind me of what I am using.
The TinyRTC module uses a DS1307 IC for the Real Time Clock. For the Arduino, you need a library. There are many, but I chose this one:
First, you must set the correct time/date in the TinyRTC module. Make sure a CR2032 battery is installed.
Put a two pin jumper on Prog.
Run my SetRTC sketch. Open the Serial Monitor to make sure this is set correctly.
Now load the ShowerMonitor2 sketch.
Remove the two pin jumper.
Setup: Set poweron high so that the SolarBoost stays on.
Loop: Read data stored in 24C32-EEPROM.
Read RTC to get correct time/date.
Turn on correct day of week LED.
Figure out if Shower LED should be on or not.
Check to see if Shift is pressed.
If it is then toggle Shower and send to EEPROM.
After about five seconds turn poweron off thus turning off Solar Boost and Arduino.
Step 5: Using Shower Monitor 2
So being Lazy, I used double sticky tape and stuck the battery and PCB on a piece of plastic. I drilled a couple of holes, strung a piece of wire and hung it on a nail.
Procedure: So the Shower Monitor2 is normally off.
Press and hold the Start button. The power LED on the Solar Boost will turn on, then one of the days of the week LEDs will turn on. Release the Start button. If the Shower LED is lit, it’s shower day.
The Shower Monitor will shut off after about four seconds.
Changing Shower Day: If you want to change Shower day, press and hold the Start button until you get a day LED, then press and hold the Shift button until the Shower LED toggles.
Troubleshooting: If no LEDs come on, it’s (hopefully) the battery. Replace with a charged 18650.
If the day of the week is off, load the setRTC sketch to set the time, then reload the ShowerMonitor2 sketch.
Participated in the