Introduction: Day of the Week, Calendar, Time, Humidity/Temperature With Battery Saver

The power saving mode here is what sets this Instructable apart from other examples showing day of the week, month, day of the month, time, humidity, and temperature. It is this capability that allows this project to be run from a battery, without the requirement for a "wall wart".

I had posted an earlier Instructable, Humidity and Temperature LCD Display with Power Saving Mode: Minimal parts, Fun, Quick, and Very Inexpensive, and at the end of that Instructable I presented a picture of an optional modification. That modification included the day of the week, calendar, and time also shown on the same display. I received a number of messages requesting information on that augmented display. Thus, I am posting this Instructable as a modification and extension to that earlier one.

To save readers the problem of having to find the earlier Instructable mentioned, I have duplicated some of the information presented in that Instructable here, and of course am including the augmented information to allow the Day of the Week, Calendar, and the Time to also be presented in addition to Relative Humidity and Temperature. However, some readers may not need the day of the week, calendar, and time, and only need the humidity and temperature displayed. For those readers, that earlier Instructable will work well.

As I mentioned in the earlier Instructable, my study was not always at the best temperature, so I decided it would be useful to display the ambient temperature on my desk. The cost of a sensor that provided humidity, in addition to temperature, was not prohibitive; therefore a humidity display was included in that project.

An additional requirement arose as my spouse frequently asked me for the day of the week and/or the day of the month, so I decided to include these in the display as well. I made two copies of the project shown here. One for my study, and one for the room in our house where my spouse is often found. I used both a (1) real time Clock (RTC) and (2) a humidity and temperature sensor.

Both the DHT11 and DHT22 humidity/temperature sensors I considered provide temperature results in Centigrade. Fortunately it is an easy conversion to Fahrenheit (the format used in the USA, which is my location). The sketch below provides code that can be easily modified to display temperature in Centigrade, if that’s what’s used where you’re located.

I considered both the DHT22 and the DTH11 sensors, and settled on the DHT22, although slightly more expensive. The DHT11 can often be purchased for less than $2, while the DHT22 is often found for less than $5. If purchased directly from China, the cost can be even less. If I only wanted to display temperature, I could have used a TMP36 sensor instead of the DHT22, and realized some savings, and indeed this is how I built an even earlier DIY project of mine. However, I decided to include the display of relative humidity among other items displayed in this project.

The DHT22 is slightly more accurate than the DHT11. So, the slightly higher cost of the DHT22 seemed reasonable. Both DHT devices contain capacitive humidity sensors. These humidity sensors are widely used for industrial and commercial projects. While not extremely accurate, they are capable of functioning at relatively high temperatures and have a reasonable resistance to chemicals in their surroundings. They measure the changes in a dielectric that are produced by the relative humidity of their surroundings. Fortunately, the changes in capacitance are essentially linear in relation to humidity. The relative accuracy of these sensors can be easily seen by placing two of them side-by-side. If this is done it will be seen that for relative humidity they differ by, at most, 1 or 2 percentage points.

The DHT11/22 sensors can easily be substituted for each other. Depending on cost constraints, if any, either sensor can be chosen. They both come in similar 4-pin packages that are interchangeable, and as we will see shortly only 3 of the 4 pins on either package will be needed to build the desktop humidity and temperature display presented here. Although only three pins are needed for use, the four pins provide additional stability when these DHT sensors are placed/mounted on a breadboard.

In a similar manner I considered both the DS1307 and DS3231 RTCs. As the ambient temperature can affect the DS1307, I settled on the DS3231. Although the DS1307 can optionally be used. In a variety of tests comparing RTCs in relation to drift (i.e., getting the time wrong), the DS3231 came out as being more accurate, but the difference in using either sensor is not that great.

Of course, if you can easily connect to the internet in your project, you can download time directly and so you do not need a real time clock. However, this project assumes an easy internet connection is not available, and is designed to work without one.

