Arduino: Time Programs & Remote Control From Android App

by maroonbells.apps in Circuits > Arduino

5827 Views, 43 Favorites, 0 Comments

Arduino: Time Programs & Remote Control From Android App

IMG_20200308_163915.jpg

I've always wondered what happens with all those Arduino boards that people don't need after they finish their cool projects. The truth is a bit upsetting: nothing. I've observed this at my family's house, where my father tried to build his own home automation solution but since he's an electrician he couldn't get over the programming part.

In this project I'm trying to address the problems he faced:

  • Programming is hard.
  • It takes time to build valuable software.
  • Home made apps look boring and aren't user friendly.

It took couple of months to get it right, but the project was worth it. I intend to solve my father's problem by providing an Android app which connects over bluetooth and supports time programs, scenes & manual control out of the box without any programming knowledge. Let's start!

Supplies

Hardware:

  • 1x Arduino Uno
  • 1x HC-05 bluetooth module
  • 1x DS1302 RTC module
  • 1x Breadboard
  • 3x Resistor 1k ohm (can be also 220 ohm or 10k ohm)
  • 1x USB 2.0 cable type A/B
  • 12x Jumper wires
  • Smartphone with Android 5.0+ (bluetooth available)
  • Laptop/PC

Software:

Upload Bluetooth Module Configuration

IMG_20200308_164922 (1).jpg
Screenshot 2020-03-08 at 17.03.49.png

First, you must configure your bluetooth adapter from your laptop/PC. Connect Arduino board to USB port of your computer. Launch Arduino IDE, open new sketch, copy & paste the code below.

Code:

void setup() {
  Serial.begin(38400);
  delay(500);
     
  Serial.println("AT+NAME=Arduino_Maya");
  delay(500);
  
  Serial.println("AT+BAUD=115200,0,0");
  delay(500);
  
  Serial.println("AT+POLAR=1,0");
  delay(500);
}

void loop() {
}

Make sure these options are selected in your IDE:

  1. Tools → Board → Arduino Uno
  2. Tools → Port → the port to which you connected Arduino

Compile and upload the program.

Connect Bluetooth Module

Maya Arduino - only BT_bb-1.jpg
IMG_20200308_174945.jpg
IMG_20200308_175120.jpg
IMG_20200308_175316.jpg

Connect your HC-05 as presented on the scheme. General instructions:

  • VCC connects to Arduino 5V pin.
  • GND connects to Arduino GND pin.
  • TXD connects to Arduino RXD pin.
  • RXD connects to Arduino TXD pin through voltage divider as the logic voltage level of the data is 3.3V. Arduino TXD (transmit pin) is 5V, therefore if you won't use voltage divider, you'll burn your module.

Setup HC-05 Module

aestdb.jpg

In this step we'll apply the configuration from step 2 to the bluetooth module. Follow these instructions:

  1. Disconnect USB cable from your computer.
  2. Press and hold the KEY button on your HC-05 module for 5 seconds while connecting USB cable.
  3. Click RESET button on your Arduino board.
  4. Wait 10 seconds before the configuration is applied.
  5. Disconnect USB cable and connect it again.

Connect DS1302 RTC Module

Maya Arduino_bb-1.jpg
IMG_20200308_184619.jpg
IMG_20200308_184525.jpg

Connect your DS1302 as presented on the scheme. General instructions:

  • VCC connects to Arduino 5V pin.
  • GND connects to Arduino GND pin.
  • CLK connects to Arduino pin 8.
  • DAT connects to Arduino pin 7.
  • RST connects to Arduino pin 6.

Upload Arduino Program

Screenshot 2020-03-08 at 21.02.45.png
Screenshot 2020-03-08 at 20.31.42.png

Yeah! All the hardware is set now. Let's catch up with software. First, download the firmware for your board available under this link:

Next, disconnect the HC-05 bluetooth module. This is very important as new code cannot be uploaded while the module is connected.

Use AVRDUDE

AVRDUDE is a tool used to upload firmware to AVR microprocessors, and it is included in the Arduino IDE so you already have it.

Windows
Open console and navigate to your Arduino IDE installation directory. Usually it's located somewhere in Program Files. Once you find it, navigate to this folder: /hardware/tools/avr/bin/.

Linux / Mac OS

If you installed Arduino IDE from official sources, you should already have avrdude added to your executable path.

Windows, Linux & Mac OS

Verify avrdude installation with this command. If help is displayed then you can proceed further. If you encounter any problems don't hesitate to ask Google about it.

avrdude --help

Upload firmware to your Arduino Uno board. Note: the firmware has been built specifically for Arduino Uno and it will not work for other Arduino boards.

avrdude -v -patmega328p -carduino -b115200 -P<arduino-usb-port> -D -Uflash:w:<path-to-firmware>:i

Once the firmware is uploaded, connect back the HC-05 bluetooth module.

Install Maya App From Play Store

Your board is now ready to be used. Download Maya App from Play Store for Android 5.0 or newer with available bluetooth adapter.

With Maya you can upgrade your house to be smart without investing lots of money in expensive brands. You can reuse the electronics you already have.

Time Programs - set your daily routines in a customizable time programs. For instance you can order your board to turn on and turn off periodically lights to scare off thieves.

Scenes - be spontaneous and activate actions which end up automatically after delay that you set.

Manual Control - works as a switch. Activate or deactivate pins according to your wish. For PWM pins percentage value is supported.

Connect to Your Board From Maya

Screenshot_20200308-192137_Maya.jpg
Screenshot_20200308-190834_Maya.jpg
Screenshot_20200308-202017_Maya.jpg

Alright, so far so good. Open the app and connect to the board.

  1. On the welcome screen choose I already configured a board. Let's connect to it.
  2. Enable bluetooth and scan for available devices. Once your board is discovered (Arduino_Maya) please click on it.
  3. Bluetooth pairing starts. Android OS will ask you for the pin in order to connect to the board. For HC-05 it's 1234 by default.
  4. In case for whatever reason you'll be disconnected, please report an issue using this link.
  5. You are connected. Congratulations! :D

Useful links

Help Center: https://apps.maroon-bells.com/maya/help_center.html
Facebook Page: https://www.facebook.com/Maya-App-101016548192466
Maya in Play Store: https://play.google.com/apps/testing/com.maroonbells.maja