Best IOT Project Making At Home using Microcontroller || PCBway
https://www.pcbway.com/?from=technology4power
Every electronic device needs PCBs. Are you looking for the Best PCB order? PCBWay is one the best PCB manufacturing companies. Order 10 pcs PCB for only $5. Visit now https://www.pcbway.com/?from=technology4power
The Internet of Things (IoT) is revolutionizing how we interact with everyday devices. From smart homes to industrial automation, IoT projects are becoming increasingly popular. If you're eager to dive into the world of IoT, this DIY guide is perfect for you. We will walk you through creating a robust IoT project using the PIC16F877A microcontroller, a 4-relay module, and other essential components. Whether you're a beginner or an experienced electronics hobbyist, this project will help you enhance your skills and bring your IoT ideas to life.
Why Choose PIC16F877A for Your IoT Project?
- The PIC16F877A microcontroller is a powerful and versatile choice for IoT projects. With 33 I/O pins, a wide range of peripherals, and robust performance, it can handle various sensors, actuators, and communication modules. Additionally, its ease of programming and availability make it a popular choice among hobbyists and professionals alike.
- Components Needed
- Here’s a list of the components you’ll need to build this IoT project:
- PIC16F877A Microcontroller: The central processing unit for the project.
- 4-Relay Module (5V): Allows you to control up to four different devices or appliances.
- 20MHz Crystal Oscillator: Provides the necessary clock signal for the microcontroller.
- Capacitors (22pF): For stabilizing the crystal oscillator.
- Voltage Regulator (7805): Ensures a stable 5V power supply to the microcontroller and other components.
- Diodes (1N4007): For protecting the circuit from reverse voltage.
- Transistors (BC547B): Used for switching and controlling the relays.
- Resistors: Various resistors for limiting current and voltage in the circuit.
- LEDs: For status indication.
- Push Buttons: To control inputs manually.
- Jumper Wires and Breadboard: For prototyping the circuit.
- Power Supply: A 12V DC adapter or battery.
- Wi-Fi Module (e.g., ESP8266): For wireless communication (optional for IoT connectivity).
- PCB: Custom-designed PCB to organize and streamline your project (recommended).
Circuit Explanation for the IoT Project Using PIC16F877A with Bluetooth Module
This image shows a fully assembled IoT project using a PIC16F877A microcontroller and a 4-relay module, controlled via a smartphone app through Bluetooth.
1. Microcontroller (PIC16F877A)
The PIC16F877A microcontroller remains the central processing unit of the project. It is connected to a 20MHz crystal oscillator to ensure proper timing and operation.
2. 4-Relay Module (5V)
The 4-relay module allows the microcontroller to control four different electrical devices, such as lights or fans. Each relay operates independently and is controlled by a digital output pin on the microcontroller through transistors.
3. Voltage Regulator (7805)
A 7805 voltage regulator is used to step down the 12V DC power supply to 5V, which powers the microcontroller and the relay module.
4. Bluetooth Module
Instead of using a Wi-Fi module, this project employs a Bluetooth module (such as HC-05 or HC-06) to enable wireless communication.
The Bluetooth module is connected to the microcontroller via UART (Universal Asynchronous Receiver-Transmitter) pins. This setup allows the microcontroller to receive commands sent from a paired smartphone app.
5. Smartphone App
The smartphone app is designed to communicate with the Bluetooth module, sending commands to control each relay.
The app features buttons that correspond to each relay, allowing the user to turn them on or off. The buttons are color-coded (red for off, green for on) to indicate the current state of each relay.
6. Circuit Connections
Power Supply: A 12V DC adapter is connected to the circuit, powering the entire system through the 7805 voltage regulator.
Relay Control: Each relay's control pin is connected to the microcontroller's digital output pins, and transistors are used to switch the relays.
Bluetooth Communication: The Bluetooth module's TX and RX pins are connected to the microcontroller's RX and TX pins, respectively, to establish a communication link.
Designing the PCB with PCBWay
PCBWay makes it easy to bring your circuit designs to life with high-quality, custom PCBs. Here’s how you can design your PCB for this project:
- Create the PCB Layout: Use PCB design software like Eagle or KiCad to draw your circuit and layout the components. Ensure proper spacing and trace width to handle the current requirements.
- Generate Gerber Files: Once your design is complete, export the Gerber files. These files include all the necessary information for manufacturing your PCB.
- Upload to PCBWay:
- Go to the PCBWay website.
- Click on "Quote Now" under the PCB services section.
- Upload your Gerber files and fill in the required details like board size, number of layers, material, thickness, and quantity.
- Choose any additional options like solder mask color or silkscreen.
- Review and Place Order: Review your PCB design and order details, then place your order. PCBWay offers fast production and shipping, so you’ll have your PCBs ready in no time.
- Assemble the PCB: Once you receive your PCB, solder the components onto the board according to your design. This will make your IoT project more reliable and easier to use.
https://www.pcbway.com/?from=technology4power
Every electronic device needs PCBs. Are you looking for the Best PCB order? PCBWay is one the best PCB manufacturing companies. Order 10 pcs PCB for only $5. Visit now https://www.pcbway.com/?from=technology4power
Code Explanation
Inclusion of PIC16F877A Header File:
#include <16F877A.h>: This line includes the header file specific to the PIC16F877A microcontroller, providing the necessary definitions and functions.
Microcontroller Configuration:
#fuses HS, NOWDT, NOPROTECT, NOLVP: These fuse settings configure the microcontroller as follows:
HS: High-Speed Oscillator.
NOWDT: Watchdog Timer disabled.
NOPROTECT: Code protection disabled.
NOLVP: Low-Voltage Programming disabled.
#use delay(clock=20000000): This sets the microcontroller's clock speed to 20MHz.
UART Configuration for Bluetooth Communication:
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7): This sets up UART communication at a baud rate of 9600, using pin C6 for transmission (xmit) and pin C7 for reception (rcv). These pins are connected to the Bluetooth module.
Relay Pin Definitions:
#define RELAY1 PIN_B0, #define RELAY2 PIN_B1, #define RELAY3 PIN_B2, #define RELAY4 PIN_B3: These define the relay control pins. Each relay is connected to a specific pin on PORTB of the microcontroller.
Main Function:
void main() { ... }: The main function of the program, which runs continuously.
Relay Pin Initialization:
set_tris_b(0xF0): This sets the lower four bits of PORTB (RB0-RB3) as output (for controlling relays) and the upper four bits (RB4-RB7) as input.
Infinite Loop (while(TRUE)):
while(TRUE) { ... }: The program enters an infinite loop to continuously check for incoming data from the Bluetooth module.
Checking for Incoming Data:
if(kbhit()) { ... }: This checks if data is available from the Bluetooth module.
data = getc(): If data is received, it is stored in the data variable.
Switch Case for Relay Control:
switch(data) { ... }: Based on the received data, the appropriate relay is turned on or off.
Case '1': Turns on Relay 1.
Case '2': Turns off Relay 1.
Case '3': Turns on Relay 2.
Case '4': Turns off Relay 2.
Case '5': Turns on Relay 3.
Case '6': Turns off Relay 3.
Case '7': Turns on Relay 4.
Case '8': Turns off Relay 4.
Default Case: If any other data is received, it is ignored.
How It Works
The microcontroller waits for a command from the Bluetooth module.
When a command is received, it checks which command it is and toggles the appropriate relay accordingly.
For example, if the command '1' is received, Relay 1 is turned on, and if '2' is received, Relay 1 is turned off.
This allows the user to control the connected devices wirelessly using a Bluetooth-enabled smartphone or other devices.
This setup is ideal for home automation projects, where you can control various appliances with ease.
CCSC Code:
#include <16F877A.h>
#fuses HS, NOWDT, NOPROTECT, NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Bluetooth communication
#define RELAY1 PIN_B0
#define RELAY2 PIN_B1
#define RELAY3 PIN_B2
#define RELAY4 PIN_B3
void main() {
char data;
// Initialize the relay pins as output
set_tris_b(0xF0); // Set RB0-RB3 as output, others as input
while(TRUE) {
if(kbhit()) { // If data received from Bluetooth
data = getc(); // Read the received data
switch(data) {
case '1':
output_high(RELAY1); // Turn on Relay 1
break;
case '2':
output_low(RELAY1); // Turn off Relay 1
break;
case '3':
output_high(RELAY2); // Turn on Relay 2
break;
case '4':
output_low(RELAY2); // Turn off Relay 2
break;
case '5':
output_high(RELAY3); // Turn on Relay 3
break;
case '6':
output_low(RELAY3); // Turn off Relay 3
break;
case '7':
output_high(RELAY4); // Turn on Relay 4
break;
case '8':
output_low(RELAY4); // Turn off Relay 4
break;
default:
break;
}
}
}
}
7. Operation
When the user presses a button on the smartphone app, a command is sent via Bluetooth to the Bluetooth module.
The Bluetooth module transmits the command to the microcontroller, which processes the command and activates or deactivates the appropriate relay.
The relay, in turn, controls the connected device, allowing the user to operate it remotely.
Video Reference:
Conclusion
By replacing the Wi-Fi module with a Bluetooth module, this project offers an easy and efficient way to control various devices wirelessly within a short range. This setup is ideal for home automation, allowing you to control your appliances directly from your smartphone through Bluetooth.
Best IOT Project Making At Home using Microcontroller || PCBway
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(1)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Estiak Khan
- How to Make a Simple DIY Mini DC Automatic IPS at Home Looking for a reliable power backup solution for your DC appliances? Building a Mini DC Automatic IP...
- DIY Easily Make a Universal Any Type of Battery Charge Controller At Home DIY Easily Make a Universal Any Type of Battery Charge Controller At HomeIf you’re into DIY electron...
- Make a 16-Channel Home IoT project using NodeMCU ESP32 WROOM Module If you're looking to build a versatile IoT device capable of controlling up to 16 appliances or devi...
- DIY Pure Sine Wave Inverter Making At Home DIY Pure Sine Wave Inverter Making at Home Using EGS002 Module: A Complete GuideBuilding your own pu...
- Build a MIND-BLOWING Mini Oscilloscope at Home with EST Projects Build a MIND-BLOWING Mini Oscilloscope at Home with EST ProjectsEver wondered how you can measure an...
- Best IOT Project Making At Home using Microcontroller || PCBway https://www.pcbway.com/?from=technology4powerEvery electronic device needs PCBs. Are you looking for...
- Universal Battery AutoCut Charge Controller with LCD - DIY at Home Are you looking to build a reliable and efficient battery AutoCut charge controller? Look no further...
- PIC16F877A Trainer Board Build Your Microcomputer || Home-Made Microcontroller Master Trainer Tutorial Banglahttps://www.pcbw...
-
-
-
kmMiniSchield MIDI I/O - IN/OUT/THROUGH MIDI extension for kmMidiMini
121 0 0 -
DIY Laser Power Meter with Arduino
172 0 2 -
-
-
Box & Bolt, 3D Printed Cardboard Crafting Tools
162 0 2 -