If you are using a “wall wart” extra power consumption may not be of overwhelming importance. However, if you are powering the display from a battery reduced power consumption will extend the battery’s life. Thus, this Instructable and the sketch below provides a way, using the “Left” button on the LCD shield, to toggle the backlight on and off to reduce power consumption.

As will be seen in this Instructable, the project requires relatively few components as the majority of the “heavy lifting” is performed by the sensors and the sketch.

I prefer to use an experimental platform for many of my projects, particularly for those that will end up as displays, as this platform allows the projects to be handled and displayed as a single unit.

Step 1: The Required Items

The required items are:

- An experimental platform, although the project could be built without it, it makes displaying the final construction easier.

- A 400-tie points breadboard

- An LCD shield with buttons

- A DHT22 (AOSONG AM2302) digital temperature and humidity sensor.

- A real time clock, I selected the DS3231 (However, a DS1307 will work with the code provide here, just be sure that the GND, VCC, SDA and SCL pins are connected in a manner similar to the DS3231. That is, the DS1307 can be substituted for the DS3231 by simply making sure the appropriate pins on the DS1307RTC match the appropriate sockets on the breadboard, the Dupont hookup wires will not need to be moved. ) The primary difference between these two RTCs is their accuracy, as the DS1307 can be affected by ambient temperature which can change the frequency of its on-board oscillator. Both RTCs use I2C connectivity.

- Female headers to be soldered on the LCD shield. I used 5 and 6-pin female headers (although if you select the alternative shield, also shown here, no headers will be needed). Male header pins can be substituted for the sockets, and if used only the gender of one side of the some of the Dupont hook-up wires will need to be changed.

- Dupont hookup wires

- An Arduino UNO R3 (Other Arduinos can be used in place of the UNO, but they should be capable of outputting and handling 5v)

- A USB cable to upload your sketch from a computer to the UNO

A device such as a “wall wart” or battery to power the UNO after it is programmed. You may have many of the needed items on your workbench, although you may need to purchase some. If you have the first few, it is possible to start while waiting on the others. All of these items are readily available on-line through sites such as Amazon.com, eBay.com, Banggood.com and many more

Step 2: Preparing the Experimental Platform

The experimental platform comes in a vinyl bag containing a 120mm x 83mm Plexiglas sheet, and a small plastic bag containing 5 screws, 5 plastic standoffs (spacers), 5 nuts and a sheet with four bumpers, self-adhesive feet. All four bumpers will be needed, as will four each of the other items. There is an extra screw, standoff, and nut that are not required. However, the bag does not contain instructions.

Initially the vinyl bag is cut open to remove the Plexiglas sheet and the small bag. The Plexiglas sheet is covered on both sides with paper to protect it in handling and transit.

The first step is to peel the paper back on each side of the platform and remove the two sheets. Once the paper is removed from each side, the four holes for mounting the Arduino to the platform are easily seen. It is easiest if after peeling the paper away, the acrylic sheet should is placed with the four holes on the right and the holes closest together and near one edge of the acrylic board, toward you (as can be seen in the attached picture).

Step 3: Mounting the Arduino UNO or Clone to the Experimental Platform.

The Arduino UNO R3 board has four mounting holes. The transparent spacers are placed between the underside of a UNO R3 and the upper side of the acrylic board. Working on my first experimental board I made the mistake of assuming that the spacers were washers that should be placed underneath the Plexiglas board to hold the nuts in place - they should not. The spacers are positioned underneath the Arduino UNO board, around the screws after the screws pass through the UNO's mounting holes. After passing through the board the screws pass through the spacers and then through the holes in the acrylic Plexiglas board. The screws are terminated by the nuts enclosed in the small package. The screws and nuts should be tightened to insure that the Arduino will not move when in use.

I found it easiest to start with the hole nearest the reset button (see photos) and work my way clockwise around the Arduino. The UNO is attached to the board, as might be expected, using one screw at a time.

