Overview
The reasoning for starting this project was two-fold, firstly, its cool being able to turn your lights on and off with your phone. Secondly, I wanted to have an excuse to learn how to make mobile apps for controlling electronics projects. This post will just cover the hardware aspects, and use an already available Android Bluetooth serial app. The creation of a specific app will be covered in a future post once it is done.
This was the app I used for getting everything up and running.
https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal&hl=en_NZ&gl=US
Electronics
The electronics for this project are extremely simple, they just consist of an Arduino nano, an HC-06 Bluetooth module, and a 4 channel relay module. Four bare power outlets with screw terminals are also required to actually plug stuff in, although depending on your application you could just wire whatever device you want to control directly to the relay.
The HC-06 module communicates over serial, and needs to be hooked up to the TX and RX pins of the Arduino. The triggering pins for the relay module can be connected to any of the digital pins, in this case they are connected to digital pins 9, 10, 11, and 12.
Something to note with the relays are that they have 3 connections, common, normally closed, and normally open. The common, as the name suggests, connects to both of the other ports. Whether you use the normally open, or normally closed connection is decided by if you want the device off(normally open), or on(normally closed), when the relay is unpowered.
Code
Each channel of the relay board is triggered by sending the number of the channel to be triggered over Bluetooth, bitwise operations are then used for setting and clearing the relays. One thing to note with the code is that because the Bluetooth communication uses the hardware serial on the atmega328p, the HC-06 module should not be connected while programming the Arduino because it will interfere. If you wanted to avoid this you could use software serial, but in this this case, since I wasn't planning on reprogramming the Arduino once it's in use I didn't bother.
Comments
Post a Comment