Uni-timer is an Arduino hardware based universal timer-unit with 4 relays, which can be programmed to switch on and off individually or in group at 24 different time periods .
The purpose of the project was to build an ultra cheep programmable timer, which will control a sprinkler system, but happened to be useful for other applications what include timing. The smallest timing scale is 1 minute.
The circuit is made from few cheep modules. The timing can be set via Bluetooth with an Android application also written by yours truly.
Step 1: Preparation. Tools and Consumables.
- Solder iron
- Cable cutter
- USBasp AVR programmer + software (or any other programmer)
- Programmer 10 pin to 6 pin converter
- FTDI 232 module (4 jumper cable + breadboard) + Arduino serial monitor or Putty software
- Android phone
- Solder wire
- Recycle some old computer IDE cable
- Test circuit board 2cm x 1cm (not essential)
- 1K resistor 3 pieces
- CR2032 battery
Step 2: Preparation. Electronics.
- Arduino Uno or some clone (microcontroller module, the brain of the circuit) - ebay
- Tiny RTC (small real time clock module) - ebay
- HC-05 Bluetooth module (Bluetooth serial module) - ebay
- 4 relay shield for Arduino Uno (like in the picture above) - ebay
- DC 9V power supply (depending on your country) - ebay
Step 3: Preparation of the Bluetooth Module
Before we assemble the circuit the Bluetooth module has to be prepared to communicate with the Android device and the Arduino Uno. This can be done by serial communication with the module, and a few AT commands.
To send the AT command to the Bluetooth module you have to connect it with an FTDI 232 module like in the circuit above. (FTDI232 is a serial to USB converter, appears as a virtual serial port on the computer)
For this use a bread-board and a few wires. On some Bluetooth modules the B1 button is soldered on the circuit from factory.
Preparing the Bluetooth module:
- Press the B1 button and keep it pressed, connect the USB cable of the FTDI232 to the computer, release the B1 button. (now the Bluetooth module entered AT mode) Start the Arduino software.
- Select the proper communication port for FTDI232 and start the Serial monitor of the Arduino software.
- Set baud-rate to 38400.
- Set it to send : carriage return and line feed
- Type AT press enter, if the circuit responds OK we are in business. :) If not, start at point 1.
- Next we set the name of the Bluetooth device, which will appear in the Bluetooth devices list of the Android phone. Type AT+NAME=UNITIMER press enter. It has to be UNITIMER because the android app will search for this name.
- Set pin code of the Uni-timer: Type AT+PIN=1234 or any 4 digit number and press enter. (will be essential at pairing of the device in Android, so memorize the number)
- Baud-rate is set to 9600 from factory but you can set it by typing AT+UART=9600,0,0.
- Type AT+RESET press enter to log out from AT mode and we are done.
Step 4: Assembling and Burning the Program
Assembling the circuit:
Use the picture above. Cut 8 cables about 8 cm long and solder them on the Arduino board, like shown in the picture. Use the test board to add the 3x1K resistors to the RX pin of the HC-05 Bluetooth module. That is the cheapest way to connect a 3V RX pin to an 5V TX output. (TTL level matching, no resistors circuit will burn) Arduino RX can listen to a 3V TTL level at this slow speed.
The remaining 4 ends of the wires go to the TinyRTC module. (our clock)
Plug the 4 relay shield and you are done with the circuit. Plug the CR2032 battery in the socket on the TinyRTC module. The battery is to keep the clock running even without power adapter connected.
Burning the program:
Unfortunately I had to get rid of the Arduino bootloader to free up space, because the sketch started to be unstable, but without the bootloader works as expected. So you can not just upload it to the board, has to be burned with an AVR programmer (USBasp). The sketch can drive 8 relays but this is a simplified version.
I'm not gonna go in too much detail here, how to burn the program, is written all over the internet.
My advice: Don't change the AVR-s FUSES.
Connect USBasp (or any suitable type) programmer to the Arduino board and use your software to upload de hex file below. You have to use a 10-6 pin adapter or some cables to connect to the programming pins of the Uno board. Disconnect the USBasp. (while burning the program, Arduino board is powered via the programmer, if not use the 9V power adapter)
Plug the 9V adapter, if all went fine the LED on the Arduino board will start to flash fast, and the LED on the Bluetooth module will flash somewhat slower.
The circuit now is ready to receive the setup. The setup is stored in the incorporated eeprom of the ATmega 328 chip on the Uno board.
Step 5: Upload, Download the Setup by Android App
Download and install the Uni-timer.apk on your Android phone. You have to use USB cable to accomplish this and enable Unknown sources from setup of the Android device. Here is how and why.
I' m still working on gathering founds to have the app uploaded to play-store. Google charges some money for that. Also I will make the app for Apple devices, if happens to be liked by people.
First of all you have to download the app and install it on your android device.
Plug in the power adapter, now the circuit is on.
Start Bluetooth on the android device and search for new devices.
Pair the UNITIMER device, witch will ask for a 4 digit pin code. ( that's the code you entered for Bluetooth pin.)
Start the app. Tap Download setup button. The app in a short while will make a connection to the Uni-timer and present you an alert window with "Setup was downloaded". If this didn't worked will give a connection error, or ask permission to Bluetooth.
If everything went fine tap the OK on the alert window, in a few moments the app will populate the setup form with the downloaded data. (at first time will be empty)
Modify the programs you want to use, in the rest remove the check-marks from the days.(Do not overlap the programs on the same day. That is discussed here.)
Tap Upload setup, you get an alert window, if everything went OK then you get an alert window with "Setup was uploaded ", if not, you get an alert with the number of the faulty program. (correct the program and repeat the process)
If program was uploaded tap the Quit button to close the app. You are done.
With the app you can modify the setup anytime.
Now you have to wait for the relays to activate at the set time. The output of the relays are the green sockets.
Important!!! Beware not to exceed at AC120V 3A or at AC240V 1,5A (DC24 3A) switching current.
More explicit Users Guide is here.