You will need a small Phillips head screwdriver to turn the screws. I found a socket to hold the nuts was quite helpful, although not necessary. I used drivers made by Wiha and available on Amazon [a Wiha (261) PHO x 50 and a Wiha (265) 4.0 x 60]. However, any small Phillips head screwdriver should work without problem, and as noted previously a nut driver is not really required (although it makes mounting quicker, easier, and more secure).

Step 4: Mounting a Half-size, 400 Tie Points, Breadboard to the Experimental Platform.

The underside of the half-sized breadboard is covered with paper pressed onto an adhesive backing. Remove this paper and press the breadboard, with its now exposed adhesive backing, onto the experimental platform. You should try to place one side of the breadboard parallel to the side of Arduino it is closest to. Simply press the self-adhesive side of the breadboard onto the acrylic board.

Next, turn the platform over and mount the four included plastic feet on the four corners of the platform’s underside.

Whatever experimental platform you use, when you finish you should have both the Arduino UNO R3 and a half-size breadboard mounted on it, and four feet on the underside to allow the platform and breadboard to be placed on any flat surface without marring that surface, while providing firm support to the assembly

Step 5: The LCD Shield

You can use a shield, such as the one shown earlier with pins already soldered on. However, such a shield has pins rather than sockets, so the Dupont breadboard cables must be chosen accordingly. If so, you only need to mount it onto the UNO. When mounting be sure that you mount the shield in the correct orientation, with the pins on each side of the shield lined up with the sockets on the UNO.

If you use a shield, such as the one I use here, without pins already soldered in place. Set aside female headers with 5 and 6 sockets, respectively, to solder onto the shield. The sockets of these headers should be on the component side of the shield when you solder them on (see photographs). Once the headers are soldered in place, you can proceed in a similar manner to that for a shield purchased with the pins already soldered on. I chose to use M-M Dupont cables as opposed to M-F cables, as I generally prefer M-M cables. However, you can choice to use pins on the LCD shield and not female headers, in which case you only need to change the gender on one side of the Dupont hookup cables.

Whichever shield you select to start with, when you finish you should have a shield mounted on top of an Arduino UNO. Either shield, the one with pre-soldered pins or the one you soldered yourself with female headers (or male headers if you choose) uses quite a few digital pins. Digital pins D0 through D3 and D11 through D13 are not used by the shield, but will not be used here. Analog socket A0 is used by the shield to hold the results of button presses. Thus, analog pins A1 through A5 are free to use. In this project, to leave the LCD display completely unobstructed I used only the analog sockets and did not use any digital inputs.

I found it easiest to use a breadboard with male headers to hold the female headers for soldering (see photographs).

Digital pin 10 is used for the LCD’s backlight display, and we will use it in our sketch to control power to the LCD when the display is not in use. Specifically, we will use the “LEFT” button on the shield to toggle the backlight on and off to save power when the display is not needed.

Step 6: Using the DHT22 Humidity and Temperature Sensor

Insert the four pins of the DHT22 into the half-size breadboard, thereby mounting the sensor on the breadboard.

I numbered the DHT22 pins 1 to 4 as shown in the included photograph. The power to the sensor is provided via pins 1 and 4. Specifically, pin 1 provides the +5v power, and pin 4 is used for ground. Pin 3 is not used, and pin 2 is used to provide the information needed for our display.

Connect the three pins that are used on the DHT22, using their associated sockets on the breadboard, to connect to the shield, and thus the Arduino UNO as follows:

1) Pin 1 of the sensor goes to the shield’s 5v power socket,

2) Pin 4 of the sensor goes to one of the shield’s GND connectors,

3) Pin 2 of the sensor, the data output pin, goes to analog socket A1 (compare this to my earlier Instructable where it went to digital socket 2 on the shield). I used an analog socket rather than a digital one here to leave the LCD screen completely unobstructed. It is useful to remember that all analog pins can also be used as digital pins. Although here A0 is reserved for the shield buttons.

