Introduction: Bluetooth Smart Plug(time Settable)
In this instructable, I would like to share you a simple and easy to be made hobby circuit. It is a Bluetooth based smart plug that can be turned on, off and can be set on for a specific time.
This is a low-cost DIY that uses simple stuff for making. The electronics part uses the microcontroller ATMega 328, Hc 05 Bluetooth module, and some other discrete components. The enclosure part uses AC plug, socket and some kind of plastic box.
Step 1: Make the Enclosure....
The very first step is to make the enclosure that has a plug (three pin or two pin type), a socket and a small plastic box.
2. Plug socket.
3.Some kind of plastic box from electrical shop.
We can make the enclosure going through these simple steps,
- Attach the three pins of the plug to the back of the box for AC input or to connect to the Ac mains switch board.
- Attach the three pin socket to the front of the box for AC output.
We have the simplest ever enclosure now.
Step 2: The Circuit.
This is the basic circuit of the system which has the microcontroller ATMega 328 as the core.
The HC 05 Bluetooth module stands as the communication block. The control signal sent from the app is received by the module and processed by the microcontroller. Based on the signal received, The power supply to the output power socket is controlled by the relay attached to the microcontroller.
The working power supply for the whole sections is provided by a 5 VDC SMPS taken out from the old mobile phone charger.
Step 3: Program the Micocontroller.
Programming the 328 is a crucial part here.We are going to program it using Arduino uno board.
In simple steps, we can program the microcontroller.
- Connect to the breadboard, the ATMega 328 that you bought.
- Make the pins 7 and 20 short circuited using jumper wires and connect them to vcc 5 V.
- Make the pins 8 and 22short circuited using jumper wires and connect them to ground.
- Connect a 16 MHz crystal and two 22 pF capacitors as shown in circuit diagram.
Now the connection circuit part is over.
- Take out/remove the microcontroller 328 from your Arduino board.
- Connect 5 V and GND of Arduino board to the breadboard.
- Connect the RESET pin of the Arduino board to the pin number 1 of the 328.
- Connect the RX pin of Arduino to the pin number 2 of the 328.
- Connect the TX pin of Arduino to the pin number 3 of the 328.
- Connect a 1 K ohms resistor from pin number 1 of the 328 to the VCC.
Now the Arduino connections are over, then
- Select in Arduino IDE,
Tools > Board > Arduino duemilanove or diecimila
- Then select
Processor > ATMega 328
After these upload the code to the microcontroller.
I am attaching here my code.
You can refer this instructable if you have any doubts in Arduino stand alone programming:https://www.instructables.com/id/Program-ATmega-328-Using-Arduino-Arduino-As-ISP/
Step 4: Make the Circuit.
I am using a simple circuit here. Only a few components are needed.
- ATMega 328.
- Base for ATMega 328.
- 16 MHz crystal.
- 22 pF capacitors.
- HC 05 Bluetooth module.
- BC 547 transistor.
- 330-ohm resistor.
- 4.7 K ohms resistor.
- Red LED.
- Vero board/universal PCB(dotted).
After collecting all these, we have to do the circuit as,
- Solder the IC base on the bread board.
- Now, solder the other discrete components as per the circuit diagram.
- Use jumper wires for connection.
- Connect the Bluetooth module using small wires.
- Place the programmed 328 onto the base.
Step 5: Build the App...!
The app is a simple one which has a few buttons for control.
I made the app using Appinventor.com, a user-friendly website for DIY persons and students to make the app without android/java programming knowledge.
Refer this instructable for more clarification about appinventor.com.
BASICS OF THE APP:
The app has 12 buttons, named ON, OFF,1minute, 5 minutes, 30 minutes, 1 hour and so on.
After connecting the app to Bluetooth module, When the button ON is pressed the app sends a byte number "1".
When the OFF button is pressed, the app sends the byte number "2" and so on up to number 12 for 12 buttons.
The microcontroller is programmed in such away that whenever it receives a number from the app via the Bluetooth module, it controls the AC output accordingly (on, off or set on a time delay as per app button pressed).
I am attaching my app here.
Step 6: The Power Supply.
The working power supply needed is a 5 V DC supply.
I broke down some old mobile phone chargers and took out its board.
We have to choose a small one to fit it inside the box.
Step 7: Put Everything Together.
In this final step, we have to connect everything together, the PCB, the power supply, the plug and the socket as per the circuit diagram.
- Connect the power supply board to the Plug connection.
- Connect the power supply output to the PCB.
- Connect one of the plug lines to the socket, And connect the other line to the output pin of the em relay.
- Connect the second pin of em relay to the socket.
- Isolate every part each other using some double sided sticker in between them.
- Make sure the plug connection does not touch the PCB.
- Close the enclosure.
Step 8: We Made It.. :)
Participated in the
Lazy Life Challenge
Participated in the
Participated in the
Automation Contest 2017