Introduction: Arduino Outlet Timer
Outlet timers are a great tool for keeping appliances for staying on too long, but they lack the customization that is sometimes necessary. Some appliances don't have switches at all, and making a homemade automated timer can come in real handy. For this project, I used an Arduino nano, an I2C 18x2 LCD screen, 3 buttons, a DLI outlet unit, and a 3d-printed case to create a fully customizable timer/switch for a couple of outlets.
A couple things to note:
-In this project I used an Arduino Nano, but just like many of the parts I used, they can easily be switched out for other similar parts. Using an ESP8266 could allow for wireless home automation for lights, fans, etc
-DLI's can be pricier than buying what many people normally use, a relay, but it is much safer and a much better idea. DLI's are very simple to use and are made for that purpose, messing up using a relay can result in dangerous amounts of current going where you don't want it.
Arduino Nano (I have recently switched to using Osoyoo pro micros, which are functionally very similar to Nanos and cost much less, but in this project I did use a nano)
18x2 I2C LCD screen- make sure to try to get a screen that is I2C supported. Trying to wire the full 16-pin array can be a pain
3d printed case- I will provide the STL below. This case is also meant to fit all the parts that I used and is meant to be put together using Hot Glue
All of these supplies are not optimized for prices, as they were just parts I found lying around the house. There are many alternatives to each, and I would assume you could construct this (besides the DLI outlet) with less than $10.
Step 1: Configure Wiring and Solder Components
Because I used an Arduino Nano without header pins, I soldered the LCD display on one to connect it via SDA, SCL, 5V, and GND. A note is that in the wiring fritzing the LCD display is not I2C, I am just wiring it as if the first 4 pins were as described above. For a display similar to this one, you need a special I2C adapter board to solder onto the row of pins at the top to convert it to the serial communication. Also, on the Arduino Nano SDA is pin A4 and SCL A5
The Three buttons and the DLI outlet must all share a ground connection as there are only 2 ground pins on this model of arduino (I split these wires by simply splicing the wires and soldering them together). Each button is then wired to digital i/o pins and then the positive terminal for the DLI outlet.
Step 2: Code
Below is a link to the Arduino code that runs my timer. The setup for the LCD Display is something that I got online, so I don't fully understand all the pin setups. An important thing to note about the button pins is that when connecting the buttons to ground instead of 5v, the pinMode must be set to INPUT_PULLUP (as I have done) which enables the integrated pullup resistor in the arduino. This "flips" the output of the button but it makes it very stable and also eliminates the risk of frying the board by putting 5v where it doesn't belong. To control the DLI, at least with the model that I used, it was as simple as running 2 wires into it, and sending 5v through one to switch the DLI on/off. I set the timer to have a max of 5 hours, and if you change this I would suggest changing the time value to a long instead of an int because it could overload. The way I arranged the functionality of my 3 buttons is to have one Reset/Turn off the timer (and the DLI), one to add 15 min, and one to subtract 15 min. Lastly, I have it programmed so after 60 seconds of "inactivity" (when the timer is at 0 and no buttons have been pressed) the LCD screen will shut off to prevent burning.
Step 3: Assemble
The case that I printed is designed so that each piece is hot glued into place from the inside. The screen and buttons fit snuggly into their spots (the holes for the buttons requires some sanding because of the threads on the two smaller buttons). The arduino does not have a tight casing or mount, but rather I designed the case to have a spot for it to sit so that it would be held in place by double-sided tape and could be accessed for charging/programming via (in my case) a mini usb. Finally, the back panel is designed to slide on the back and can be hot glued in place. I have attached the .stl files for the casing below.