The DHT22 sensor can only provide updated information every 2 seconds. So, if you pole the sensor more than once every two seconds, as can occur here, you may get results that are slightly dated. For homes and offices this is not an issue, particularly as the relative humidity and temperature are displayed as whole numbers without decimals.

Step 7: Adding the Real Time Clock (RTC)

I used the six pin side of the DS3231, although only four pins are needed. This was to provide even more stability for this RTC when plugged into the breadboard. An attached picture shows the CR2032 battery that needs to be plugged into the DS3231 RTC to allow it to retain information even when unplugged from another power source. Both the DS1307 and the DS3231 accept the same style CR2031 button battery.

The connections for the DS3231 are as follows:

- GND on the DS3231 to GND on the LCD shield

- VCC on the DS3231 to 5V on the LCD shield

- SDA on the DS3231 to A4 on the LCD shield

- SCL on the DS3231 to A5 on the LCD shield

When you finish you will have Dupont cables plugged in A1 (for the DHT22) and A4 and A5 for the SDA and SCL pins of the RTC.

I have also included a picture of the optional DS1307 showing the pins that would need to be connected. Although it cannot be read from the photo, the small IC closest to the unsoldered "holes" is the DS1307Z that is the RTC. The other small IC that can be seen is an EEPROM that can be used for storage; it is not used it in the sketch below.

Both the RTCs consume very little power, in the nanoamps range, so the real time clocks will retain information and not run short of power if they are run only off internal batteries. It is probably best to change the button battery every year, although the current drain is so low for both RTCs that they might possibly hold their charge for several years.

Step 8: The Sketch

This site removes less than and greater than symbols and the text in between these symbols. Thus I have not tired to include the sketch in the text here. To see the sketch as written, please download the attached text file. Seconds are not shown in the sketch, but are sent to the hidden buffers on the 1602 LCD just beyond the display buffers. Thus, if seconds are something you want to display, just continuously scroll the display left and then right.

In the sketch I included a header file for the DS3231, and I define an object of the DS3231 type. This object is used in the sketch to periodically retrieve the day of the week, month, day, and time information required. This information for day of the week, month, and day of the month is assigned to char variables, and then the results stored in these variables is printed on the LCD. The time is printed out in full, but the seconds portion of time, as discussed earlier, is sent to the non-display 24 character buffers on the 1602 LCD, just past the displayed characters. As noted above, only the hours and minutes are displayed and the seconds are hidden at the early part of these 24 character buffers.

The LCD backlight can be turned on when needed, and left off otherwise. Since the display is still active even with the backlight off, it can be read with a strong light even if off. That is, the backlight need not be on to read the information presented on the LCD, which continues to update even if toggled off.

In the sketch, you will see the line:

RTC.adjust(DateTime(2016,07,31,19,20,00));

This uses an object of the type RTC_DS1307 and allows us to easily set the the current date and time. Please enter the appropriate date and time on this line when you run the sketch. I found that entering a minute past the current time, shown on my computer, resulted in a quite close approximation to the actual time (it takes the IDE a little time to process the sketch, and about 10 seconds additional for the sketch to run).

Step 9: Displaying the Assembled Project

I mounted my assembled project on a business card holder (see photograph). The business card holder was available in my ‘odds and ends’ collection. As I have many of these holders, I used one here. However, the assembled project could just as easily be displayed on a mobile phone holder, etc. Any holder that takes the assembled project from a flat position to an angle of 30-60 degrees should work as well.

Step 10: Afterwards

Congratulations, if you followed the steps above you now have your own display showing the day of the week, calendar, time, relative humidity and temperature.

If you found this Instructable of value, and particularly if you have any suggestions for improvement or to increase my knowledge in this area, I would be pleased to hear from you. You can contact me at transiintbox@gmail.com. (please replace the second 'i' with an 'e' to contact me.